How to get Repeated Notifications using Rule Machine

Hi guys,
I am trying to set up a repeating notification when my garage door reports open and my HSM status is set to Away or Night. I had it inside my HSM but the tilt sensor for some reason every blue moon would report the door being open (even though it wasn't) and the siren would go off. To make this wife-approved I have removed it from HSM and just want to get notification to my phone (repeating) if the alarm is set.

I have the following rule setup. It works to start the repeating notification but doesn't ever seem to exit the repeat even when the status of the garage door changes to closed. Am I missing something? Why does it repeat forever?

(I give myself 2 minutes to get out the door and close the garage door before notifications start)

2021-03-29 15_06_59-Alarm Armed Garage Door Opened

That current truth evaluation looks a little odd to me: I thought RM evaluated OR and AND with equal precedence left to right, so basically T OR F AND F as you have now should be (T or F) AND F, which is false, but your final evaluation says [TRUE]. Perhaps Bruce can comment on that. Regardless, you may want to add parentheses to force what I assume is your desired interpretation: ((IF HSM staus is Armed WAY OR HSM status is Armed Night) AND Garage Door open) THEN. If the display above is correct, then your repeat isn't getting cancelled because the truth evaluation matches the IF THEN, not the ELSE, even though the door is closed.

Also, probably unrelated: I'd suggest re-doing that "Delay 0:02:00" as a "Wait for event: elapsed time --> 0:02:00" instead. This will cancel and restart the countdown if the door gets (closed and) re-opened. You can achieve that with a "Delay" too, but you have to be explicit--mark it as "cancelable" and add a "Cancel Delayed Actions" action--so I think the "Wait..." is easier. That probably isn't the problem here, but it could be a problem in other aspects regardless.

1 Like

Thanks for the suggestions, but I have a very stupid question: How do I add parentheses? Are you telling me there is a way to just edit the code directly (Please say yes).

EDIT: Nevermind, I found what you were talking about. I'll give that a try

Thank you @bertabcd1234 ! The parentheses seems to have solved the problem!

1 Like

Just to help others, for the repeat to cancel based on the IF condition, it must be a SIMPLE CONDITIONAL ACTION

Conditional Action -> Simple Conditional Action

In this case, you don't use an END-IF, just an END-REP.

Here are the logs (order top to bottom). I manually turned off the virtual reminder switch to demonstrate the repeat canceling itself.

10:13:25 infoReminder - Trash: Repeating Actions
10:13:25 infoAction:     Set Volume on Master Bedroom speaker to 100
10:13:26 infoMaster Bedroom speaker volume is 100
10:13:26 infoAction:     Speak on Master Bedroom speaker: 'Don't forget to take the trash out!' --> delayed: 0:00:02
10:13:26 infoAction:     Set Volume on Master Bedroom speaker to 40 --> delayed: 0:00:10
10:13:26 infoAction: END-REP (waiting for next)
10:13:28 infoDelay Over:     Speak on Master Bedroom speaker: 'Don't forget to take the trash out!' --> delayed: 0:00:02
10:13:29 infoMaster Bedroom speaker is playing
10:13:30 infoMaster Bedroom speaker is idle
10:13:36 infoDelay Over:     Set Volume on Master Bedroom speaker to 40 --> delayed: 0:00:10
10:13:36 infoMaster Bedroom speaker volume is 40
10:13:41 infoReminder - Trash was turned off
10:14:26 infoAction: IF (Reminder - Trash(off) is on FALSE) Repeat every 0:01:00 (not repeating)
10:14:26 infoReminder - Trash: Action Repetition ended
10:14:26 infoAction:     Set Volume on Master Bedroom speaker to 100 (skipped)
10:14:26 infoAction:     Speak on Master Bedroom speaker: 'Don't forget to take the trash out!' --> delayed: 0:00:02 (skipped)
10:14:26 infoAction:     Set Volume on Master Bedroom speaker to 40 --> delayed: 0:00:10 (skipped)
10:14:26 infoAction: END-REP
1 Like

Hi all,
Iā€™m pretty new to hubitat and struggling! I used to run smartthings with webcoreā€¦and I had it doing things like this.
Anyways, intended outcome is for the hub to notify me when the garage door is open after dark, and repeat every fifteen minutes until it closes or isnā€™t dark anymore. Iā€™m getting notified, but it wonā€™t stop notifying me when I close it. Thanks in advance!

Right: rule actions run only when triggered, which in your case is the door opening. Then, if the door is open (and it's night), you get stuck inside that repeat, and nothing you have inside the repeat (or elsewhere) will stop that repeat when the door closes.

To solve this problem, you need to use one of the patterns presented in the first post of this thread. I'd look under the "If multiple conditions have to be tested to mean to stop" example, assuming you care about both the door and time. If you don't want the notifications to stop just because it became morning (say, the door was left open overnight), you could consider moving the time to a predicate condition, preventing the rule from triggering when false but not affecting anything else. Then you'd have something like:

Predicate condition: Time is between sunset and sunrise

Trigger: Garage door opens

Actions to run:

IF (Garage door open) Repeat every 0:15:00 
  Notify: "Garage door open!"
END-REP

This is basically the first example above (note that I'm using a simple conditional, which here--attached to the beginning of the repeat--functions as a way to stop the repeat when false). But, again, if you only want notifications throughout the night, I'd take a look at the next section.

2 Likes