how to set up timer automation, I want to turn on a switch for 1 hour and then turn it off for half an hour. and then repeat
Create two timers, on_timer (duration: 1 hour) and off_timer (duration: 30 minutes).
Automation can look like this.
alias: timer automation
description: ''
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.on_timer
id: 'off'
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.off_timer
id: 'on'
condition: []
action:
- service: switch.turn_{{ trigger.id }}
target:
entity_id: switch.some_switch
- service: timer.start
data: {}
target:
entity_id: timer.{{ trigger.id }}_timer
mode: single
You’ll have to start the timer the first time or add some other trigger for when it should be started.
You could use any sort for condition to cause it to stop.
1 Like