Hi there, I am new to HA, Im plugging away and getting there, with no programming experience, a great learning curve.
I am trying to automate the turn on some lights before sunset and off again after a delay when we are home. Using Life360 for tracking me and my wife
I cannot get my automation to work, I have read and read about doing this but must be missing something somewhere, can someone assist Please? My Yaml
automation:
- alias: 'Lights on when at home after sunset'
trigger:
- platform: state
entity_id: group.all_devices
- platform: sun
event: sunset
offset: -00:45
condition:
condition: and
conditions:
- condition: sun
after: sunset
- condition: state
entity_id: group.all_devices
state: 'home'
action:
- service: homeassistant.turn_on
entity_id: group.all_lights
- delay: '04:00:00'
- service: switch.turn_off
entity_id: group.all_devices
Thanks for the fast response, WOW, I think I see where I went wrong, sun condition was in triggers and conditions, no neeed to do it twice.
Will see if it works in a couple of hours
Unless you live near the equator, you’ll likely want to use the sun elevation instead. Forty five minutes before sunset is a very different light level on the longest day compared to the shortest day