I have this setup for my toilet closet via two rules: one for contact on the door via Simple Lighting and another rule for situations where the light may be turned in while the door is open. We only close the door when we are in there so primary rule to manage the light turning off is door open and close. But sometimes the light may be turned on while door is open so I wanted to make sure it turns off after 5 minutes.
Pretty simple setup, a Lutron Caseta dimmer for the light, and a dome motion sensor above the door threshold to capture motion as soon as someone walks in, but not capture motion from the hallway.
I don't have any Caseta dimmers but assuming they can act as a scene switch I would use two rules.
First rule modified
Trigger: Motion Active -or- VirtualSwitch On Cancel Delay Actions On Light Wait for condition: VirtualSwith Off Wait for condition: Motion Inactive IF(Door Open) Off Light - delayed 00:00:30 (cancel)
The second rule will control the virtual switch. Button 1 double tap to turn on VirtualSwitch, button 2 double tap to turn it off. I put a one hour timeout just in case someone forgets to turn off the VirtualSwitch.
Trigger: Caseta button 1 doubleTapped On: VirtualSwitch Wait for event: Caseta button 2 doubleTapped --> timeout: 01:00:00 Off: VirtualSwitch
This seems to work for all of my tests ( about 6 cases with different combos of door open/closed, switch/dimmer levels set, motion active/inactive)
I used your logic, but updated it a little for some different times to set levels of brightness, and so that the virtual switch overrides setting the light level.
Trigger: Motion Active -or- Bathroom Virtual Switch On Cancel Delay Actions IF ( Bathroom Virtual Switch is Off) THEN IF (Time Between 2:30 AM PDT and 6:30 AM PDT) THEN Dim: Bathroom Light: 10 --> fade:1 ELSE Dim: Bathroom Light: 40 --> fade:1 END-IF END-IF Wait for condition: Bathroom Virtual Switch is Off Wait for condition: Bathroom Motion Inactive IF (Bathroom Door Open) Off Light - delayed 00:00:30 (cancel)
Glad to see this working for you!
Using the information in this thread I setup two rules.
One rule that turns off the light when the door is opened using simple automation.
The second rule uses motion lighting and is setup to not turn off the lights when the door is closed.
The problem I am running in to is where the light gets turned on by motion and the door gets closed but because no one is in there it then stays on. I am struggling with how to address turning off the light in that scenario.
If the devices are all able to be used in simple automation (i'm not home to check), then just set up another rule with a longer time out than you have set for you auto off if the door is closed. So, something along the lines of
if the light is on and the door is closed for more than said number of minutes and there is no activity, then turn off the lights. The motion should, otherwise keep the light on if there is someone in there.
I'd easily be able to set this up in RM, but the optimal way would be to use simple automation or motion lighting unless there are too many restrictions. Take a look at your options and let me know if you need help with a RM rule. That comes easily for me off the cuff.
That worked. But I am running 3 separate rules and I am thinking my logic could be better.
The goal is turn on with motion.
Don't turn off while door is closed and motion.
Turn off when door is opened.
Extra rule to turn off for the scenario where the light was on and the door was closed and the existing rule will never turn the light off.
Turns off light after 30 mins of inactivity just in case the door gets closed while the light is on and there is no one in there
Turns off light when door is opened
Turns ligts on with motion and prevents them from turning off when door is closed
That's great! Sometimes all you need is a different perspective to be able to stick a toe outside that box and get it done. That's amazing.