Assistance with automation backyard lights

Hi there,

Being relatively new on Homeassistant, I’m still discovering the possibilities of this great tool. I’m running it on a RPI4 and I’m using it for home automation and energy monitoring.

One thing i can’t figure out is why the lights outside aren’t working anymore in the morning. I want them to go on at 5:00 and turn off 30 min. before sunrise. The automation used to work. Could anyone have a look at it and help me to the right direction?

Looking at tracing it seems there is a problem at midnight:

Triggered by the sunset with offset at 13 november 2023 om 16:52:47

Service “Licht: Aanzetten” aanroepen op “Buitenverlichting avond/ochtend”

(light.shellydimmer2_3c6105e3b0c6) turned on
(light.buitenverlichting_avond_ochtend) turned on
Show 3 more items

Wachten op 1 trigger
7 uur later

Service “Licht: Uitzetten” aanroepen op “Buitenverlichting avond/ochtend”

(light.buitenlamp_voordeur) turned off
(light.buitenlamp_achtergevel) turned off
Show 3 more items

Confirm the time is after 5:00 testen

Aborted at 14 november 2023 om 00:00:00 (runtime: 25633.07 seconds)
alias: "Buitenverlichting avond/ochtend aan "

alias: "Buitenverlichting avond/ochtend aan "
description: Buitenverlichting avond aan, nacht uit, ochtend aan
trigger:
  - platform: sun
    event: sunset
    offset: "+30"
condition: []
action:
  - service: light.turn_on
    data: {}
    target:
      entity_id: light.buitenverlichting_avond_ochtend
  - wait_for_trigger:
      - platform: time
        at: "00:00:00"
  - service: light.turn_off
    data: {}
    target:
      entity_id: light.buitenverlichting_avond_ochtend
  - condition: time
    after: "05:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
  - condition: sun
    before: sunrise
  - service: light.turn_on
    data: {}
    target:
      entity_id: light.buitenverlichting_avond_ochtend
  - wait_for_trigger:
      - platform: sun
        event: sunrise
        offset: "-30"
  - service: light.turn_off
    data: {}
    target:
      entity_id: light.buitenverlichting_avond_ochtend
mode: single

Thanks in advance

Please repost your automation inside a preformatted text block (look under the gear icon in the editor then look for the </> icon. Automations in yaml depend on spacing being correct and without preformatted text blocks it’s next to impossible to tell if yours are correct.

alias: "Buitenverlichting avond/ochtend aan "
description: Buitenverlichting avond aan, nacht uit, ochtend aan
trigger:
  - platform: sun
    event: sunset
    offset: "+30"
condition: []
action:
  - service: light.turn_on
    data: {}
    target:
      entity_id: light.buitenverlichting_avond_ochtend
  - wait_for_trigger:
      - platform: time
        at: "00:00:00"
  - service: light.turn_off
    data: {}
    target:
      entity_id: light.buitenverlichting_avond_ochtend
  - condition: time
    after: "05:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
  - condition: sun
    before: sunrise
  - service: light.turn_on
    data: {}
    target:
      entity_id: light.buitenverlichting_avond_ochtend
  - wait_for_trigger:
      - platform: sun
        event: sunrise
        offset: "-30"
  - service: light.turn_off
    data: {}
    target:
      entity_id: light.buitenverlichting_avond_ochtend
mode: single

I’m not an automation expert, but reading this I would expect that this automation would turn on the lights, then wait until midnight trigger occurs, then turn off the lights, then immediately check the next 2 conditions. Because it would fail one of those conditions (it’s not after 5:00am) the automation would finish.

When it worked did you have another “wait for trigger” somewhere in there?

Thanks for your reply. It did work and as far as I know I didn’t change anything.

I have added an “wait for 5 hours time out” before the -condition: time after 05:00:00" line. Let’s see how that works :slight_smile:

It works now, thanks :slight_smile:

1 Like