Wait for event (contact sensor) working in RM 4.x?

@bravenel

Bruce, just tried creating my first rule using the new wait for event, I'm not getting the results I expected, can you confirm I'm using it correctly.

In the following example: at 8pm on Wednesday the rule will trigger 5 minute repeating action with stop option. Then it should wait for the contact to open or until 11pm to stop the repeating action. I'm not finding that the contact sensor going active is stopping the repeat, am I doing something wrong? Logging doesn't show the wait for event or contact sensor state change at all.

I’m going to take a crack at this one but could be totally wrong.

Maybe the end rep needs to be at the end of the entire thing.

It never gets beyond the repeat. It's going to continue running that part of the rule over and over, and not until the repeat stops does it move on. Yours will never stop.

So, aka, put the wait before the repeat (?).

Will that end up causing multiple waits to be scheduled, exactly one every 5 minutes in this case? Or will the new wait supersede the old one? Never tried a repeat with a wait before.
If that doesn't work, you might try putting the contact sensor and the 11pm as a trigger event and then have the conditional action of time & contact sensor closed and have that cancel the repeat. Take the wait completely out of it in this case. Something else to try at least.

What you probably should do is use the "Repeat loop" instead of Wait. At the end of the Repeat actions you add IF Front Door Open Stop Repeating; and you could have two, so also IF Time Between 11:00 PM and 11:00 PM Stop Repeating.

And you would have to add the contact sensor and the time as trigger events as well, correct?

No, why would you do that?

So, the trigger event of 8pm will also trigger the rule to be evaluated if the contact sensor closes or the time is 11pm? Then I must be completely misunderstanding how RM4.0 works. I thought you had to put whatever things you wanted to cause the rule to be evaluated in the triggered events.

image

This was the original rule that we are discussing. You're saying you wouldn't have to modify the triggers at all?

The rule is in a repeat loop, so it would be checking the door status every 5 minutes --> that's what the OP wanted. The between time test should be 11:00 to 11:05 to be sure it catches the actual time the loop comes around.

Oh, you put the other If's within the repeat....I get it.

Mixing Wait and Repeat doesn't really work. Or at least would be confusing.

That's what I thought. I just was putting the new conditional actions you listed in the wrong place in my head. I gotcha now. So, you would do this:

Trigger:  Time 8pm

Action:
     Repeat every 5min + Cancel
          If time is 11pm or contact sensor is closed
                 cancel repeat
          End-IF
          notify mark's phone
     End Repeat

Something like that?

No. Read the docs about Repeat loops: Rule-4.0 - Hubitat Documentation

Okay, how is what I linked incorrect? It looks exactly like this:

image

Some more details than just "read the doc" might be helpful. Other than using cancel instead of stop I can't see any difference.

You had your actions after the test, not before.

BTW, there is a bug that you revealed: A Wait in a Repeat loop should cancel prior waits, and it doesn't. For device event subscriptions it doesn't matter, but for Certain Time it schedules them multiple times.

What difference does it make if the cancel test is before the action or after? If it's after, you still get one notification even if the contact is closed. With my version you do not. Does it not work with the if before the action?

I understand now, I didn't realize that nothing after a loop was executed until the loop ended.

Thanks Bruce and too all that tried to help.

@bravenel

So this should work?

8pm on Wednesday start a repeat every 30 min from 8pm to 10pm (limited by the # of repeats, but subject to cancel). If the front door opens during repeat period (some one took out the trash) stop the repeat?

I put the first condition of 8:00pm to 8:01pm to prevent the door opening before or after the scheduled time from starting/duplicating the repeat?

You first IF-THEN after the Repeat is broken. Delete and redo.