This automation turns on the switch at 5:00 and off at 5:15 every other day (i.e. every two days) and is able to handle a restart correctly.
alias: Example 1
trigger:
- platform: time
at:
- '05:00:00'
- '05:15:00'
- platform: homeassistant
event: start
condition: "{{ (now() - as_datetime('19700101T00Z')).days % 2 == 0 }}"
action:
- service: "switch.turn_{{ iif(now().hour == 5 and 0 <= now().minute < 15, 'on', 'off') }}"
target:
entity_id: switch.your_device