How to stop a rule from looping

I've created a rule that is supposed to identify when a switch is turned off, wait 1 minute and turn it back on, wait 5 minutes and turn off and end. The purpose of the rule is to turn on the fan in the toilet to get rid of any lingered distasteful smells after the room has been vacated.

The problem is, it is just a loop. As soon as it turns itself off, it restarts the rule again, thus turning itself back on for 5 minutes.

I tried inserting Wait Until switch is switched back on, but it still loops.

I'm at a loss

You'll need to post a screenshot of the rule in order for anyone to assist. But in essence how can it ever end if the trigger is that the switch is off and your rule turns off the switch (re triggering the rule)

It might need to be triggered by the fan turning on....Something like:
Required expression - private boolean true
Trigger - fan switch turns on
Actions:

  • Set private boolean false
  • Wait until fan turns off
  • Wait 1 minute
  • Turn fan switch on
  • Wait 5 minutes
  • Turn fan switch off
  • Set private boolean true

The private boolean needing to be true for the rule to trigger, setting it false as the first action and back to true again as the last action should prevent you re-trigger problem.

1 Like

Thank you! That's done the trick. I really appreciate that

1 Like

No problem. Private Boolean used that way is very handy when you need all actions to complete without a rule re-triggering and starting the actions again.

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