Rule to turn off light "immediately" if no motion

I'd like a Rule that turns off the light "right away" when the door contact is opened and then closed, but there is no motion in the room.

Scenario - a door with a contact sensor and motion sensors in the room. If the door is opened, but there is no motion, when the door is closed the light goes out "immediately". However, if the door is opened and there is motion then the lights turn off 2 minutes after the motion has stopped and the door is closed.

Thanks in advanced!

Here's an option

Trigger:
Door Contact open

Action:
Cancel Delayed Actions
On:  Light
Wait for events:  Door Contact closed
IF (Motion Sensor Active) THEN
    Wait for events:  Motion Sensor inactive
    Off:  Light --> delayed 0:02:00 (cancelable)
ELSE
    Off:  Light
END-IF
4 Likes

Thanks! I’ll give that a try!

That is true. The option I provided won't reset the delay if the motion sensor goes active again within the 2-minute delay.

Oh, bummer.

Wouldn’t adding the motion sensor as a second trigger make this what he’s looking for without any other changes to the rule?
Although, you may need to create a motion zone device and give it a longer timeout depending on what motion sensor you’re using. I could see a scenario where someone is in the room, hasn’t moved for 30 seconds, and someone else opens and shuts the door causing the light to turn off. Of course that’s probably not real common if you don’t have kids or a wife that would find it hysterical :joy:

That seems like it should work. Nice and simple. It sounds like it’s for a garage perhaps. If it is, get a couple more motion sensors and group them in the Zone Motion app using motion aggregation. It will work much better.

1 Like

Here's an updated option for you

Trigger:
Door Contact open
Motion Sensor active

Action:
IF (Door Contact open) THEN
    On:  Light
    Set lBoolean to true
    Wait for events:  Door Contact closed
END-IF
IF (Variable lBoolean = true) THEN
    IF (Motion Sensor active) THEN
        Wait for events:  Motion Sensor inactive
        Wait for event:  --> elapsed time: 0:02:00
    END-IF
    Off:  Light
    Set lBoolean to false
END-IF

Local Variable:
lBoolean false

for me rules with motion and door together seem simplier n event engine..

ie

@anon81541053 @pseudonym Thank you! I really appreciate you taking the time to help me with this. I'll try these options tonight.

@kahn-hubitat I guess I need to spend more time here, I didn't even know Event Engine existed. Looks like a good tool.

This is for the garage and basement lights. In both instances there are times when I open the door, but never enter the room. Having the light go off right away will be great. I got this idea from a webCoRE piston, but it's not working consistently.

Even though I've been in IT for many years, I've always been on the infrastructure side, so righting rules, pistons, etc., is always a challenge for me. The logic just doesn't click for me. I pretty much depend on other people to right them so I can tweak for my needs.

Thanks again!

1 Like

No, if the rule is re-triggered when the door is open it'll meet the condition of the first IF-THEN and wait for the door to be closed before proceeding to the IF-THEN block that contains the logic to turn off the light.

@microlino my replies don't seem to be tagging you.

1 Like

I need to give event engine a try

Yes, that could happen but hard to say if it will happen regularly or just be an edge case.

1 Like

I switched out my garage ML rule with this earlier today and it appears to work perfectly. I am using a motion zone of 5 sensors in place of a single motion sensor.

1 Like

I also replaced “wait for event” with “wait for condition” regarding the motion sensor inactive status because I added a Hue outdoor motion sensor (driveway) to keep the garage lights from turning off if I’m working on something (remodeling) after dark. It seems to be working as expected.

1 Like