Light On/Off based on motion with condition of door closed

I was poking around in the Simple Lighting app, Motion Lighting app and in Rule Machine and not finding what I'm looking for. Here's the logic in basic code speak

if motion is active:
turn on bathroom light
turn on bathroom fan
else:
if
motion stays away from active for 1 minutes:
and:
bathroom door is open
then:
turn off bathroom light
turn off bathroom fan

Simple Lighting canā€™t do it, but Rule Machine can. It would take two rules in Rule Machine, since you have two different sets of conditions. There is also more than one way to do it.

Simple approach:

First rule is a Trigger:
event: motion active
action: turn on light and fan

Second rule is a Rule:
condition1: motion inactive
condition2: door open
rule: cond1 AND cond2
action for true: delay off with cancel, light and fan

First one is simple and obvious. Second one a little less so: If motion stops and the door is open, in one minute it will turn off the light and fan, UNLESS motion starts again or the door closes, in which case it wonā€™t. This little loop continues until there is no motion and door open for 1 minute, then it turns stuff off.

Does that work?

1 Like

Sounds like just the thing I need. Now Iā€™m going to test with the Zooz Mini Sensor that Kevin got working for me. Iā€™m still trying to figure out why that other Zooz ZSE02 motion sensor wonā€™t workā€¦ errā€¦

Tried it out and the ON part works but the OFF part is having an issue. Iā€™ll play more tomorrow. Thereā€™s also another issue (known) because those switches are relayā€™s and if the physical switch is changed then the VS isnā€™t updated accordingly.

I am trying to figure out the following logic in RM

If Motion Changes to Active
Then Turn On Light

If Motion Changes to Active
And
Door is Closed
Then Set some variable to ignore turning the light off

If Door Changes to Open
Then Set some variable to evaluate turning the light off

If Motions Stays Inactive for 1 minutes
And
Variable is set to evalute
Then Turn Off Light

I think I have this set up but I had to use 4 rules. I am sure there is an easier way to set this up?...

Could you explain a little better? So you want motion to turn on/off the light, but if the door is closed, not turn it off, right? But then if the door opens, start turning it off again from motion inactive.

If thatā€™s right, you could do it with Motion Lighting, one Rule, and a virtual switch. The rule turns the virtual switch on/off when the door closes/opens. Motion Lighting rule uses the switch to disable off. In effect, the switch becomes the proxy for the door, and closing the door disables turning the light off irrespective of motion.

In another app for Lutron, the app optionally creates the disable switch, a virtual switch, saving you the trouble. That could be added to Motion Lighting as well. Youā€™d still need the rule to tie the switch to the door.

I will try that out. Iā€™ve had the Hub for a while but just only moved over 4 devices from SmartThings for testing.

I want to avoid just bypassing motion if the door closes because someone can come out of the room and close the door behind them.

I also want the Fan to come on if occupied for a set amount of time and go off after the door is opened after a set amount of time.

My motion sensor has a 30 second retrigger time soā€¦
If motion changes to active and Door is closed, then someone is in the room.
If motion stays active for 1 minute and Door is closedā€¦then someone is in the room.

I want to avoid creating Virtual Switches as much as possible as I have too many devices and the use of variables will be better for me.

This almost works but there are a couple of things that I needed that I have not found to be able to do without multiple rules:

I don't want the fan to come on unless someone has been in the bathroom for x amount of minutes.
Another issue is the light will not go off if the door is closed. Sometimes when people come out of a room, they close the door behind them.

I created a Virtual Switch and made the following rules.

Rule 1-Triggered Rule
If motion becomes active
And
Door is close
Then Turn on Virtual Switch
Someone is definitely in the room

Rule 2-Rule
If motion is active
And
Door is Close
Wait 1 Minute
Then Turn on Virtual Switch (Cancel)
This rule was necessary to make sure someone was actually in the room

Rule 3-Trigger
If Door becomes open
Then Turn Off Virtual Switch
The Virtual Switch is used for Motion Lighting (bypass)

Rule 4-Rule
If Virtual Switch is off
And
Motion is inactive
And
Door is open
Then wait 1 minute (cancel)
Turn Off Fan and Light
Although Motion Lighting will turn off the Lights and Fan, if someone is coming out of the room, then there is no need to wait the total time.

I made the following rule in Motion Lighting for light levels for modes and to turn off if door is closed but no one is in the room:

Seems like a bit much and was hoping that there was an app or options out there that could consolidate this. If not, at least I know now how to accomplish this task...:frowning_face:

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.