Hi all, quite new to HA as I’ve formally been doing most things with Google Home Automation. HA is a breath of fresh air!
I have a lot of automations now working very will in HA. However, I have a very simple automation that turns a light on if a camera detects motion and the sun has not risen.
It should check to see if the light is on first and if so, not run the automation.
However, for reasons I cannot fathom this doesn’t seem to work, even though when I test the condition it detects the light being on fine. I’m sure this must be something daft I’m doing in the code but any pointers would be much appreciated! A similar script in Google with the same devices worked a treat!
YAML code below:
alias: Motion - Turn on Hall Lights
description: ""
triggers:
- trigger: state
entity_id: binary_sensor.hall_motion_alarm
from: "off"
to: "on"
conditions:
- condition: sun
before: sunrise
after: sunset
enabled: true
- condition: light.is_off
target:
device_id: 2d3a0ada37368de5b883ee2613cd54f8
options:
behavior: any
actions:
- alias: Turn on the light
action: light.turn_on
data: {}
target:
device_id: 2d3a0ada37368de5b883ee2613cd54f8
- alias: Wait until there is no motion from device
wait_for_trigger:
trigger: state
entity_id: binary_sensor.hall_motion_alarm
from: "on"
to: "off"
- alias: Wait the number of seconds that has been set
delay: 120
- alias: Turn off the light
action: light.turn_off
data: {}
target:
device_id: 2d3a0ada37368de5b883ee2613cd54f8
mode: restart
max_exceeded: silent
Thanks in advance.