I need to create a script to open some switches for 20 minutes… but I can’t find the right way to do it with scripts visual editor, just in YAML mode. So I added a 20 minutes timeout, that works fine…
Is there any way to write the minutes to delay in wait_template field of the scripts visual editor?
If you’re interested, here’s a fairly robust way to turn something on at a specific time and have it automatically turn off some time later.
In this example, the “some time later” is hard-coded to be 20 minutes but could be based on the value of an input_number.
It uses a time-onlyinput_datetime to know when to turn on the switch (or whatever it is you want to do).
It automatically computes the turn off time based on the start time plus 20 minutes.
It is immune to restarts unlike methods that employ delay, wait_template, timer, etc. When Home Assistant restarts, the automation will always set the switch to the correct state.