Motion and contact sensor rules

I have a motion sensor and door sensor in a room. I currently have motion sensor turn on the light right away and then turn off after 1 minute. However, I want to add a variable where if the dooor is open then the light always stays on.

how do i do that?

Are you using Rule Machine? If so, it's fairly straightforward:

Triggers:
Motion Active

Actions:
Turn on Light
Wait for Expression - Contact sensor closed and motion inactive with a duration of 1 minute
Turn off Light

Basically, your rule would turn on the light and then wait until the Expression is true. If the sensor is open, the rule will wait until both it is closed and the motion sensor goes inactive. After that will start a one minute countdown until turning off the light.

If you rule is not based off Motion Inactive, but just a time elapsed of one minute, then your actions would look like:

Actions:
Light on
Wait for Event - Elapsed time of 1 minute
Wait for Expression - Contact closed
Turn off Light

2 Likes

This is it!! thank you so much...
I didnt know about the Wait for Expression variable.

Got it working so the light turns on as i enter the room with motion sensor and turns off 1 minute after i leave. However, if the door is remained open the light will not turn off.

FYI you should check out room lighting, IMO for simple cases like this much easier to setup than RM.

1 Like

Will this not turn the light off after waiting one minute? Regardless of the door being open.

The way I understand it is that you should put an IF statement after the wait. If door is closed and motion inactive. (But I could be wrong)

I think you should make the duration of the wait longer (in case someone forgets the door open), or remove the duration, if you want to wait until the expression is true.

I have it setup that the light will stay on if the door is open, and if the door is closed AND there is no movement for 1 minute it will turn the light off

I use the door open for instances where I need the light to stay on regardless of movement as with motion sensors sometimes it will turn off if I stay still. Also, if I forget to close the door I see that the light is still on and it acts as a reminder to close the door

1 Like

No. It will only turn off the light after the expression is true and waiting for one minute. If @munchies put in a timeout instead of duration, this would be the case. Either the expression becomes true (door closed/motion inactive) or the timeout is reached and then the light is turned off.

Thanks! Yes, it was a brainfart on my side :slight_smile: