Rules for bathroom ventilation
Moderators: grovkillen, Stuntteam, TD-er
Rules for bathroom ventilation
Hi all,
could any one please assist me with a espeasy rule?
I would like to setup an bathroom ventilation rule,
so when the lux value is above 100 and/or the humidity is above 65 the fan should turn on and stay on for 5min.
I am using a wemos d1, dht22 and a bh1750.
This is the rule I have to far: but the "delay" doesn't work...
On System#Boot do
gpio,0,0
endon
On Light#Lux>100 do
gpio,0,1
endon
On Light#Lux<99 do
delay 300
gpio,0,0
endon
thx
sawo
could any one please assist me with a espeasy rule?
I would like to setup an bathroom ventilation rule,
so when the lux value is above 100 and/or the humidity is above 65 the fan should turn on and stay on for 5min.
I am using a wemos d1, dht22 and a bh1750.
This is the rule I have to far: but the "delay" doesn't work...
On System#Boot do
gpio,0,0
endon
On Light#Lux>100 do
gpio,0,1
endon
On Light#Lux<99 do
delay 300
gpio,0,0
endon
thx
sawo
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Rules for bathroom ventilation
Never use delay, it's blocking.
This rule will have the fan running until the lux and humidity is below those values and then run for 300 seconds.
Code: Select all
On System#Boot Do
Let,1,0
EndOn
On Humidity#Level>65 Do
Event,FanOn
EndOn
On Light#Lux>100 Do
Event,FanOn
EndOn
On FanOn Do
GPIO,0,1
TimerSet,1,300
EndOn
On Rules#Timer=1 Do
GPIO,0,0
EndOn
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: Rules for bathroom ventilation
hi grovkillen,
thanks alot for your help again!!!
It works!!!
Thanks
thanks alot for your help again!!!
It works!!!
Thanks
Re: Rules for bathroom ventilation
Hi grovkillen,
do you think you can help me again with this rule?
I want to have a short delay of 30sec, before the fan turns on, when the lux value is greater then 100.
How can I realize this.
thx
sawo
do you think you can help me again with this rule?
I want to have a short delay of 30sec, before the fan turns on, when the lux value is greater then 100.
How can I realize this.
thx
sawo
- grovkillen
- Core team member
- Posts: 3621
- Joined: 19 Jan 2017, 12:56
- Location: Hudiksvall, Sweden
- Contact:
Re: Rules for bathroom ventilation
Code: Select all
On System#Boot Do
Let,1,0
EndOn
On Humidity#Level>65 Do
If [Light#Lux]>100
TimerSet,2,30
Else
Event,FanOn
EndIf
EndOn
On Light#Lux>100 Do
Event,FanOn
EndOn
On FanOn Do
GPIO,0,1
TimerSet,1,300
EndOn
On Rules#Timer=1 Do
GPIO,0,0
EndOn
On Rules#Timer=2 Do
Event,FanOn
EndOn
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you

ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you



Re: Rules for bathroom ventilation
Hello,
I made recently a bathroom fan control based on light on / off ( lux detection was not possible because our bathroom has a window!).
The control is based on the idea to mesure the humidity when the light is switched on, to switch the fan if the humidity value is above a certain level for me : 40%.
Experrience shows me that the humidity change quickly after after fan runs because the humidity sensor near the fan mesures the real ambiance air humidity after some time. So i make a new mesure 60 sec after light on.
When light is switched off : new mesure and compare with value at beginning. If no change turn fan off. If humidity has increased, run the fan until hum level reachs the start level.
After 15 min stop fan anyway. If light is switched on when fan is running no new value is mesured because the deshumidification process is still ongoing : this could be the case to turn light on quickly after having turn thr light off.
Data are send to home assistant for management
See my rules below
See physical layout
and rules ... please delete comments to save space !!
Have fun ...
Patou
I made recently a bathroom fan control based on light on / off ( lux detection was not possible because our bathroom has a window!).
The control is based on the idea to mesure the humidity when the light is switched on, to switch the fan if the humidity value is above a certain level for me : 40%.
Experrience shows me that the humidity change quickly after after fan runs because the humidity sensor near the fan mesures the real ambiance air humidity after some time. So i make a new mesure 60 sec after light on.
When light is switched off : new mesure and compare with value at beginning. If no change turn fan off. If humidity has increased, run the fan until hum level reachs the start level.
After 15 min stop fan anyway. If light is switched on when fan is running no new value is mesured because the deshumidification process is still ongoing : this could be the case to turn light on quickly after having turn thr light off.
Data are send to home assistant for management
See my rules below
See physical layout
and rules ... please delete comments to save space !!
Code: Select all
On system#boot do
let,1,50 // Hum Ecl On
let,2,18 //Temp Ecl On
let,3,51 //Hum Ecl Off
let,4,19 // Temp Ecl Off
let,5,0 // Delta Hum
let,6,0 // Delta Temp
let,7,900 // Tempo max Fan on in sec
let,8,40 // low limit Hum %
let,9,0 // fan was not on
gpio,0,0 // Fan Off
// timer 1 : check interval hum level if Ecl = 0ff
// timer 2 : max run time of fan
// timer 3 : recheck Hum after Ecl On
endon
On Ecl#State=1 do // Ecl On
if [Fan#State] = 0
Let,1,[Temp_Hum#°C]
Let,2,[Temp_Hum#Hum%]
Let,3,[Temp_Hum#°C]
Let,4,[Temp_Hum#Hum%]
Let,9,0
TaskValueSet,12,1,[var#2] // Store actual hum in non volatile variable
else
Let,9,1 // fan was on
endif
if [Temp_Hum#Hum%] > [var#8] // higher than low limit hum %
Gpio,0,1 // Fan On
Publish, %sysname%/Fan,"On"
endif
Timerset,3,60 // wait 60 sec and take a new hum mesure
Publish, %sysname%/Ecl,"On"
Endon
On Rules#timer=3 do // new mesure 60 sec after Ecl = On (time needed for ambiance air to reach the fan hum sensor)
if [Temp_Hum#Hum%]> [var#8] and [Ecl#State]=1
Gpio,0,1 // Fan On
Publish, %sysname%/Fan,"On"
else
Timerset,3,60
endif
if [Var#9] = 0 // only if fan was not already on
Let,1,[Temp_Hum#°C]
Let,2,[Temp_Hum#Hum%]
TaskValueSet,12,1,[var#2]
endif
endon
On Ecl#State=0 do // Ecl Off -> store actual values in spare variables
Let,3,[Temp_Hum#°C]
Let,4,[Temp_Hum#Hum%]
Let,5,[var#3]-[var#1]
Let,6,[var#4]-[var#2]
TaskValueSet,12,2,[var#4]
TaskValueSet,12,3,[var#6]
Publish, %sysname%/Ecl,"Off"
Timerset,1,10 // wait 10 sec
Timerset,2,[var#7]
endon
// Rules set 2
On Rules#timer=1 do
if [var#5] <= 1 // If hum did not increase ...
Gpio,0,0 // Fan off
Publish, %sysname%/Fan,"Off"
else
Let,3,[Temp_Hum#°C] // if not : reload the variables
Let,4,[Temp_Hum#Hum%]
Let,5,[var#3]-[var#1]
Let,6,[var#4]-[var#2]
TaskValueSet,12,2,[var#4]
TaskValueSet,12,3,[var#6]
Publish, %sysname%/Hum1, [var#2]
Publish, %sysname%/Hum2, [var#4]
Publish, %sysname%/Delta_Hum, [var#6]
Timerset,1,10
endif
endon
On Rules#timer=2 do
Gpio,0,0 // after 15 min Fan off
Publish, %sysname%/Fan,"Off"
Timerset,1,0
endon
On Temp_Hum#°C do
Publish, %sysname%/Temp, [Temp_Hum#°C]
Publish, %sysname%/Hum, [Temp_Hum#Hum%]
Publish, %sysname%/Atm, [Temp_Hum#hPa]
Publish, %sysname%/Delta_Hum, [var#6]
endon
Patou
Re: Rules for bathroom ventilation
One ac adapter is the power supply (on the board)
The other monitors the on /off of the light
The other monitors the on /off of the light
Who is online
Users browsing this forum: No registered users and 15 guests