I can't figure out why my rule machine code doesn't work

Hi! I have one fan that works in two separate rooms (divided by a wall) - the bathroom and the toilet. The Hue light in the toilet is triggered by the contact sensor, and then turned off again by that as well, which works perfectly, and I have a separate rule for that. As for the fan: I want the fan to come on 30 seconds or so after the light in the toilet is triggered, and then off again a bit later. I also want the fan to come on if the humidity sensor in the bathroom hits a threshold and then come off again if the humidity sinks to an acceptable level.

As it is only one fan for both those things, I find that having one rule to control the fan in these different ways is fiddly.... But: I think I've managed. Except for the fact that, the fan never comes off, so turning the fan off does not work in this rule, and I don't understand why it doesn't.

I'd appreciate any help!

So I thought the trigger was, if the light in the toilet changes? So, if it's off and then turns on, or if it's on and then turns off? How come, in the toilet, the light turns on, then the fan comes on, then the light turns off, but the fan keeps going indefinitely?

Are you saying it would help if I changed the "ELSE IF" to "END IF"?

I put that as an OR trigger... does that not mean that if either the light in the toilet comes on OR tthe humidity is high, the rule runs?

As it stands, whether "Toilet" turns on or off, if Bathroom fan if off, it will turn on.

You're looking at Toilet being changed or the humidity to be a factor, but then you're taking the condition of the fan being off to be a reason to turn it on. Remove that part and just use the toilet condition (however it needs to be) and humidity to be where you want it to be for turning the fan ON.

ELSE-IF, the humidity is in the range you want AND the toilet condition is opposite of what triggered the fan, THEN turn the fan OFF.

Be sure to also add END-IF at the end of your IF-THEN statement.

This I don't understand - I mean, the fan should only turn on "if the fan is off", "else if the fan is on" then it should turn off....?

Thanks, I will try that out!!

Thanks... But presumably this would then mean that someone going to the toilet would not trigger the fan? (for the purpose of removing unpleasant smells)

Thanks for all your help! Sadly, I couldn't get anything to work.... In the end, I've now got one rule where the fan is triggered by the humidity in the bathroom or by the toilet light coming on, that works well.

Then I've got another simple rule where the fan is turned off when the toilet light goes off (turning it off after the bathroom humidity is down will just have to be a manual thing).

I tried doing that with a delay, with the effect being that the rule didn't work - so, if the light goes off, then fan goes off works, but if the light goes off then fan goes off after one minute does not work.

That makes no sense to me at all, and to be honest I'm now a bit frustrated with rule machine...

It's not an issue with the devices involved - the Hue light in the toilet (through the Hue integration) works perfectly through Dashboard etc, so does the fan (which is a Fibaro relay switch).

i would remove the "Bathroom and Toilet Fan is on" in the ELSE-IF. if the toilet light turns on/off in under 30 seconds, the fan will not be running to trigger the ELSE statement. just leave it as

ELSE-IF (toilet is off OR humidity < 55)

2 Likes

OK, I'll try that...!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.