Light on at sunset/sunrise then off at fixed time

This is a pretty simple blue print for turning on a light at either sunset or sunrise and then turning it off at a fixed time.

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

I’ve also put it on github if you want to manually import it

blueprint:
  name: Sunset / Sunrise Light
  description: Turn a light on at sunset or sunrise and off at a specified time
  domain: automation
  input:
    offset_time:
      name: Offset Time
      description: This sets the offset to the Sunrise / Sunset time
      default: "-00:00:00"
      selector:
        time:

    off_time:
      name: Off Time
      description: This sets the time at which the lights shall be turned off
      default: "23:00:00"
      selector:
        time:

    target_light:
      name: Lights
      description: The lights to control.
      selector:
        target:
          entity:
            domain: light
              
    trigger_selector:
      name: Sunrise / Sunset
      default: sunset
      selector:
        select:
          mode: dropdown 
          options:
            - label: "Sunset"
              value: "sunset"
            - label: "Sunrise"
              value: "sunrise"

trigger:
  - platform: sun
    event: !input trigger_selector
    offset: !input offset_time
    id: "1"
  - platform: time
    at: !input off_time
    id: "2"
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: "1"
        sequence:
          - service: light.turn_on
            data: {}
            target: !input target_light
      - conditions:
          - condition: trigger
            id: "2"
        sequence:
          - service: light.turn_off
            data: {}
            target: !input target_light
mode: single

Thanks I will give it a try. Currently I have manual automations, one for on and one for off.

Thanks, any feedback would be appreciated :slight_smile:

Nice minimal design, not too overloaded.I like that! :slight_smile:
If I want the light to be on prior to sunrise I guess I’ll need to enter “-2:30:00” for example, correct? And can a % brightness be added manual in the .yaml as well? (me ← newby)
Another use case I’d like to have in just one automation would be the option to turn on the light before sundown and turn it off at 23:35 for example but also have it turned for example 2:20h prior to sunrise and turned off at 7:35 Useful for the light at the entrance door or Christmas lights.