Is there a way to do this with the automations editor yet? I’m just doing a first time setup with home assistant, and was going to try keep all my automations in the automations editor.
I have a bunch of motion sensors around the house. I can use them to turn lights on, but can’t figure out how to set the delay to switch them back off.
Can I use the state attributes? I see one called “no motion since” listed which has a value in seconds.
automation kitchen_light_movement_off:
alias: Turn off kitchen lights when there is no movement
trigger:
platform: state
entity_id: binary_sensor.Family_Room_Motion
to: 'off'
for:
minutes: 10
action:
- service: light.turn_off
entity_id: light.kitchen_light
Yeah, I can do it that way, but was looking to keep it all in the automations editor. Would be good if there was the ability to reference the attributes, or to add that for: time command
I know I’m a bit late to this party, but thought I should share in case someone else has a similar use-case…I have zigbee light switches controlling the outside lights and SR501 PIR sensors to detect movement outside (via ESP8266 ESPHome). I wanted the exterior lights to act as security lights normally except if I turn on the lights manually, as then I don’t want any motion detection automation switching them off. My solution based on the great contributions in this thread using 2 automations are as follows. The off automation is normally in a disabled state.
- id: '1618811753220'
alias: Turn on gym patio lights on motion detection
description: ''
trigger:
- platform: state
entity_id: binary_sensor.gym_patio_motion
from: 'off'
to: 'on'
condition:
- condition: or
conditions:
- condition: sun
before: sunrise
- condition: sun
after: sunset
- condition: state
entity_id: light.gym_patio_lights
state: 'off'
action:
- service: automation.turn_on
target:
entity_id: automation.turn_off_gym_patio_lights_on_motion_detection_ended
- service: light.turn_on
target:
entity_id: light.gym_patio_lights
mode: single
- id: '1618989416766'
alias: Turn off gym patio lights on motion detection ended
description: ''
trigger:
- platform: state
entity_id: binary_sensor.gym_patio_motion
to: 'off'
for: 00:01:00
condition:
- condition: state
entity_id: light.gym_patio_lights
state: 'on'
action:
- service: light.turn_off
target:
entity_id: light.gym_patio_lights
- service: automation.turn_off
target:
entity_id: automation.turn_off_gym_patio_lights_on_motion_detection_ended
mode: single
Happy for feedback / comments to improve etc.
Key features:
I can use the lights as normal exterior lights. When I turn them on, they stay on and the motion detection/security light feature becomes disabled
If I’m not using them as general party lighting, they automatically become securty lights, lighting up if there’s motion in their vicinity.
If you’re interested, the two automations can be consolidated into one.
It requires that you create input_boolean.gym_patio_lights to serve as an indicator (to keep track of who turned on the light, namely you or the automation).
So, when I am testing, I change the sun elevation value (above or below the horizon) dependent on day/night time.
Regarding the input_boolean, how exactly do you configure it? I created the helper, assigned a name, and used it in the automation (so it’s related to the automation), but how does it change status when the lights get turned on by the switch or from another source? How can you relate it?
I see that. Like I see that the automation got triggered. It just doesn’t meet the conditions but the conditions exist.
Regarding the input_boolean, the whole use of it is not to take actions in case the value is in a state that is not triggered by the automation. Like I turned the lights manually, and I don’t want the automation to interfere. But how does the status of that specific input_boolean change when I manually turn on the lights?