Lua script for controlling humidity in the bathroom Topic is solved
Moderator: leecollings
-
- Posts: 10
- Joined: Tuesday 13 October 2015 10:04
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Lua script for controlling humidity in the bathroom
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
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
-
- Posts: 4
- Joined: Sunday 03 January 2016 15:11
- Target OS: Windows
- Domoticz version:
- Contact:
Re: Lua script for controlling humidity in the bathroom
I have a question regarding the code below.
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.
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
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.
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Lua script for controlling humidity in the bathroom
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.almirhod wrote:I have a question regarding the code below.
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?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
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.
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.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 4
- Joined: Sunday 03 January 2016 15:11
- Target OS: Windows
- Domoticz version:
- Contact:
Re: Lua script for controlling humidity in the bathroom
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.
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.
-
- Posts: 12
- Joined: Monday 13 July 2015 12:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Lua script for controlling humidity in the bathroom
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.
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.
-
- Posts: 12
- Joined: Monday 13 July 2015 12:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Lua script for controlling humidity in the bathroom
Does anyone have a suggestion?
-
- Posts: 139
- Joined: Thursday 19 February 2015 21:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Lua script for controlling humidity in the bathroom
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
https://www.domoticz.com/wiki/Automate_ ... nds_shades
or a bit updated version in this topic
viewtopic.php?t=6085
-
- Posts: 23
- Joined: Sunday 22 March 2015 6:41
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Lua script for controlling humidity in the bathroom
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).
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).
-
- Posts: 139
- Joined: Thursday 19 February 2015 21:48
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Lua script for controlling humidity in the bathroom
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!
I will share the script when ready!
Re: Lua script for controlling humidity in the bathroom
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.
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.
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Lua script for controlling humidity in the bathroom
Did you create the uservariables in Domoticz as described in the wiki?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Re: Lua script for controlling humidity in the bathroom
Yes I did create the 6 variable with integer @ 0dannybloe wrote:Did you create the uservariables in Domoticz as described in the wiki?
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Lua script for controlling humidity in the bathroom
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:
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.
Code: Select all
humCounter = tonumber(uservariables['humCounter'])
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Re: Lua script for controlling humidity in the bathroom
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
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
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Lua script for controlling humidity in the bathroom
Good luck.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Re: Lua script for controlling humidity in the bathroom
Thx again Dan !
it's confirm I can see interaction between humidity increase and FAn ON/OFF.
cheers
it's confirm I can see interaction between humidity increase and FAn ON/OFF.
cheers
-
- Posts: 6
- Joined: Tuesday 14 January 2014 15:06
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Lua script for controlling humidity in the bathroom
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.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
Re: Lua script for controlling humidity in the bathroom
this one may do the work... I haven't tried itjorns wrote:Can someone give us a clue how to implement a second humiditysensor that can control the fan?.pecora wrote:Does anyone have a suggestion?
thx
https://github.com/BazemanKM/Domoticz-M ... 20humidity
let us know
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: Lua script for controlling humidity in the bathroom
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'.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Re: Lua script for controlling humidity in the bathroom
could you pls confirm if dzVents could run directly on Windows ?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'.
Who is online
Users browsing this forum: No registered users and 0 guests