How to get Repeated Notifications using Rule Machine

To get something to notify repeatedly until some conditions are met, try one of these:

If a single condition is going to become true to mean to stop:

Trigger Event:  whatever starts the notification 
   IF (NOT condition) REPEAT [notification interval]
      Send "notification" TO notification device

That is a While Loop. It going to repeat while the Simple Conditional condition is true, and then it will stop once it's false.

Here is a concrete example of that:

Trigger Event:  Front Door Opens
   IF (Front Door Open) Repeat 00:00:30 
      Notify Bruce "Front Door Open"

Each time around this loop it checks the condition of Front Door Open. If it's open, it notifies. If it's closed, the repetition ends and the rule if finished.

If multiple conditions have to be tested to mean to stop:

Trigger Event:  whatever starts the notification 
   REPEAT [notification interval] Stop
      IF (multiple-conditions) THEN
         Stop Repeating Actions
         Send "notification" TO notification device

In each of these examples, the notification happens immediately. If you want to wait before notifying, your could put a delay on the Send notification (be sure the delay is less than the notification interval used for the repeat). However, such a delay may mean you get one extra notification. So, another way to do this would be to skip the notification the very first time only. To do that, use a local variable. Here is that with my front door example, using an LV called First Notice.

Trigger Event:  Front Door Opens
   Set First Notice to false
   IF (Front Door Open) Repeat 00:00:30 
      IF (First Notice true) Notify Bruce "Front Door Open"
      Set First Notice true

How does this rule look ?

You don't really need Stop of a numbered repeat, unless you plan to stop it from some other rule.


At least this puts my at ease knowing these
Strange repeats from the siren arnt related to this.


Yes I sure at this point, I am running the risk of being thrown completely off this board but I really want to get this right and learn along the way.

None of the examples covers #2 of my UC. I want the repeat to stop when a VS is turned off via Echo voice command.

So, as I continue to try and make things work, I came up with this based on your example above, but it still won't cancel

Everything works fine except when I turn off the Trash Reminder (VS), repeat doesn't stop

Sorry to be redundant...
Use Case:
At a specific day/time each week (I will adjust the trigger once it's working, for now I am using a Virtual Contact Switch)

What I want to happen:

  1. Upon trigger, send notification
  2. Turn on a virtual switch (VS) (Trash Reminder) (can be before send notification as I have no preference)
    3: Repeat notification every x mins until the VS is turned off. (which I will do via Echo voice command)
  3. Once VS is closed, turn off repeating notification


1 Like

If you wanted to use a Wait with a repeat, can you show an example of that for us @bravenel? I am pretty sure that the wait has to go inside the repeat, correct?

There's nothing in your rule to turn it off. It doesn't check your VS. Your rule gets triggered when the VS turns on. But there is no check inside your rule for if the VS gets turned off.

Initial testing shows this version works as expected

I'll know more on Wed this week


1 Like

@bravenel, I had posted this in another thread, but it appears this is the more appropriate thread, and possibly you will be able to give me the best advice.

Long story short... there is an app that will automatically change my mode to "Sabbath" when it is appropriate to do so (Sabbath or Holiday based on the Jewish lunar calendar). In addition, at the conclusion of the Sabbath or Holiday, it will change the mode to "After-Sabbath".

My goal is basically, to start running this rule when the mode becomes "Sabbath" and run it every single day until the mode becomes "After-Sabbath". Typically it will either run anywhere from 1-3 times (never 4).

Currently this rule is "paused" since I'm pretty sure it won't work the way I want it to. In addition, I have a rule called "After-sabbath" that when that mode becomes active, it cancels this rule. I feel like that condition (to cancel the repeating event) is probably better to have within the same rule with the repeating event.

Would love to hear your thoughts! Thanks in advance.

Is this version better?

So reading this has given me a different perspective than I had when I first saw your Rule. Your app creates two modes "Sabbath" and "After-Sabbath". You should use these (particularly Sabbath) as conditions and not as triggers.

Use Sunset as your trigger.

So your rules would look something like this:

Rule 1
When time is Sunset


IF (Mode is Sabbath) THEN
    Dim: Kitchen Lights: 50
    Dim: Living Room etc.

Rule 2
When time is 6:30AM


IF (Mode is Sabbath) THEN
    Dim: Living Room etc
    Wait for events: When time is 11:00AM
    Dim: Kitchen etc.

As I understand it (and pardon my ignorance if I am wrong). Shabbat begins at a specific time and lasts the entire 1, 2, or 3 day period.

By using it as a condition, the actions in the two rules I've listed will only run when the Mode is Sabbath.

1 Like

This actually looks great! Thanks for the idea. @bertabcd1234 had a similar idea. I guess when two great minds say one thing its probably the way to go.

Sincerest thanks to you all!

1 Like

I like your idea. I presume you are Orthodox, and it is very clever to use automation to fulfill your obligations appropriately.

Yes, orthodox. Thankfully timers are an accepted work-around to not using electricity on Sabbath/Holidays.

We've come a long way from the timers we used to plug our lamps into with the pins.

  • One last question to hopefully end my search to perfect these rules. What is the purpose of the "END-IF" statement at the conclusion of your rule? Is that, if the conditions are not met, just end the rule? What happens without the "END-IF"?
1 Like

As your rules become more complex, it is critical to use an END-IF to separate IF blocks. Even more so if they are nested IF blocks.

So it is just good practice to always complete an IF block with an END-IF.

1 Like

Is there a good place to learn about "ELSE-IF" and "ELSE"?

Let's say I make a rule:
Trigger: Sunset
IF (mode is X) then: Turn light on
IF (mode is Y) then: Turn light off
If (mode is Z) then: Alarm house

In this scenario, is END-IF appropriately used, or ELSE-IF should be used? These terms confuse me.

OR should it be:

IF (X) then on
Else-if (y) then off
Else-if (z) then alarm

Actually, it could be either. The logic works out the same.

When you have a sequence of IFs, as in your first case, if the conditions are mutually exclusive, as in your case, then only one of them can be true. ELSE-IF would work the same way for this case, as if the first one is false, maybe the next one is true, etc.

There can be a difference when the conditions are not mutually exclusive, in which case the order in which the conditions are evaluated is important. In that situation, ELSE-IF comes into its own. In this situation, it would be important only to do the second test if the first test failed. Whereas, with your first case, all 3 tests would happen no matter what.

ELSE-IF would in some cases be more efficient -- in those cases where an early test is likely to be true, thus allowing later tests to be skipped. But, in the case where the last test is true, the two forms have the same efficiency -- finding the truth on the last test performed.

Think of ELSE-IF this way: If the first or prior condition is true, we won't even look at the ELSE-IF or ELSE part. But if the first or prior condition is false, then we will try the ELSE-IF test. If and only if all preceding IF and ELSE-IF are false will we do the ELSE part.

ENDIF just marks then end of the IF-THEN sequence. We need that because IF-THENs can be nested -- the actions to run after the IF-THEN is true might include another IF-THEN. So to keep them all straight we use ENDIF. Sort of like right parenthesis matching a left parenthesis. RM uses textual indentation also to help see the nesting and matching of IF-THEN and ENDIF.


Appreciate the thorough response.

Just to clarify one point.

If I use the scenario above with the IF,END-IF 3 times... are you saying that if XYZ are all different variables (day, brightness, temperature) then all three rules would be run if it was Sunday, dark, and over 30 degrees, whereas if ELSE-IF was used only the “X” rule would be run because it was true first, and even though Y and Z were also true they would not be run because X already satisfied the condition.

That is correct.