marco74
(Marco)
October 15, 2020, 10:47am
1
Hi Homeassistanters and esphomers,
anyone knows if is possibile to set a variable value for a delay within a script?
I have a script like the one below, but I would like to have the delay duration coming from a global.
I have tried with
dalay: !lambda "id(duration) + 'min'; "
but it is making my device to randomly reboot…
script
- id: execBoostMode
mode: restart
then:
- switch.turn_on: heaterRelay
- delay: 30 min
- switch.turn_off: heaterRelay
Thanks a lot.
Marco.
1 Like
11180
(Nemanja)
October 18, 2020, 4:35pm
2
Looking for a similar solution, but just i want the MQTT to pass the delay payload to the delay property.
I also haven`t found anything suitable on the docs , i will try with your ‘solution’ and check if i benefit from it
Did you find a solution? I set the delay without unit but it seems not to interpret it.
oxan
(Oxan)
August 9, 2021, 11:02am
4
The delay is templatable, but it expects a timeout in milliseconds.
- delay: !lambda "return id(duration) * 60 * 1000;"
If someone could PR the documentation to add this, that’d be appreciated
birchman
(Mattias Björkman)
August 9, 2021, 2:24pm
5
This is from the documentation on esphome about delay actions. (last two lines).
on_...:
then:
- switch.turn_on: relay_1
- delay: 2s
- switch.turn_off: relay_1
# Templated, waits for 1s (1000ms) only if a reed switch is active
- delay: !lambda "if (id(reed_switch).state) return 1000; else return 0;"
Maybe not explicitly said. But still it there.
/Mattias
PR accepted, and documentation updated. The ESPhome team move fast!
1 Like