I’ve been searching all through the forums and haven’t been able to find the code that would assist me on doing the following:
Starting my pool pump 3 hours after sunrise for 30 min and then again 6 hours after sunrise for 30 min. Taking into account redundancy. In short I just don’t know how to use sunrise/sunset in a value template like you would time or a float value. Here is what I have currently that does the job if there’s no interruptions.
- alias: Run Pool Pump 3 & 6 Hours After Sunrise for 30 Min
trigger:
- platform: sun
event: sunrise
offset: '+03:00:00'
- platform: sun
event: sunrise
offset: '+06:00:00'
action:
- service: switch.turn_on
entity_id: switch.pool_pump
- delay: 00:30:00
- service: switch.turn_off
entity_id: switch.pool_pump
It does work, it’s just the redundancy I can’t work out. So for example if the power goes off, or even if I restart HA at say 6H 23M after sunrise, the automation will never trigger again until the following day at 3H after sunrise.
- alias: Run Pool Pump 3 & 6 Hours After Sunrise
trigger:
- platform: sun
event: sunrise
offset: '+03:00:00'
- platform: sun
event: sunrise
offset: '+06:00:00'
action:
- service: switch.turn_on
entity_id: switch.pool_pump
- alias: Turn off Pool Pump after 30 Min
trigger:
- platform: sun
event: sunrise
offset: '+03:30:00'
- platform: sun
event: sunrise
offset: '+06:30:00'
action:
- service: switch.turn_off
entity_id: switch.pool_pump