How to setup a Rule so that it has to wait 15 minutes before it can be triggered again?

I created a Rule that when our Side-Yard Gate is opened, it makes an announcement on our Sonos speakers at 40% volume and also sends a Push notification on my phone saying "The Said Yade Gate has been opened". Then after a 10 second delay, it resets the volume back to 25% and announces the reset.

Which works great every time. BUT, when someone is working in the yard and has to open and close the gate five or six times in 15 minutes it drives everyone in the house nuts as well as my phone sounding like a door chime.

I'm wanting to simple add that once the Rule runs, that it can not run again for 15 minutes. No matter how many times the Gate has opened with in that 15 minute time frame.

I know it's probably very simple to do, but I'm not that great at creating rules. Plus I'm having a brain freeze trying to make it work. :cold_face:

Thanks for any help.

An easy way to do this would be with Private Boolean on this rule (though any local or global variable or even virtual or real device state, etc. would work). In your case, just make the actions something like:

IF (Private Boolean is False) Exit Rule
Set Private Boolean False
Speak 'Side yard gate opened'
Notify 'Side yard gate opened'
Speak 'Resetting volume' -> delayed 0:00:10 
Set Private Boolean True -> delayed 0:15:00
3 Likes

Thanks @bertabcd1234

I never created or worked with Private Boolean or local or global variable before. So I know that would be a big challenge for me. lol

@bertabcd1234 helped me enable my first PB rule as well. Once you get the concept down they are pretty easy to use. I have 3-4 in use now. Just don't try to use symbols in the names. Bed things can happen if you do that. I found that out the hard way.

1 Like

not to hard. its just a rule like any other. if you create a new rule for the boolean you just select the rule you want to use the boolean for.

1 Like

Hi @bertabcd1234
I feel silly asking this question, but I 'm really curious about the format of your post.
It's obviously not a screendump of a RM rule.
Do you type it out like this, with all the different colors etc to make it clear to the OP, or do you have some secret way of making your rules?

image

Greetings! I typed out the text vaguely resembling how the rule would display, then used the "code"/preformatted text formatting feature in the forum software to display it like that:

image

(This applies some default syntax highlighting, and I'm not sure what it is..if I looked harder, I'm sure I'd find a way to specify or disable that. But I think it's better specifying the text as preformatted so indentation and otherwhitespace is preserved, which is visually helpful in rules.)

Thank you! That clears a lot.
Sometimes I wish I could write rules like that (RM can take very long, especially if my hub is a bit slow) but this way would be very easy to make errors, so maybe it's a good thing!

@bertabcd1234

I just started messing around last night for the first to see if I could create a Private Boolean like you showed me, but I must be doing something wrong.
Where you have " If (Private Boolean is False) Exit Rule ", I'm not sure where you got that from within Actions, unless this is just a title you gave to the Private Boolean.

(I'm using an extra contact sensor to test with instead of using the Side-Yard Gates contact sensor)

When I open the 'Test - Sensor' everything runs like it's suppose to, I get the speaker announcement, I get the text notification on my phone, and I get the announcement 10 seconds later of the volume being resetting.
But as soon as I open the Test - Sensor again to see if there is now a 15 minute delay, all the Actions start running again. There is no 15 minute delay happening.

Hope you can point out my mistake and help correct me,
Thanks

777

Looks pretty close! There are two parts to finishing the PB thing you asked about (which, to address that question directly, is indeed part of the rule). First is getting a simple conditional. This will get you the following line when you're all done:

IF (Private Boolean is False) Exit Rule

but would be equivalent to this "full" conditional if you preferred to do it that way instead:

IF (Private Boolean is False) THEN
  Exit Rule
END-IF

But since you only need a single condition (is PB false?) and a single action (Exit Rule), the Simple Conditional works just fine, is a couple less clicks, and only takes up one line. Just mentioning this so that you know how to do either way if you need to in the future.

The second part is getting that action as part of the Simple Conditional action, which should be straightforward since it won't let you finish adding the simple conditional without specifying one.

Here are the steps I would take to do the whole thing:

  1. Choose "Insert Action Before", and choose your "Set Private Boolean False" line (this will put the action at the beginning of the rule, where you want it)
  2. For "Select Action Type to Add," choose "Conditional Actions"
  3. For "Select Which Action to Add" (which will appear after the above step), choose "Simple Conditional Action"
  4. Under " Select capability for Action Condition," choose "Private Boolean"
  5. Choose "false" under "Private Boolean is..." (default is "true," so you'll need to change that)
  6. Click "Done with this conditional"
  7. For "Select Action Type for Conditional," choose "Delay or Repeat Actions, Wait"
  8. For "Selection Action Type to Add," choose "Exit Rule"
  9. As usual, keep hitting "Done"-type buttons until you've saved the action and ultimately the whole rule :slight_smile:
1 Like

@bertabcd1234

Thank you for the detail setup, It worked perfect.

I really appreciate the time that you took to show me and help me understand what all was needed to do when creating a Private Boolean, in order to get this Rule working the way I wanted it to.
This is my first Private Boolean, and again I really appreciate you helping me to get over a hurdle that I thought I would never cross in RM. Creating complex rules is never a strong point for me.

Thanks again!

2 Likes

I had a very similar problem I was trying to solve -- thanks for this post! (honestly this seems like a common enough design pattern that I wish there was something more built in to limit how many times a rule could run)

Anyway here is my rule -- I haven't been able to test it yet but I think it'll do what I want. It's for a airscape whole house fan (they have a connected local API)

  1. Trigger if the room temperature get's 'cold enough' or the private boolean changes
  2. If the fan isn't going then don't do anything
  3. if the fan has no timer running then just turn it off (it's cool enough)
  4. If there is no timer then start turning it down every 30 minutes -- eventually it'll be at it's lowest speed where it will run the rest of the night until I manually turn it off)

I'm still playing with the logic a bit -- I may change it to start ramping down the speed regardless of the timer setting but it's nice to be able to have this kind of sophisticated logic.

Side note: One of the brilliant thing in hubitat is custom attributes and commands. With RM you can really do some fancy stuff

Screen Shot 2020-07-09 at 9.36.56 AM

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