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.
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
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
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.
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
@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.
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.
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.
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.