I am trying to understand the logic in RM4 so I am doing so by trying to recreate some of my existing rules for learning purposes.
I have a rule that turns off the exhaust fan in the bathroom 5 mins after the bathroom light is turned off.
Two questions...
Should I have the rule set to only turn off the fan if its on or does that not matter?
How do I setup the rule so that if the light is turned back on while the fan delayed off is counting down it cancels the delayed off?
@cory I totally understand and I am sure that there are a lot of others that will agree. But the reason I put in my post was to see if the way I see it actually happening is correct. To me putting the cancel before the actual delay was throwing me. So putting things in the logical order seemed to help.
Do you always want the bathroom fan on if the light is on? If so, then I would use this rule. Otherwise I would remove turning the bathroom fan on in the first part of the action.
I would also add the fan itself turning off as a trigger and then part of the first condition to cancel the delayed actions. If you turn it off manually, there's no sense in trying to turn it off again later.
That is incorrect. If you are getting that, then please post your rule that is giving you that error. You should always cancel your delayed actions before doing anything else because if something else errors, your delayed actions won't be canceled.
This is overly complicated....Plus, why do you have two if statements for opposite conditions? that's what Else or Else If is for. By definition the light cannot be on and off at the same time, correct? So, I would move them to one if/else statement and make things easier.
This will also attempt to cancel a delay that doesn't exist when the light is on.
This makes no difference to the rule. If this matters to you, I would do this:
If: Bathroom light off
Turn off fan after 5 min delay (cancelable)
Else
Cancel Delayed actions
Turn on bathroom fan
End-If
But again, that surmises that someone would want the fan on whenever the light was on, which i know i don't. So, that part can be removed.