Perform action on sunrise/sunset, BUT no earlier/later than

Hi community!
I would like to have some more advanced automation for my roller shutters.

I already did something like this:
Open shutter1 on sunrise
Open shutter1 half an hour before sunrise
Open shutter1 on 7:00

But thats not really satisfying.

I want to open the shutters at around 7:00 in the morning. But when sunrise is later, I want to open them on sunrise.

Is there any way to get something like “Open shutter on sunrise, but not earlier than 7:00”?

Thank you!

At 7am if the sun is already up the shutters will open. Otherwise this waits until sunrise after 7:

trigger:
  - platfrom: sun
    event: sunrise
    id: 'sun'
  - platfrom: time
    at: '07:00:00'
    id: 'time'
action:
  - choose:
      - conditions:
          - "{{ trigger.id == 'sun'}}"
          - condition: time
            after: '07:00:00'
        sequence:
          - service: cover.open_cover
            target:
              entity_id: cover.your_shutter
      - conditions:
          - "{{ trigger.id == 'time'}}"
          - condition: sun
            after: 'sunrise'
        sequence:
          - service: cover.open_cover
            target:
              entity_id: cover.your_shutter
4 Likes

Thanks a lot for your idea tom_l!

It looks a little different for me, but this could be the way to go

trigger:
  - platform: sun
    event: sunrise
    id: sun
  - platform: time
    at: '07:00:00'
    id: time
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: sun
          - condition: time
            after: '07:00:00'
        sequence:
          - device_id: fd408e1ca45f9f6ac9f461e5d44c9efe
            domain: cover
            entity_id: cover.shelly25_k2
            type: set_position
            position: 100
      - conditions:
          - condition: trigger
            id: time
          - condition: sun
            after: sunrise
        sequence:
          - device_id: fd408e1ca45f9f6ac9f461e5d44c9efe
            domain: cover
            entity_id: cover.shelly25_k2
            type: set_position
            position: 100
mode: single

1 Like

Using the cover.set_position service that works with entity_ids instead of the device action may save you some grief latter.

1 Like

I will have a look into the differences, thank you!

Your yaml worked great over the last days.

1 Like

This one worked for me also. Thank you for your solution.

Just one little remark.

you typed “platfrom” where it should be platform.

Just a little info for the rest of us who also need this.

Hello, sorry I’m new on HA, can you guide me where to add this code? Thank you