Sunrise Sunset automation

Is the “offset: ‘+00:15:00’” referring to 15 minutes after sunrise/sunset?

Thanks for all this info. It, a long with the current automation helper in HA has helped me automate some settings.

I love HA, but wouldn’t an “on at sunset, off at sunrise” process be one of the most used automation out there? Why the “this or that” condition process. It would be much more straightforward to have:
trigger: sunset,
action turn on
trigger: sunrise
action turn off

I know it doesn’t work that way now but maybe it should.

Not real helpful putting in a picture instead of the code to help others out.

2 Likes

For those that want something to copy and paste.

alias: Outdoor lights ON/OFF based on sun
description: ""
trigger:
  - platform: sun
    event: sunrise
    id: sunrise
    offset: "-00:10:00"
  - platform: sun
    event: sunset
    id: sunset
    offset: "+00:18:00"
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: sunset
        sequence:
          - service: light.turn_on
            data:
              kelvin: 5000
              brightness_pct: 100
            target:
              entity_id: light.outdoor_lights
      - conditions:
          - condition: trigger
            id: sunrise
        sequence:
          - service: light.turn_off
            data: {}
            target:
              entity_id: light.outdoor_lights
mode: single

Shorter alternative:

alias: Outdoor lights ON/OFF based on sun
description: ""
trigger:
  - platform: sun
    event: sunrise
    offset: "-00:10:00"
  - platform: sun
    event: sunset
    offset: "+00:18:00"
condition: []
action:
  - service: light.turn_on
    target:
      entity_id: light.outdoor_lights
    data:
      kelvin: 5000
      brightness_pct: "{{ iif(trigger.event == 'sunset', 100, 0) }}"
mode: single
1 Like

I want to do the same thing with one change. I only want the outside lights to be on only when the temperature is below 60 degrees outside and the sun is down. The issue is it may not be 60 until well after sundown depending on the season. How can I combine make that happen?

Include triggers for both sundown and the temperature dropping below your desired value (numeric state trigger) and mirror those triggers in the conditions block.

Sunrise/Sunset condition
Numeric State condition