From sunset to sunrise

I wanted to make an automation in which the light is turned on by a motion trigger and in the condition the work from sunset to sunrise.
But at 00:00 this condition “broke” because the day has changed and the system is waiting for a new sunset.
I suggest adding the option “sunrise of the next day” or “sunset of the previous day”.
at the moment, I solved the problem like this: 2 time intervals and the “or” condition from sunset to 23:59:59 and from 00:00:00 to sunrise
image

This works as a condition for sunset to sunrise:

condition:
  condition: or
  conditions:
    - condition: sun
      after: sunset
    - condition: sun
      before: sunrise

As does this:

condition:
  - condition: state
    entity_id: sun.sun
    state: below_horizon

According to the developers the following should work but does not:

condition:
  - condition: sun
    after: sunset
    before: sunrise

There is an issue open to fix this particular case.

3 Likes