Another bathroom ventilation project

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Bluesea
New user
Posts: 5
Joined: 16 Jun 2020, 15:26
Location: Switzerland

Another bathroom ventilation project

#1 Post by Bluesea » 15 Oct 2023, 12:10

Hello

I have a two speed bathroom fan. I want to turn them on depending on the humidity. And it should block from turning on automatically during the night.
I put everything together, And it runs so far, but he is running always on level 1. I think something on my script is wrong.
Does anyone with experience see the fault?



on [TempHum#Humidity]<65 do //if humidity under lowerlevel then van off
gpio,14,1
gpio,12,1
endon

on [TempHum#Humidity]>65 and [TempHum#Humidity]<75 do //if humidity between lower and uper level then van level1
if [VirtualSwitch1#Dummy1]=0 //check if night block
gpio,14,0
gpio,12,1
endif
endon

on [TempHum#Humidity]>75 do //if humidity over uperlevel then van level2
if [VirtualSwitch1#Dummy1]=0 //check if night block
gpio,14,0
gpio,12,0
endif
endon

User avatar
Ath
Normal user
Posts: 3520
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Another bathroom ventilation project

#2 Post by Ath » 15 Oct 2023, 12:26

Bluesea wrote: 15 Oct 2023, 12:10 Hello

I have a two speed bathroom fan. I want to turn them on depending on the humidity. And it should block from turning on automatically during the night.
I put everything together, And it runs so far, but he is running always on level 1. I think something on my script is wrong.
Does anyone with experience see the fault?
There are a few syntax errors in your code: (Check Rules syntax here: https://espeasy.readthedocs.io/en/lates ... Rules.html)

Code: Select all

on TempHum#Humidity do
  if %eventvalue1%<65 or [VirtualSwitch1#Dummy1]=1 //if humidity under lower level or night-block then fan off
    gpio,14,1
    gpio,12,1
  endif
  if %eventvalue1%>65 and %eventvalue1%<75 //if humidity between lower and upper level then fan level1
    if [VirtualSwitch1#Dummy1]=0  //check if night block
      gpio,14,0 
      gpio,12,1
    endif
  endif
  if %eventvalue1%>75 //if humidity over upper level then fan level2
    if [VirtualSwitch1#Dummy1]=0 //check if night block
      gpio,14,0
      gpio,12,0
    endif
  endif
endon
(Kept the code structure close to your original)
(Air code ;))
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8756
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Another bathroom ventilation project

#3 Post by TD-er » 15 Oct 2023, 12:37

Yep, the main thing you should realize is that in the on...do part you should not use []
When parsing the rules, everything wrapped in [] is being converted into a numerical.
Thus the on...do part will probably not match if you use [] in that line.

Also you can't use "and" or other logic operators in the on...do line.

Bluesea
New user
Posts: 5
Joined: 16 Jun 2020, 15:26
Location: Switzerland

Re: Another bathroom ventilation project

#4 Post by Bluesea » 15 Oct 2023, 12:52

Wow, thank you very much! Now it does what I want. I'm still learning this rules.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 27 guests