The rule below works EXCEPT that there is a delay of up to 5 minutes (the time interval of the repeat) after the door is closed before the last notification at the end of the rule is sent that the door is closed.
Iām using Repeat While Expression. Is there another form of Repeat, or some other way, that would exit the repeat immediately, thereby eliminating the notification delay?
The notification that is delayed is enclosed in yellow below.
Maybe adding a "Wait for event: contact closed" as the (almost) last action inside your repeat, followed by your "door was closed" notification? That would be an easy modification within your existing rule.
A bit cleaner would probably be to trigger on "changed" and use an IF THEN/ELSE structure in the rule, plus something like Private Boolean (or a variable you make) to track whether the "door open" notification actually occurred (in the IF THEN, which could look about like most of your rule now--or you could move the repeat cancellation logic to the ELSE, too) and send the "door closed" notification if so (in the ELSE if the variable is in the right state, then reset it).
No, the wait will never be satisfied as long as the event doesn't happen, and the repeat will happily keep on going (either way, technically, though the resulting condition if the event happens would eventually stop things).
Iāve modified my rule, but there is still that 5 minute delay (the time interval of the repeat), before the message that the doors is closed.
Iām trying to get the message to be sent immediately when the door is closed and not have to wait for the 5 minute repeat to finish.
If you move up your Ā« Wait for event Ā» and the following Ā« Notify Ā» by one line, the problem will be fixed. (The Ā« END-REP Ā» should be on the last line.)
It should be noted that the new rule you shared, beyond the different order of actions, is further different from my suggestion above. I don't see any way your repeat gets stopped now. All I was thinking was adding the wait and notify inside your existing repeat. This issue that remains even with fixing the order of actions. (This being the first suggestion; the second would require substantially different actions and a different trigger.)
As for the question of setting a maximum number of repeats, yes, the "Repeat n times" option on the rule is the easiest way to do that.
I accidentally posted the old rule. Following your advice and the example of Sebastien, I corrected the rule and it works great now! I apologize for the confusion.