My first and short attempt at YAML not going so well

By starting this topic, you have empirically proven it’s not easier; you misused the Automation Editor in YAML mode and employed outdated automation syntax. Use Visual mode to learn how valid YAML is generated; walk first, then run.

I also recommend you review the documentation’s glossary. You appear to have used terms like script and automation interchangeably but they’re two different concepts in Home Assistant. It makes it more challenging to understand what you did if you use the wrong terminology.

Fair enough

35 devices and counting. I’m now on to automations like this…

alias: Holiday Lights regular lights on at 10:30PM
description: Outside lights on at 10:30PM, and then off again at sunrise.
triggers:
  - trigger: time
    at: "22:30:00"
conditions: []
actions:
  - target:
      entity_id: light.back_wall_light
    data:
      brightness_pct: 6
    action: light.turn_on
  - target:
      entity_id: light.front_wall
    data:
      brightness_pct: 6
    action: light.turn_on
  - target:
      entity_id: light.front_recessed
    data:
      brightness_pct: 3
    action: light.turn_on
  - wait_for_trigger:
      - trigger: sun
        event: sunrise
        offset: 0
  - action: light.turn_off
    metadata: {}
    data: {}
    target:
      device_id:
        - 55d2f116af38775dd0627f28cd70fef8
        - a3558423ffac555caaf4ab45eafc20c7
        - 70e6aa23ab5f6173224b3602cc7715c7
mode: single

Thanks again!!!

The wait_for_trigger waits several hours (for sunrise). That’s not a robust strategy.

If Home Assistant were to restart during that time period, the automation is terminated and so the lights will not be turned off (at sunrise). It’s a best practice to minimize the length of time that an automation spends in its actions phase.

Move the Sun Trigger to the triggers section and then use a choose to decide what actions to perform based on which one of the two triggers fired.

1 Like