I noticed that there was some push back against using a delay in an automation. And after hearing the reason that it can break the automation (restart and other events when HA will startup again)
I kinda agree and started tinkering with set_datetime templates.
Now i created an automation for boosting the living room for a hour (in this test its still 20 seconds)
It seems to work and i can spam the button without it breaking. But more experienced eyes might spy a glaring error or small adjustment for better stability.
If you could have a look:
alias: Booster Woonkamer
description: ''
trigger:
- platform: state
entity_id: input_boolean.woonkamer_booster_toogle
id: Woonkamer_Boost_On
to: 'on'
- platform: state
entity_id: input_boolean.woonkamer_booster_toogle
to: 'off'
id: Woonkamer_Boost_Off
- platform: time
at: input_datetime.woonkamer_booster_time
id: Delay_Boost_Reached
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: Woonkamer_Boost_On
sequence:
- service: scene.create
data:
scene_id: woonkamer_setpoint
snapshot_entities: climate.woonkamer
- service: climate.set_temperature
data:
temperature: 21
target:
entity_id: climate.woonkamer
- service: input_datetime.set_datetime
data:
time: >-
{{ (now().strftime('%s') | int + 20) |
timestamp_custom('%H:%M:%S', False)}}
target:
entity_id: input_datetime.woonkamer_booster_time
- conditions:
- condition: trigger
id: Woonkamer_Boost_Off
sequence:
- service: scene.turn_on
target:
entity_id: scene.woonkamer_setpoint
data: {}
- conditions:
- condition: time
after: input_datetime.woonkamer_booster_time
- condition: state
entity_id: automation.booster_woonkamer
state: 'on'
sequence:
- service: scene.turn_on
target:
entity_id: scene.woonkamer_setpoint
data: {}
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.woonkamer_booster_toogle
default: []
mode: restart