Wait for event timeout

So the more I read, the more I get lost And the more I try it, the more confused I get. I'm sure I'm overthinking it, but please help. Also, I'm sorry for the basic question.

Wait events. I did a simple test rule.

Trigger: door opens
Turn on light
Wait for event: door closes, timeout 20 seconds
Turn off lights

It turns off the lights whether the wait times out or the door closes. I guess I've crossed over somewhere to thinking that if the wait times out, it wouldn't continue.

If I add a conditional after the wait and say if the door closes, turn off light, else, exit rule, it works. But then I have to add the same (similar) action twice (wait for this event and if this event happens). Is there a way to make this easier?... something more along the lines of, wait for this event until the timeout else do this.

This should help!

Wait for (the lack of) event - RM5? - #2 by bertabcd1234?

1 Like

ive been trying wait events/conditions for a motion notify on my tv. i have my liv room lights to go off after 30m if no motion, then turn tv off. if motion active, it resets the timer and u get another 30m. problem is, watching a movie and not moving for 30m shuts off everything and we have no clue. so i added a notify on the tv to say, 30m is almost up, trigger the motion basically. this works but if we trigger the motion 5 times in 30m, tv notifies 5 times also. so i have been playing around with the wait for events/condition. (wait for 25 minutes to say, trigger the motion or all is off). i havent been successful yet, but i just started playing with it. I will update when i get it right, maybe it will help.

or maybe this, he beat me to the reply...

1 Like

That is basically what you need to do and the example shown in the link is a good one. In your case a simple conditional if door open exit rule after the wait would work as well. No need for a IF then ELSE

Waits only stop if the rule is re-triggered. But the rule starts over and, in your rule, the the wait would start again. Although in your rule that would never happen because the only way to re-trigger would be to first shut the door.

1 Like

Maybe I missed it somewhere, but it doesn't look like you ever stated what you want the rule to actually do. If you don't want it to turn off the light at all until the door is closed, just remove the timeout. If you want to wait for the door to remain closed for 20 seconds rather than instantly, use "duration" instead of "timeout." If you want to do something different (but still something) in each case, @terminal3's suggestion to add an ELSE to my rule linked to above should work. But if all you're doing in the ELSE is an "Exit Rule," that sounds like effectively nothing to me (unless you have more actions after this) and thus the same as the first possibility I mentioned.

So...a few options depending on what you really need. :slight_smile:

2 Likes

Why is this so difficult?

I have a room with a motion sensor and a light - all I want to do is turn on the light when motion is detected and the to turn it off when no motion has been detected for 5 minutes using rule machine 5.1

Using this and it does not wait for no activity on the sensor - it just keeps lighting up and fading.

IF (Time between 16:00 and 20:00(T) [TRUE]) THEN
Set color: Study desk ->Warm White ->Level: 100
Wait for event: Study Motion Sensor inactive --> timeout: 0:05:00
Fade Study desk down to 0 over 1 minute with 5.0 seconds interval
END-IF

Any ideas please?

The triggering event should be motion detected (not time) with a restriction/condition of time.

That is the trigger - I just did not add it to the above - the IF is for different times of the day 16:00-20:00 and then another IF for 05:00-08:00 and the Required Expression is for Illuminance of the sensor.

You want a "wait for conditions", not "wait for event". Use a duration. I'm not a RM expert, so I can't explain what timeout is meant to do. But duration is what you want and is shown in the documentation

https://docs.hubitat.com/index.php?title=Rule-5.0#Wait_for_Events_and_Wait_for_Conditions

1 Like

Here's the explanation of timeout vs. duration

I"m with Bill, I'm definitely not an expert, but with my understanding of RM, in this rule, it will only wait 5 minutes for the motion to become inactive. Basically if the motion becomes inactive it will advance OR if five minutes passes it will also advance (even if the motion is still active).

I would use the "wait for expression" with a duration as mentioned by others. That would wait for the motion to be inactive for the five minutes. If the motion becomes active, it will retrigger and cancel the wait, or start it over once it's become inactive again. I've had a few hang from time to time on a wait for expression, but in theory the rule won't advance until the duration has been met.

2 Likes

Seems like your lights mightā€™ve been shutting off as soon as your motion sensor reporting active switched to inactive. I have a handful of ring motion sensor g2ā€™s directly connected to my C7 and their timeout is around 30 seconds.

I know itā€™s a little late to the party, but I stumbled upon this post trying to figure out the same, and while my question was answered it seems like this post never got a solution.

I think the simplest solution for the case of motion or contact sensors is to use the motion lighting app. It saves you from having to put together all of these conditional actions and streamlines the process.

Motion lighting documentation.

Duration instead of timeout in RM would also achieve similar results as ML.