I’m setting up a rule that turns on the bathroom exhaust fan if the humidity in the bathroom is 10 percentage points higher than the humidity in the livingroom.
Additionally, I want the fan to stay on no more than one hour at a time, and come back on no sooner than 15 minutes after it last shut off.
I think the following rule will do that, but it’s hard to test without running the shower a bunch
And there’s a warning in designer on the line where I subtract the value of the livingroom humidity from the value of the bathroom humidity. What did I do wrong?
import org.joda.time.*
var DateTime FanTimeOn = null
var DateTime FanTimeOff = null
rule "Bathroom exhaust fan"
when
Item BRHumiditySensorCurrentLevel received update
then
var BRHumid = BRHumiditySensorCurrentLevel.state
var LRHumid = LRHumiditySensorCurrentLevel.state
if(FanTimeOn == null && FanTimeOff.plusMinutes(20).isBeforeNow()) {
if(BRHumid - LRHumid => 10){
BathroomFan.sendCommand(ON)
FanTimeOn = now.toDateTime
}
}
else if(FanTimeOn != null && FanTimeOn.plusMinutes(60).isBeforeNow()){
BathroomFan.sendCommand(OFF)
FanTimeOff = now.toDateTime
}
end