Add script.execute_sync
action or configurable blocking mode for scripts
#3303
Unanswered
AndreiArdelean1
asked this question in
Component enhancements
Replies: 1 comment
-
🏷️ I've automatically added the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Component name
script
Link to component documentation on our website
https://esphome.io/components/script
Describe the enhancement
Currently, calling a script via
script.execute
is asynchronous. To wait until a script finishes, you have to pair it manually withscript.wait
, e.g.:This works but is repetitive and unintuitive for users who want scripts to behave like traditional synchronous functions.
I propose either:
script.execute_sync
that automatically waits until the script finishes:blocking: true
) that makesscript.execute
wait automatically:Use cases
This is useful for sequences where multiple switches or GPIOs must be turned on/off in order with delays between them. For example:
In my particular case, I need to turn a specific relay on for a fixed duration and then turn it off, ensuring it always returns to the off state, and combining them in a bigger script.
Currently, achieving this requires manually pairing
script.execute
withscript.wait
for each step, which is repetitive and prone to mistakes. A built-in blocking mechanism would make these sequential automations much simpler, safer, and more readable.Anything else?
script.execute
andscript.wait
for sequential operations, which is repetitive and error-prone.Beta Was this translation helpful? Give feedback.
All reactions