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
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)