Lights off at sunrise cause problems due to seasonal changes

So, the problem is that as the seasons changes, the sun rises at different times.

I have my outdoor lights automated to turn on at 06:30, and then off again at sunrise. This works well in the winter. But now its summer and the sun rises before my set “turn on time”.

Result: lights turn on at 06:30 and then nothing because the sun already rose before 06:30.

Is there a smart way to automate around this problem?

Use offsets.

Set the turn on at sunset +/- the offset time. For example, if 6:30 is 45 minute after sunset, set the to + 45 minutes.

- event: sunset
    offset: "00:45:00"

I used this all the time because the sunset/sunrise time changes every day, I don’t want my lights or other automation to go on until it is dark, so at sunset at add a offset, also at sunrise, I add one too.

1 Like

Maybe use the Sun @ Sun - Home Assistant (plus offsets as needed) instead of a hard time?

“If sunrise after 6:30, turn on at 6:30, else leave off”

Set the trigger to 6:30
Set the condition that sun.sun is “below_horizon”.

1 Like

Here’s a basic sketch of one way to do it:

triggers:
  - trigger: sun
    event: sunrise
    id: "off"
  - trigger: time
    at: "06:30:00"
    id: "on"
conditions:
  - or:
      - condition: trigger
        id: "off"
      - alias: Check that sunrise hasn't already passed when triggered by "on"
        condition: and
        conditions:
          - condition: trigger
            id: "on"
          - condition: sun
            before: sunrise
actions:
  - action: light.turn_{{ trigger.id }}
    target:
      entity_id: light.example
mode: queued
3 Likes

I am using sun elevation. Using something like this, elevation can be adjusted.

value_template: '{{ state_attr("sun.sun", "elevation") < 4 }}'
2 Likes

Thanks guys! Got a lot of new ideas how I can implement this! Will do some tests over the next few days and see how it goes :slightly_smiling_face:

1 Like