Turn lights on at specific time if sunrise is in 30 min or later

HA Wizards,

I’m trying to setup an automation where the Hall’s light switches on at 6:50 am ONLY IF the sunrise is in 30 min or more (sunrise is 7:20 or later).

I tried the following code but didn’t work. what’s the correct way to achieve this? is there a way to compare the current time with sunrise’s time and then run the automation?

automation:
  - alias: 'Turn on light at 6:50am if sunrise is on or after 7:20am'
    trigger:
      platform: time
      at: '06:50:00'
    condition:
      condition: sun
      after: sunrise
      after_offset: '00:30:00'
    action:
      service: light.turn_on
      entity_id: light.hall_lamp

Shouldn’t the condition offset be “before”?

1 Like

Hi, to me it’s not clear what you are trying to accomplish, don’t know about others.

Do you mean 30mins before sunrise, the light should go on?
What about that 7:20?

Turn the light on at a specific time, but only if that time is 30 min or more before sunrise for that day.

turn the lights on at 6:50 if sunrise occurs at 7:20 or later.
For example: if sunrise is at 7:21 or 8:30 or any time after 7:20, then switch on the light.
If sunrise occurs before 7:20, then do not switch on the lights (it’s bright enough outside to need the lights on inside)

I’ll give this a try,
Thank you