Often we have wait for condition or wait for times written in automations. However, they don’t persist on HA restarts. Often the solution blueprints and automations have is to create a state machine and a timer. This can be rather complex. A simpler idiom might be to take inspiration from promises and async programming by making the ability to do async scripts/automations.
Essentially there should be a service call to make delayed action temporary automation for one off timed events or as part of an automation in lieu of wait for calls.
The caller would specific a datetime or a duration and then it would run an action. Or a condition and a timeout. Params could be passed that would be evaluated when the async call was made (for templates perhaps?). Then at set time, duration or on the condition the given actions are called.
This script would be temporary and this once evaluated HA wouldn’t worry about the condition anymore.
I think this would be really useful for one off delayed actions or as an alternative to the wait condition. Then we can make those automations truly not bound by restarts and allow one off async tasks to be ran easier.
This is an alternative solution as well to the Todo list delay item option that I we submitted to WTH too.
Yeah essentially. A wait for that persists on reboots. Though to expand it a little a one time automation. Where you can give it triggers and once it’s activated or hits a timeout it isn’t persisted.
So, an automation.create where the last action of the automation calls automation.delete on itself. Or the same with a script. Not a bad idea.
This also opens the door to making scripts or automations from a dashboard. For example, making a dashboard that lets non-admin users make a basic automations.
Script to delay a Todo list item (if that doesn’t get implemented). Script to delay removes items from Todo list and creates a temporary automation to wait X time and then add it to the list again.
Anytime I’m tempted to implement a state machine automation interface, it probably can be implemented simpler with these temp async calls
One off reminders can also be implemented this way
Emergency alerts also would probably work better this way. Instead of triggering every X minutes and checking if there’s a leak or something. It can just trigger on leak and then create a temporary automation that alerts if relevant and calls itself in X minutes again and otherwise deletes self.
Basically any situation that could be done programming with promises or async/await