What’s wrong with this automation

This automation used to work. Lights go on only they won’t go off.


alias: Buiten - Spots Avond
description: ''
trigger:
  - platform: sun
    event: sunset
    offset: '-00:15:00'
condition:
  - condition: time
    before: '22:00:00'
action:
  - type: turn_on
    device_id: df8f88ebdcf7ad803e2baeff62c2f0e3
    entity_id: light.buiten_spots
    domain: light
    brightness_pct: 35
  - wait_for_trigger:
      - platform: time
        at: '22:00:00'
  - type: turn_off
    device_id: df8f88ebdcf7ad803e2baeff62c2f0e3
    entity_id: light.buiten_spots
    domain: light
mode: single



alias: Buiten - Spots Ochtend
description: ''
trigger:
  - platform: time
    at: '06:30:00'
condition:
  - condition: sun
    before: sunrise
action:
  - type: turn_on
    device_id: df8f88ebdcf7ad803e2baeff62c2f0e3
    entity_id: light.buiten_spots
    domain: light
    brightness_pct: 35
  - wait_for_trigger:
      - platform: sun
        event: sunrise
        offset: '00:15:00'
  - type: turn_off
    device_id: df8f88ebdcf7ad803e2baeff62c2f0e3
    entity_id: light.buiten_spots
    domain: light
mode: single


If you reload the automations, restart HA, or anything causes your automations to be interrupted/restarted/etc then the automations won’t finish. You’re a lot better off splitting those into separate on and off automations, like this:

alias: Buiten - Spots Aan
trigger:
  - platform: sun
    event: sunset
    offset: '-00:15:00'
  - platform: time
    at: '06:30:00'
condition:
  - {{ (trigger.platform == event and now().hour < 22) or (trigger.platform == time and is_state('sun.sun','below_horizon')) }}  
action:
  - type: turn_on
    device_id: df8f88ebdcf7ad803e2baeff62c2f0e3
    entity_id: light.buiten_spots
    domain: light
    brightness_pct: 35
mode: single

alias: Buiten - Spots Uit
trigger:
  - platform: sun
    event: sunrise
    offset: '00:15:00'
  - platform: time
    at: '22:00:00'
action:
  - type: turn_off
    device_id: df8f88ebdcf7ad803e2baeff62c2f0e3
    entity_id: light.buiten_spots
    domain: light
mode: single

I’d generally recommend sun elevation over a fixed time offset, since the light level is very different across the year if you used fixed offsets.

Thnx for the reply, is the condition a tempate?
like this:

condition: template
value_template: >-
  {{ (trigger.platform == event and now().hour < 22) or (trigger.platform ==
  time and is_state('sun.sun','below_horizon')) }}  

Yes it is. That’s a new way of doing template conditions that turned up in the 0.115 release.

Thnx for the help.