From Dusk till Dawn

Hi, anybody got an idea why my code does not work? When I come home I want to turn on the music (works) and if the sun has already set (more precisely, already 2 hours before the official sunset) then also turn on my lights.

I see many potential error sources:

  • Is my offset written correctly? (two hours before sunset = -02:00:00?
  • Can I combine after sunset and before sunrise into one command, or can this only handle one at a time?
  • Can it work to add a condition like this into the actions flow (because I want everything before the condition to always happen, but the lights only when it’s dark)?


 - data: {}
    entity_id: media_player.spotify
    service: media_player.media_play
  - after: sunset
    after_offset: '-02:00:00'
    before: sunrise
    condition: sun
  - data: {}
    entity_id: group.main_lights
    service: homeassistant.turn_on
  - data: {}
    service: script.candy_feed

You can’t span midnight like that with a single Sunrise-Sunset Condition. You have to use two conditions as shown in the documentation.
Sunrise-Sunset Condition