Hello, I try to automate switch toogling with this code below, but it toogle only once. Can you help, or tell me what can be wrong with this automation code?
- alias: looper
initial_state: false
trigger:
platform: state
entity_id: automation.looper
from: 'off'
to: 'on'
action:
repeat:
while:
- condition: template
value_template: '{{ repeat.index <= 2 }}'
sequence:
- service: switch.toggle
data_template:
entity_id: switch.mqtt_switch_5
- delay: '00:00:2'