Delay Rule Machine Rule From Running Again For x Minutes

I have a rule to wake my computer up if I trigger my office motion sensor. It works great, and finally got the conditions to only trigger during certain times

But I'm struggling to prevent the rule from executing all the time. I want the rule to fire, but then not be able to fire for 15 minutes. I can't get the delays and waits to work, and it doesn't seem like I can set a delay based off the last time the rule ran.

I tried putting a delay after "on: mainline", but that didn't prevent the rule from firing additional times.

Also I tried "time since Mainline was set 'on'", but that doesn't work, because Mainline is a psuedo-switch, and Hubitat doesn't know it's actual status, so that expression is always false. Hence I'm trying to base it off the last time the rule was run, not the last time Mainline was on.

Any help would be appreciated, thanks!

There are many ways you could do this, but here is my suggestion. Add three actions after your "On" action: Set Private Boolean False (This Rule), Delay 0:15:00, and Set Private Boolean True (This Rule). Then, turn on "Use required expression," and add a required expression of Private Boolean true. A required expression being false will prevent the rule from triggering.

Finally, add an END-IF at the end, just to make things synactically correct. Won't cause problems here, but it's a good habit. :slight_smile:


Awesome! Thanks so much, worked great! I also noticed I could pause the rule, delay for 15 minutes, but then when I switch to "resume", "This Rule" isn't an option. Is that because it's currently active, so it won't let you resume it, even though it would be inactive at the time?

Thanks again!

Right, you can't un-pause a rule from itself. You could do it with another rule, though!

1 Like

Hmm, came back after lunch and the rule didn't fire. Looks like the private var might be stuck in false? According to the logs, it looks like it set it false, waited, but then didn't turn it true? or do I have something set wrong? Thanks again for the help!!

I don't see a timespan of 15 minutes in your logs, so I don't see where it would have reached the point for Private Boolean to be set false. But I do see an "Initalized" as your most recent entry, only three minutes after the 15-minute delay started, which suggests you may have hit "Done" or "Update Rule." This will sort of re-initialize the rule, including un-scheduling any scheduled jobs (like delays), so you should avoid doing so while these are still pending--otherwise, you could get stuck in a state like this. (If you were just trying to view the rule, you can back out or close the window/tab without a concern--the caution against doing this, in case that was the concern, applies when you are editing the rule.)

If your IF would currently evaluate to true (it would have when you took this screenshot), you can work around this by just hitting "Run Actions," as long as you're OK with the actions actually running. This will reset PB to true after 15 minutes. If not, you could create a second, temporary rule to set PB on this rule back to true. You could also swap the use of PB with a hub variable (not a local variable) if you want an easier way to view or change this in the future, though as long as the rule runs through each time, it shouldn't be needed.

Ah, Gotcha! Yeah the screenshot was about an hour after "initialize", so I think I got it stuck in the false state! These rule sets are mildly infuriating :rofl: Thanks so much for the help, really appreciate it!

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