Lightswitch autoamtion help needed

Good afternoon everyone…
I am trying to code automation’s for my outside lighting.
I want sunrise - a few minutes to turn on some switch and after plus 2 hrs back off and in the same automation suntset + a couple minutes another turn on plus 2hrs and than back off again to have light in the morning and in the evening but not over night. i found a couple options but wasnt successful yet besides this embarrassing version of my own which does not survive a reboot or such:

alias: Switch_GroupDeko
description: ""
trigger:
  - platform: sun
    event: sunset
    offset: "-1800"
    enabled: true
  - platform: time
    at: "04:55:00"
    enabled: true
condition: []
action:
  - service: switch.turn_on
    data: {}
    target:
      device_id:
        - edda35775e586ba22174f8777093ec9c
        - c8adb5686f4197a9179d0b27968d1278
        - 72b20e587a08ded091b61d55dad1fc54
  - wait_for_trigger:
      - platform: time
        at: "07:00:00"
      - platform: time
        at: "22:00:00"
  - service: switch.turn_off
    target:
      device_id:
        - edda35775e586ba22174f8777093ec9c
        - c8adb5686f4197a9179d0b27968d1278
        - 72b20e587a08ded091b61d55dad1fc54
    data: {}
mode: single

I tried a couple blueprints but it seems that 2 switch times in one automation, especially with sunset/rise or position noone did so far.
Hope for ideas…thx alot in advance

i wouldn’t approach it quite like you have. several issues w/ it. but i’d do this

description: ""
mode: single
trigger:
  - platform: sun
    event: sunrise
    offset: "-00:15:00"
    id: before_sunrise
  - platform: sun
    event: sunrise
    offset: "1:45:00"
    id: after_sunrise
  - platform: sun
    event: sunset
    offset: "-00:15:00"
    id: before_sunset
  - platform: sun
    event: sunset
    offset: "1:45:00"
    id: after_sunset
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - before_sunrise
              - before_sunset
        sequence:
          - service: light.turn_on
            target:
              entity_id:
                - light.bay_n
                - light.bike_light_lt
      - conditions:
          - condition: trigger
            id:
              - after_sunrise
              - after_sunset
        sequence:
          - service: light.turn_off
            target:
              entity_id:
                - light.bay_n
                - light.bike_light_lt

by the way, you should avoid using device_id’s. read this to understand why:

i’m surprised the blueprints don’t let you do mutliple lights. are you usre? which one? but if you want to use a blueprint and for some reason it doesn’t allow multiple lights, you could make a single light group and use that in the blueprint.

description: ""
mode: single
trigger:
  - platform: sun
    event: sunrise
    offset: "-00:15:00"
    id: 'on'
  - platform: sun
    event: sunrise
    offset: "1:45:00"
    id: 'off'
  - platform: sun
    event: sunset
    offset: "-00:15:00"
    id: 'on'
  - platform: sun
    event: sunset
    offset: "1:45:00"
    id: 'off'
condition: []
action:
  - service: switch.turn_{{ trigger.id }}
    target:
      device_id:
        - edda35775e586ba22174f8777093ec9c
        - c8adb5686f4197a9179d0b27968d1278
        - 72b20e587a08ded091b61d55dad1fc54

ah, nice! interesting i didn’t realize you could use the same trigger id! that’s awesome to know. thanks!

Hello and thx for the answers…
But i get this from the last suggestion when i try to run it:

Blockquote Error: Template rendered invalid service: switch.turn_

What do you mean by this?

Home Assistant: Testing Your Automation

I copied your solution and tried to run it…which it did not do and in “Traces” i get that message which assume is a hint on what is not doing it.
So i was wondering if this solution works in your environment to find out what i need to change to get it working for me as well…cause i like the sleek design

Again, what do you mean? Are you saying you clicked the “Run” button? Doing that skips the triggers, so trigger.id has no value for the automation to use.

Good point…and yes i did the run thing…sorry for being blonde.
Will try and play with the testy automation you send.

Hello again…
I tried and tested and your option is just working like charm
Already switched all my other switch timers to that pattern.
Awesome, thx and this should be a sticky or a wiki entry for best practice!!!

if you like his solution, you should mark his post as the solution to this question. that will “sticky” it as the solution and put it right with your original question.