Question on Hubitat YouTube Video Tutorial Rule Example: Bathroom Lights

I'm starting to look at examples of simple automations and came across the YouTube video titled "A smarter way to automate bathroom lights" and liked the idea of using a contact sensor + motion sensor to instantaneously turn lights ON/OFF.

My question is around "Wait for event: Basement bathroom motion inactive". If I implemented this rule in the powder room and take the scenario where I walk in there to quickly wash my hands, leave, and CLOSE the door behind me, wouldn't this rule leave the lights on since by the time it gets to the IF...ELSE-IF statement (motion inactive), the door would be closed? I'm sure I'm just understanding this rule incorrectly, but it seems to me that this only works if the person never closes the door behind them as they leave.

In your case, yes; you may want to leave the contact sensor out of this automation if that's not a meaningful piece of information for you. Instead of the wait and if/else, a common pattern does something like "Wait for event: motion inactive --> duration 0:05:00" and then turns the lights off, among other options.

You may also want to look into an app like Room Lighting or even Basic Rule that can create this automation for you with less room for misconfiguration like a rule leaves open.

(Editing to add that this is all to say: if you're suspecting this rule was written for cases where the door is normally left open, you are correct.)

3 Likes

Ah I was hoping there was a way to do this without an mmWave sensor or a wait time and still have that "instant off". Is that possible?

Questions along this line often come up when people are wanting to determine presence within a room, considering common patterns of use including the opening and closing of doors and motion detection. Your example of leaving the door open while you are in the room and then leaving is a perfect example where the same sequences of events are not always a reliable method for driving automations, as habits and patterns of behaviour can change.

Contact Sensors are definitely useful when turning lights on as someone walks into a room, opening the door first. But this can be equally be problematic if the door could already open, the use of the contact sensor in this scenario is just a nice, quick, ideal situation, but would not be the only trigger, needing some other motion or similar trigger option alongside the contact sensor.

1 Like

You can eliminate the duration above and make it turn the lights off as soon as motion reports inactive. However, that will still be subject to whatever internal delay your PIR sensor has, sometimes seconds but sometimes minutes, sometimes configurable. However, I think that would get annoying during regular use of the room.

I personally wouldn't worry about this too much; if I want it instant for some reason, I can still use the switch, otherwise the tiny amount of electricity saved by a few minutes' usage will not be noticed, and it's still better than the alternative of accidently leaving the lights on indefinitely. But if you want to chase this path and you have predictable door behavior, I suppose you could do something with contact changed, but that seems tricky to get right in every case.

2 Likes

This is true for me... While I have delays following motion being inactive in various rooms, if I'm exiting the room and I know I'm not intending to go back in, and I am passing a switch that I can use to switch the lights off, I will often manually turn the lights off.

You guys are right. I was overcomplicating it. Not everything needs to be automated. The ON is good enough. I should just view the OFF as a "safeguard from leaving it indefinitely on".

2 Likes

Probably a simple solution but how would one accomplish this kind of automation?

Light ON by motion active.
IF door is not closed in the next 10 seconds after light was turned on, wait for the motion to become inactive to turn off the light.
IF door WAS closed in next 10 seconds after turning on the light, wait for the next time the door opens to turn off the light.

This sounds (to me) like a good solution how to 'fake' a presence sensor in the bathroom. It won't turn off the light if you're sitting still for a long time, but it will also turn off the light when you've left as well. Only option i can see this not working would be with multiple people in the bathroom...

One way could be the following:

Trigger
Motion Active

Actions
Light on
Wait for Expression: Motion inactive and Door sensor open with a duration of 10 seconds
Lights off

It's not exactly what you are asking for, but basically does the same thing. It will turn on the light with motion. The rule will then wait for both the motion sensor to be in active and the door sensor to be open. The duration means that both conditions will need to be true for 10 seconds. Afterwards, it will turn off the light.

1 Like

thanks, but i don't think that would work. if i go out and close the door, there won't ever be a condition where motion is inactive and the door is open.

True, but this is also a same issue with your initial request. If there needs to be an accommodation for that possible state (door closed with motion inactive and have the light turn off), you'll need to rethink the entire rule. With that said, there is a fairly easy way that could cover this:

Trigger:
Motion Active

Actions:
Light On
Wait for Event - Elapsed time of 10 seconds
Wait for Expression - Motion inactive and Door sensor open with a timeout of 15 minutes
Light Off

It's similar to the initial one. Motion triggers the light on. The rule waits 10 seconds. From there, to progress to lights off you would need one of two things to happen: (1) both the motion sensor to go inactive and the door to open or (2) 15 minutes to pass. Once one of those two things happen, the lights will turn off. This will allow you to still get the lights off if no one is in the bathroom (motion inactive) and the door is closed (contact closed).

If motion becomes active again, it will takeout the waits and start the rule again. This will help with "long time" in the bathroom scenario. Basically, the timeout will not happen if someone moves in the bathroom within the 15 minute countdown.

1 Like