Automation steps

Hello,

I’m new to HA and made an automation. I did it with de ui, but dont know if this will works.
Its about 3 lights that have to turn on at sunrise, off at sunset, and for one of the 2, has to stay on but lower brightness at 23:00.
Is my code correct like this?

alias: Buitenverlichting Aan
description: ""
trigger:
  - platform: sun
    event: sunset
    offset: "-00:10:00"
condition: []
action:
  - service: light.turn_on
    data:
      brightness_pct: 95
    target:
      entity_id: light.buitenlamp_schuur
  - service: light.turn_on
    data:
      brightness_pct: 8
    target:
      entity_id: light.lamp_overkapping
  - service: light.turn_on
    data:
      brightness_pct: 60
    target:
      entity_id: light.contactdoos_buiten_prikkabel_lamp
  - delay:
      hours: 0
      minutes: 15
      seconds: 0
      milliseconds: 0
  - wait_for_trigger:
      - platform: time
        at: "23:00:00"
  - service: light.turn_on
    data:
      brightness_pct: 69
    target:
      device_id: a25beb37d9c1cb1a72acd5258a3a2cf0
  - wait_for_trigger:
      - platform: sun
        event: sunrise
        offset: 0
  - service: light.turn_off
    data: {}
    target:
      device_id:
        - a25beb37d9c1cb1a72acd5258a3a2cf0

The problem of doing this in one automation is that it’s fragile. If you edit that automation, or restart HA, then it’ll never turn lower the brightness, or turn off.

The other problem is that the sun’s elevation is more significant than a time offset. Ten minutes before sunset is a very different level of light on the shortest day than on the longest day.

- alias: Buitenverlichting Aan 1
  description: ""
  trigger:
    - platform: numeric_state
      entity_id: sun.sun
      attribute: elevation
      below: 1
  action:
    - service: light.turn_on
      data:
        brightness_pct: 95
      target:
        entity_id: light.buitenlamp_schuur
    - service: light.turn_on
      data:
        brightness_pct: 8
      target:
        entity_id: light.lamp_overkapping
    - service: light.turn_on
      data:
        brightness_pct: 60
      target:
        entity_id: light.contactdoos_buiten_prikkabel_lamp
- alias: Buitenverlichting Aan 2
  description: ""
  trigger:
    - platform: time
      at: "23:00:00"
  action:
    - service: light.turn_on
      data:
        brightness_pct: 69
      target:
        device_id: a25beb37d9c1cb1a72acd5258a3a2cf0
- alias: Buitenverlichting Aan 3
  description: ""
  trigger:
    - platform: state
      entity_id: sun.sun
      to: 'above_horizon'
  action:
    - service: light.turn_off
      data: {}
      target:
        device_id:
          - a25beb37d9c1cb1a72acd5258a3a2cf0

You can collapse these into one, with three triggers, the trigger id value, and a choose block, but it gains you nothing.

okay but so as my script is, it will run good or not? I’m sleeping at the most time when this has to be run :slight_smile:

It should unless you get sunset within 15 minutes of 23:00