I have an idea on a better approach to motion lights for our house, but I’m stuck in figuring out how to implement it. As usual, I’m sure there’s 20 different ways to do this, so I welcome your ideas and opinions… even if your opinion is that my idea is stupid!!
So, here’s what I’m thinking.
Typical Motion Lights automation - turns on with motion and turns off when no motion. This part is done and works fine.
Second automation to abort the first, when someone wants the lights to stay on. Would be triggered by ANY change to the lights and would stop the first automation, thus leaving the lights on.
Just in case it’s not clear, if the lights are turned on by motion, I want them to turn off again by motion. UNLESS, someone alters the light. For instance, alexa is asked to increase the brightness. Or maybe a button is pressed.
Our dog often triggers the lights, which isn’t a big problem, just want them to turn back off without waiting too long. On the other hand, if you sit down and start doing something (without a lot of movement) it’s frustrating when the lights turn off on you.
Hope this makes sense. The trigger for step 2 is what I’m stuck on. How to I trigger an automation ONLY if another automation is running? Or perhaps there’s a better way.
If I am understanding correctly, just:
trigger on motion detection
turn light on
then add a “wait for trigger” with triggers for both motion going off, and a trigger for the light changing state (that is, someone meddling it).
Then, a choose block that chooses based on the trigger id, if it was triggered by the motion trigger, turn off the light, otherwise end the automation.
That’s a great approach, and much cleaner. Now I need to figure out the criteria for the trigger so I don’t miss things. If anyone has something that’s somewhat all inclusive, I’d love to see how you did it. Otherwise I’ll start with what I know how and tweak as I learn more.
I know the status of the light switch in my office
if the light switch is OFF office motion will take over its a condition in the automation
but if i walk in and manualy turn on motion automation does nothing. therefore I have to manually turn it off
- id: "motion in office : light on "
alias: "motion in office : light on "
initial_state: true
trigger:
- platform: state
entity_id: binary_sensor.office_motion
to: "on"
condition:
condition: and
conditions:
- condition: state
entity_id: sensor.office_switch
state: "OFF"
action:
# Action to turn ON
- data:
entity_id: light.office
service: light.turn_on
You can use an input_boolean turned on & off by the motion automation and use that to determine if the automation will turn off the light.
so, basically:
motion automation first turns on the light then also turns on the boolean
then checks to see if the boolean is still on before it turns the light back off then also turn off the boolean
if you change the lights (however you determine that) then use that change to turn off the boolean so the motion automation gets cancelled due to the boolean condition not being met.
In short, this automation turns on lights when motion is detected in a dark room and turns them off again when the motion stops. UNLESS, someone changes the brightness of the light, in which case it stays on a while longer.
After I test this for the next day or two, I’ll post any modifications I make. Thanks again!!