Hoping for a little help, I appear to have bitten off more than I can chew.
I have three Sengled lights in the bathroom, a motion detector, and a Sylvania dimmer switch button controller.
Right now, I have the motion controller turning on the lights at a low dim level, then going off after a couple of minutes.
Here's what I'm trying to do: Set it up so that if someone wants to use the shower, they can click the switch and have the lights come on full until they are done. After that, I want to added a door contact sensor so if the door is closed, the lights stay on until it's opened again, then go off after a minute or so.
I've been playing in the motion lights app as well as rule machine, and I'm getting tripped up finding a way to have the switch override, what's effectively, a night light being tripped by the motion sensor.
If anyone could point me in a direction to explore, I would very much appreciate it. I'm new to rules, and have been just keeping it simple until this little project.
I’ve been heading down that same path but don’t have all the pieces in place yet. One bathroom has a motion and contact sensor and the other has a motion sensor and Pico remote. I don’t have all three devices in either as yet.
If the door is open then the motion sensor works as expected. If the door is closed then the light stays on regardless of the state of the motion sensor.
The other bathroom is more complex and uses a global variable.
Currently it is only managing the motion events until I get another contact sensor.
I’m using an Iris v2 sensor so the sensor goes inactive after 30 seconds no motion. I also have a global variable (gBathroomOverride) that is used to delay turning off the light.
When the mode is "bedtime" the global is set to 0, otherwise it is set to 30. This way at night the light is on for only 30 seconds after motion stops. All other times it stays on for 60 seconds.
It works well but you may be wondering why I used a variable as it would be easier to just set the delay in the commands. That’s where the Pico comes in.
If you press the on button it sets the light to 100% and changes the delay to 90 so the light will stay on for two minutes after motion stops. This gives you a longer window to re-trip the light. Likewise if you long press the on button it will set the level to 50% and the delay to 870 for a 15 minute delay (bathtub setting).
If you press the off button it will immediately turn off the light and reset the delay to 0 or 30 depending on mode. Obviously you don’t really need the off button but the switch is mostly there so guests have a familiar UI.
Next step is to add a contact switch so that closing the door overrides the delay like the guest bath. I will also be adding Inovelli switches to the guest bath for a similar functionality and to add the fan control to the logic.
It is still a work in progress but the basics of what you are looking for are there.
Check out the zone motion app. It allows you to aggregate sensors into one meta sensor. But even if you only have one sensor in the room, it allows you to specify a longer motion timeout than 30s.
That might simplify your use of a global to handle this case.
Thanks for the heads up. I do use the zone motion app in other rooms. I use a short duration when the mode is bedtime and a longer duration otherwise.
This use is still a work in progress. My main goal is to automate everything but still let a guest interact in a way they understand without explanation and without disrupting the automation (ie: turn off smart bulb at the switch). It may swing back towards a motion zone control, I’m just letting it evolve while decide how I want it to ultimately work.
I have a contact sensor, and the problem I'm having is overriding the delay and having the contact sensor keep the lights on until the door is open again.
This is what I'm trying next: (Edit: It didn't work.)
First off you are running the rule when motion changes but you are not checking the condition. So when motion is detected it will turn on the lights and when motion stops it will turn on the lights.
Start simple:
Trigger: Motion *changed*
Rule:
IF (motion detected) THEN
Turn on light
ELSE
Turn off light
ENDIF
This will turn the light on with motion and off after the motion sensor times out. Typically this is 30 seconds or 4 minutes after motion has stopped depending on the sensor.
When that is working add the contact sensor to the logic.
IF (motion detected) THEN
Turn on light
ELSE
IF (contact open) THEN
Turn off light
ENDIF
ENDIF
If motion is detected it will turn the light on. This part hasn’t changed. Once the motion has stopped and the sensor times out it will execute the else section.
In this case if the door is open then the light will turn off. If the door is closed then nothing will happen and the light will stay on.
One edge case is if you don’t move and let the motion timeout the light will still be on. If you can somehow manage to open the door and leave without triggering the motion sensor the light will stay on. You would really have to work hard for that to happen.
Leave the rule like that for a while and see how it works out. If you decide the motion times out too quickly When the door is open then you can try adding a delay. I don’t use delays often but off the top of my head I think it would look like this:
IF (motion detected) THEN
Turn on light
CANCEL DELAYED ACTIONS
ELSE
IF (contact open) THEN
Turn off light DELAYED 3:00 CANCELABLE
ENDIF
ENDIF
One other note. If you are explicitly turning a light on and off don’t use toggle. Use the discrete on and off functions. Toggle flips the current state. In your example if the door is closed and the light is on the next time the motion sensor sends a motion activated the toggle will turn off the light.
That's fantastic. I appreciate the input and have been trying it.
The reason I want the door closing to cancel the light going off until it's open again is if someone takes a shower - the motion detector doesn't detect motion behind the shower curtain. I could stick one in the shower but I'm not sure how long what will survive with teenage girl shower temperatures and steam...
That’s exactly the use case I’m using it for. If the door is closed the light should stay on. The second example should work for you. I just suggest setting up the first example and playing with it for a bit to get a hang of how it is working.
Then add the two lines in the second example (IF and ENDIF) and leave it for a few days. That might be all you need. If you decide the lights are going off too often with the door open then add the changes in the third example and adjust the delay to suit.