Page 1 of 1

Problem with rules for fan control with humidity and PWM

Posted: 29 Dec 2023, 21:42
by obstbauer
Hello,
I try to control a fan with measured humdity, PWM and rules but I don't find a working solution.
I know how to do it with python or C but I have problems to understand the rules logic.
I want to control:

Humid < 50 PWM 300
Humid >51 and <61 PWM 700
Humid >61 and < 70 PWM 900
Humid > 70 PWM 1023

The hardware and the sensors work.
I tried things like that:
On
if [BME280#Humidity]>51 and [BME280#Humidity]<61
PWM,12,700
end if
Endon

for every step one rule but it doesn't work

The only thing which works was:

On BME280#Humidity<50 Do
PWM,12,300
Endon

On BME280#Humidity>50 Do
PWM,12,1023
Endon

in one rule but with this I only have two steps.

Maybe you can help me? Thank you!

Re: Problem with rules for fan control with humidity and PWM

Posted: 29 Dec 2023, 21:53
by TD-er
Humid < 50 PWM 300
Humid >51 and <61 PWM 700
Humid >61 and < 70 PWM 900
Humid > 70 PWM 1023
See: https://espeasy.readthedocs.io/en/lates ... lseif-else

Code: Select all

On BME280#Humidity Do
  if %eventvalue1% > 70
    pwm,12,1023
  elseif %eventvalue1% > 60
    pwm,12,900
  elseif %eventvalue1% > 50
    pwm,12,700
  else
    pwm,12,300
  endif
Endon

Re: Problem with rules for fan control with humidity and PWM

Posted: 29 Dec 2023, 23:06
by obstbauer
it works!
Thanks a lot !