Do not run a rule if it's run already in the last 30 minutes for example

Looking for suggestions for a Rule that would ignore a trigger for a rule, if that Rule has run in the last 30 minutes for example.

I'm running a hot water recirculation pump for 7 minutes if triggered by a motion sensor. But I do not want to trigger it again when it's running or even within 30 minutes of having it run.

Thank you.

There are lots of ways you could approach this, but perhaps the simplest is using a required expression. If you aren't using the rule's Private Boolean feature for anything else, you could leverage that here. As an example:

Required expression: Private boolean true

Trigger events: Motion active or whatever you have?

Actions to run:

Set Private Boolean false
// Run pump, etc.
Wait for event: elapsed time --> 0:30:00
Set Private Boolean true

Basically, you set Private Boolean false as soon as the rule actions start. That will make your required expression false, which prevents the rule from triggering. Your actions will continue running and doing whatever you want, and 30 minutes later, you'll reset Private Boolean to true so the required expression will again become true and your rule is eligible to be re-triggered.

6 Likes

Thank you - took me a bit to figure the exact syntax. But I think I got it.

No, you do not need Private Boolean as a trigger. It should be a required expression only (cut off in your screenshot, but it should display above your trigger events box), besides being set in your actions as you have it now.

I noticed, it would turn ON but never OFF.

I made the changes, is that OK?

Essentially I want the pump to run 6 minutes, but not rerun within 30 minutes.

Big thank you.

Almost! I would:

  1. Change the required expression of "Private Boolean is false" to "Private Boolean is true." You want to not trigger when Private Boolean is false (so you'll need a required expression that will be false when that is the case), at least as you have your rule written now. The other option is to switch the "Set Private Boolean" actions around in your rule, but I'd suggest this instead because it's fewer clicks and a better example of how you'd probably write such rules in the first place given that Private Boolean defaults to true.

  2. Change your actions so that it turns the pump on and then off. Right now, it's doing effectively nothing when triggered, then turning the pump on 6 minutes later. Sounds like you maybe want that to be "Off" instead, then insert an "On" right before that?

Also: as of that screenshot, you're in a pickle since Private Boolean false right now (and the required expression I suggested will be too), likely because a previous execution was interrupted. Hitting "Done" or "Update Rule" could have done that. You can change this by navigating to the Select Actions to Run page, tapping the false cell in the "Private Boolean" row to change it to true; or by just doing Run Rule Actions now if it's not a problem that it actually runs (or you want to test it without a real trigger).

Gee this is not an easy thing to understand... Sorry to bother but I do appreciate your help.

Is this more like it?

No, now you are missing the actions in your rule to change Private Boolean (so your required expression doesn't matter--Private Boolean never gets changed). You had them in there originally, so just add them back and you should be good. Set it false as your first action, then true as your last action after 30 minutes or whatever you are looking for.

How is this ? (Hoping it's getting better...)

Close, but there is nothing in your rule actions that will turn the switch off now. Also, it will wait 6 minutes before turning it on. I'm assuming that's not what you want?

Rule actions are essentially an ordered script that will do the actions you specify in the order you specify (aside from delays and things that might make it work differently). I might suggest reading: Rule 5.1 | Hubitat Documentation

Correct I only wish to run it for 6 minutes, then turn off. How's this then ?

If I take the 6 minutes out, where do I say to the pump only run 6 minutes ?

Is your pump on when the switch is on, or is that reversed? I suspect you want that delay on the "Off" instead of the "On." (But if not, that should work.)

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