I have been using HA for around for weeks now and I have done some basic automations and scripts which I have linked to Alexa with the Home Assistant skill, along with a subscription to Nabu Casa. These all seem to work fine and I am beginning to get a good basic understanding of YAML but I am far from there yet. One thing I am struggling with is a sunset automation which runs in HA. The idea is that at sunset, the landing, hallway and kitchen lights turn on 30 minutes before sunset. These areas are quite dark, so hence the offset. I want then for the porch lights to turn on at sunset, no offset, but this is not happening as they turn on at the same time as the other lights. I am guessing it is a sequencing issue but I just cannot see it. Rightly or wrongly I have used CoPilot to help. I find this is good way for me to visualise and to begin to understand the coding structure, but using AI has it’s limitations. The code below is what I have and was hoping someone could see where I am going wrong. I suspect it is a sequencing issue but I could be miles off track, so any help is appreciated.
alias: Sunset Automation
description: Porch lights turn on at sunset, other lights at different offsets.
triggers:
- event: sunset
offset: "-00:30:00"
trigger: sun
- event: sunset
offset: "00:00:00"
trigger: sun
actions:
- target:
entity_id: light.kitchen_cupboards
data:
brightness_pct: 100
action: light.turn_on
- target:
entity_id: light.kitchen_plinth_lights
data:
brightness_pct: 60
action: light.turn_on
- target:
area_id:
- hallway
- landing
data:
brightness_pct: 50
action: light.turn_on
- target:
area_id: front_door
data:
brightness_pct: 40
action: light.turn_on
mode: restart