tom_l shared a great example how to automate light based on a motion sensor. I’m sharing another version that supports human override. This automation behaves like this:
When motion sensor is triggered off -> on, turn on the light only if it’s off.
If the light is already on, it’ll stay on regardless of whether motion is sensed or not.
Wait for the motion sensor to change back to off for more than 1 minute, and then turn off the light
If the light is manually turned off while the motion is still going on, the automation stops immediately.
##========== Auto backyard light ==========##
- id: auto_backyard_light
alias: "Auto backyard light"
trigger:
- platform: state
entity_id: binary_sensor.backyard_motion # CHANGE THIS
from: "off"
to: "on"
condition:
condition: and
conditions:
- condition: state
entity_id: light.backyard_light # CHANGE THIS
state: "off"
# Add any other condition you would like, e.g., is_day_time
action:
- service: light.turn_on
target:
entity_id: light.backyard_light # CHANGE THIS
# Wait for the motion to stop for 1 minute
# or the light is manually turned off
- alias: "wait"
wait_for_trigger:
- platform: state
entity_id: light.backyard_light # CHANGE THIS
from: "on"
to: "off"
- platform: state
entity_id: binary_sensor.backyard_motion # CHANGE THIS
from: "on"
to: "off"
for:
seconds: 10
# Stop execution if the light is turned off manually
- condition: template
value_template: "{{ wait.trigger.idx == '1' }}"
- service: light.turn_off
target:
entity_id: light.backyard_light # CHANGE THIS
Hi, is this the complete config or do I need to add extra?
I have the above copied into YAMAL (with my own updated entities) but light doesnt turn on upon motion.
Thanks
Yes it’s the complete automation. You may need to trim the condition section to add/remove more conditions for this automation to run/not run. Also don’t forget to change the entity ids.
If the light is manually turned off while the motion is still going on, the automation stops immediately.
Do you a way to make that condition like
If the light is manually changed (brightness, scene, turned off), the automation stops.
I have a list that is switched on with minimum brightness on motion. Often, that is enough. Sometimes, I require more brightness and use the wall switch to change. This also means, I do not want it to be switched off anymore.