Page 4 of 8
Re: Lua script for controlling humidity in the bathroom
Posted: Friday 30 October 2015 9:50
by Cybertom
aaahhh i get it.
I must read this in a different way. not like
(fan = off and fanfollowprogram = 0) or (fan = on and fanfollowprogram = 0)
but
(fan=off) or (fan=on and fanfollowsprogram = 0)
That make sense to me, Thanks Dannyblo
Re: Lua script for controlling humidity in the bathroom
Posted: Sunday 03 January 2016 15:51
by almirhod
I have a question regarding the code below.
Code: Select all
if (fanFollowsProgram == 1 and otherdevices[FAN_NAME]=='Off') then
-- likely someone turned off the ventilator while the program was running
fanFollowsProgram = 0
end
Why do you reset the program when the fan is OFF? Doesnt it make more sense to turn the fan back ON and finish the ongoing program?
Maybe I'm missing something but dont your risk that the next humidity measure is the same or lower and therefore not starting the fan at all. Best case a few degrees higher.
Re: Lua script for controlling humidity in the bathroom
Posted: Sunday 03 January 2016 20:11
by dannybloe
almirhod wrote:I have a question regarding the code below.
Code: Select all
if (fanFollowsProgram == 1 and otherdevices[FAN_NAME]=='Off') then
-- likely someone turned off the ventilator while the program was running
fanFollowsProgram = 0
end
Why do you reset the program when the fan is OFF? Doesnt it make more sense to turn the fan back ON and finish the ongoing program?
Maybe I'm missing something but dont your risk that the next humidity measure is the same or lower and therefore not starting the fan at all. Best case a few degrees higher.
Well, I thought that if someone turned it off while the program was running there must have been a good reason for it. In fact, I use this 'feature' sometimes. Sometimes I don't want all the heat in the bathroom to be sucked away while I am still there and if there is not much moist then I just turn it off (in effect canceling the de-humidification program). But you can easily remove that piece of code if you want to.
I am considering to adapt the script a bit so that it starts the de-humid program only until there is nobody left in the bathroom or when the lights are out. That way you don't suck out all the warmth while there are still people in there. Guess that's not very hard to do. But I'm not sure yet how.. if I'm gonna use the PIR (motion) data, the lux values or the state of the light/dimmer switch.
Re: Lua script for controlling humidity in the bathroom
Posted: Monday 04 January 2016 9:55
by almirhod
Ok, now I understand why you want to stop the program.
In my case the light and fan is controller by direct association with a MultiSensor. The Multisensor turns ON/OFF the fan/light based on movement. So I want the script to start the de-humidification and keep the fan ON even if the multisensor turns it off. My priority is to get rid of humidity first so I dont want anyone to be able to stop the program.
Anyhow the script looks good. I wanted to write a similar script and was reading Domoticz WIKI. Selected a random script just to see an example and this was the script.
Re: Lua script for controlling humidity in the bathroom
Posted: Saturday 14 May 2016 23:47
by pecora
Very nice script...! It helped me out in the bathroom.
But I've got another sensor in the kitchen. How can I implement that one in the script?
Cant make a new script because I can't paste him also in "on action" of the fan.
Re: Lua script for controlling humidity in the bathroom
Posted: Tuesday 17 May 2016 11:06
by pecora
Does anyone have a suggestion?
Re: Lua script for controlling humidity in the bathroom
Posted: Friday 27 May 2016 12:06
by franzelare
i have my script based on a sunscreen script, works the same and also time out after manual operation can be re-used
https://www.domoticz.com/wiki/Automate_ ... nds_shades
or a bit updated version in this topic
viewtopic.php?t=6085
Re: Lua script for controlling humidity in the bathroom
Posted: Wednesday 01 June 2016 22:41
by sj3fk3
Very nice script! I was messing about with a lot of nodes in a node-red flow (using mqtt), but this is much cleaner..
My only optimisation would be to store all variables in 1 object (I don't really need to humanly read the different values). That way it's much easier to use the script for more then 1 fan/sensor combination (I have 2 sets in my house).
Re: Lua script for controlling humidity in the bathroom
Posted: Saturday 04 June 2016 7:59
by franzelare
I plan to add an methane sensor to my script, I have the sensor only need to do the coding for a mysensor wifi node... (ESP01)
I will share the script when ready!
Re: Lua script for controlling humidity in the bathroom
Posted: Thursday 09 June 2016 19:40
by toups
Hi all and thx to Dan for this script.
Having said this, I have an issue with an error msg that comes every minutes:
"2016-06-09 19:35:00.426 Error: EventSystem: in script_time_humidity: [string "..."]:62: attempt to perform arithmetic on global 'humCounter' (a nil value)"
which refers to line 62 which is "humCounter = humCounter + 1"
To give more detail, I'm using Domotocz on Win7 & RFLINK and my sensors are dual (temp+hum sensors).
Many thx in advance for those who may have tips & tricks or elements that could help me to investigate.
Re: Lua script for controlling humidity in the bathroom
Posted: Thursday 09 June 2016 20:17
by dannybloe
Did you create the uservariables in Domoticz as described in the wiki?
Re: Lua script for controlling humidity in the bathroom
Posted: Thursday 09 June 2016 20:26
by toups
dannybloe wrote:Did you create the uservariables in Domoticz as described in the wiki?
Yes I did create the 6 variable with integer @ 0
Re: Lua script for controlling humidity in the bathroom
Posted: Thursday 09 June 2016 20:30
by dannybloe
I assume you use the same script as in the wiki. The only thing that I can think of is that this results in a nil value:
Code: Select all
humCounter = tonumber(uservariables['humCounter'])
Are you sure that you didn't make a typo when creating the variable? It must be exactly with that name. If you did then maybe remove the variable and create it again.
Re: Lua script for controlling humidity in the bathroom
Posted: Thursday 09 June 2016 20:35
by toups
Bingo !!!!
well spotted Dan... a space was before the variable name "humCounter" ...
Sorry for this and many thx for your suggestion
I look forward to check how it goes now
But I'm not going to take an another shower this evening
cheers
Re: Lua script for controlling humidity in the bathroom
Posted: Thursday 09 June 2016 20:36
by dannybloe
Good luck.
Re: Lua script for controlling humidity in the bathroom
Posted: Friday 10 June 2016 11:50
by toups
Thx again Dan !
it's confirm I can see interaction between humidity increase and FAn ON/OFF.
cheers
Re: Lua script for controlling humidity in the bathroom
Posted: Friday 10 June 2016 18:37
by jorns
pecora wrote:Does anyone have a suggestion?
Nice peace of work. Works like charm in my bathroom. I even empty my hot water tank to just try it out
. Though i have the same issue as pecora.
Can someone give us a clue how to implement a second humiditysensor that can control the fan?.
thx
Re: Lua script for controlling humidity in the bathroom
Posted: Friday 10 June 2016 19:03
by toups
jorns wrote:pecora wrote:Does anyone have a suggestion?
Can someone give us a clue how to implement a second humiditysensor that can control the fan?.
thx
this one may do the work... I haven't tried it
https://github.com/BazemanKM/Domoticz-M ... 20humidity
let us know
Re: Lua script for controlling humidity in the bathroom
Posted: Friday 10 June 2016 19:56
by dannybloe
I will make a version in the coming days that will support multiple devices. It will be based on
dzVents though because that allows me to check previous readings more easily. And it is much easier to support multiple 'rooms/devices'.
Re: Lua script for controlling humidity in the bathroom
Posted: Monday 13 June 2016 14:20
by toups
dannybloe wrote:I will make a version in the coming days that will support multiple devices. It will be based on
dzVents though because that allows me to check previous readings more easily. And it is much easier to support multiple 'rooms/devices'.
could you pls confirm if dzVents could run directly on Windows ?