I frequently find myself wanting to run a service at a specific time, yet only once (e.g. turn on the lights at 3am today, because someone is coming back late, start the vacuum at 2pm today, etc…).
The current solutions are all pretty cumbersome:
Create an automation, and remember to delete it
Set up a timer and an automation
Setup a calendar based automation
Would be great to simply have the ability to call a service at a future time.
The steps for scheduling an action to occur at a specific time would be identical to creating an automation that does the same thing.
Although an automation can’t delete itself (there’s no deletion action) it can disable itself.
If you’re interested, the same WTH was posted 2 years ago and I provided blueprints for “One Shot” automations (perform a scheduled action and then disables itself).
It may also be possible to create a custom intent for the Conversation agent so you can say “Turn on something at time”.
I disagree. Even if we discount the need to delete the automation (which I don’t think we should), there are still additional steps, as well as additional mental load, from things such as naming, choosing from many possible triggers, conditions, actions, as well as the need to disable to ensure the automation doesn’t run twice. A simple service call with a time delay or specific time is way simpler than that.
I think this would go hand-in-hand with having that ability in service calls.
In theory, we could do this now by using repeat in combination with a list of service calls and passing them to a script that just runs them at a designated time.
I’ve played around with using a text input card and datetime Helper to save an intent in the body of a calendar event. Then an automation is triggered by the event and passes the message to Assist to process. I haven’t used it much, but the few times I did, it worked fine.
If the driving force for this idea is convenience (i.e. minimize the “mental load” of selecting options in a UI), for executing simple “one-time” tasks, then it seems like it would be most convenient if one could simply type, or speak, the command such as “Turn off kitchen light at 8:00 PM” or “Start vacuum at 2:00 PM”. In other words, it sounds like a task for the Conversation agent.
Then the mental load will be replaced by the mental load of figuring out whether the conversation agent got it right, not to mention that it will be extremely hard to pass in multiple parameters.
As I mentioned earlier - “[conversation agent support] would go hand-in-hand with having that ability in service calls.”
Yes, there are many ways to achieve this, the question is how friendly do we want this to be. I think that scheduling actions is a pretty basic requirement from a home automation system, so it makes sense for there to be a really friendly way to do it.
It can be designed to echo back the command, like Alexa does when you, for example, tell it to set a 5 minute timer.
not to mention that it will be extremely hard to pass in multiple parameters.
It appears that you’re suggesting it will need to be more sophisticated than merely turning something on/off at a specific time. In other words, its ultimate functionality will approach what automations can already do (duplicating an existing feature).
Regarding “additional mental load”, the average user will have created at least one automation (conceivably far more) so they are already familiar with the process and can simply leverage their existing expertise. What’s missing is a “delete automation” action.
FWIW, I doubt the development team will approve a proposal to create what is effectively a stunted automation.
“It’s like an automation, with a similar UI, but to reduce mental load it has no name or conditions and fewer choices of triggers and actions and deletes itself after running.”
That’s not what I’m suggesting at all. It could be as simple as a service call (think of the UI for calling scripts from dashboards), but with a way to control timing.
I mean the pop-up for a script. There are various ways to get to it (e.g. clicking on “Information” in the context menu for a script, clicking on a script entity in a card, etc…)
What about something like this? It’s a script with fields defined for action, duration,and time. It requires one or more actions using an action selector, then it has optional selectors for both time and duration. Duration works like a timer (ie, perform the actions in 20 minutes). If both time and duration are provided, then it waits until time, then continues to wait for the duration given. If neither are provided, it would immediately run the action(s) (might be good for testing).
Note: I’m just doodling here while waiting for my partner to wrap the last of her presents. I haven’t used this in production or tested it beyond the most basic of checks.
alias: Timed actions
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{timer_field is defined and time_field is defined}}"
alias: "Wait until a specific time, then delay for a given duration"
sequence:
- wait_for_trigger:
- trigger: time
at: "{{ time_field }}"
- delay: "{{ timer_field }}"
- repeat:
for_each: "{{ action_field }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: >-
{{ repeat.item.target is defined and
repeat.item.data is defined }}
sequence:
- target: "{{ repeat.item.target }}"
data: "{{ repeat.item.data }}"
action: "{{ repeat.item.action }}"
- conditions:
- condition: template
value_template: "{{ repeat.item.target is defined }}"
sequence:
- target: "{{ repeat.item.target }}"
action: "{{ repeat.item.action }}"
- conditions:
- condition: template
value_template: "{{ repeat.item.data is defined }}"
sequence:
- data: "{{ repeat.item.data }}"
action: "{{ repeat.item.action }}"
default:
- action: "{{ repeat.item.action }}"
- conditions:
- condition: template
value_template: "{{ timer_field is defined }}"
alias: "Wait for a given duration"
sequence:
- delay: "{{ timer_field }}"
- repeat:
for_each: "{{ action_field }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: >-
{{ repeat.item.target is defined and
repeat.item.data is defined }}
sequence:
- target: "{{ repeat.item.target }}"
data: "{{ repeat.item.data }}"
action: "{{ repeat.item.action }}"
- conditions:
- condition: template
value_template: "{{ repeat.item.target is defined }}"
sequence:
- target: "{{ repeat.item.target }}"
action: "{{ repeat.item.action }}"
- conditions:
- condition: template
value_template: "{{ repeat.item.data is defined }}"
sequence:
- data: "{{ repeat.item.data }}"
action: "{{ repeat.item.action }}"
default:
- action: "{{ repeat.item.action }}"
- conditions:
- condition: template
value_template: "{{ time_field is defined }}"
alias: "Wait until a specific time"
sequence:
- wait_for_trigger:
- trigger: time
at: "{{ time_field }}"
- repeat:
for_each: "{{ action_field }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: >-
{{ repeat.item.target is defined and
repeat.item.data is defined }}
sequence:
- target: "{{ repeat.item.target }}"
data: "{{ repeat.item.data }}"
action: "{{ repeat.item.action }}"
- conditions:
- condition: template
value_template: "{{ repeat.item.target is defined }}"
sequence:
- target: "{{ repeat.item.target }}"
action: "{{ repeat.item.action }}"
- conditions:
- condition: template
value_template: "{{ repeat.item.data is defined }}"
sequence:
- data: "{{ repeat.item.data }}"
action: "{{ repeat.item.action }}"
default:
- action: "{{ repeat.item.action }}"
default:
- repeat:
for_each: "{{ action_field }}"
sequence:
- choose:
- conditions:
- condition: template
value_template: >-
{{ repeat.item.target is defined and repeat.item.data is
defined }}
sequence:
- target: "{{ repeat.item.target }}"
data: "{{ repeat.item.data }}"
action: "{{ repeat.item.action }}"
- conditions:
- condition: template
value_template: "{{ repeat.item.target is defined }}"
sequence:
- target: "{{ repeat.item.target }}"
action: "{{ repeat.item.action }}"
- conditions:
- condition: template
value_template: "{{ repeat.item.data is defined }}"
sequence:
- data: "{{ repeat.item.data }}"
action: "{{ repeat.item.action }}"
default:
- action: "{{ repeat.item.action }}"
alias: >-
Wait for a specific time, a duration, both (waits for time, then adds
duration), or neither(immediately run actions).
fields:
action_field:
selector:
action: {}
name: Action
required: true
timer_field:
selector:
duration: {}
name: Timer
time_field:
selector:
time: {}
name: Time
description: ""
A datetime helper has a date and a time. You can make an input for it on your dashboard. If you set that, and you make an automation once, that uses the datetime helper as it’s trigger, and a configurable action, you’re more or less there, no?
This is what I do to temporarily override my heating schedule. I use a custom card for a datetime picker.
If you’re scripts have fields it will let you select values for them, and look somewhat similar to the relevant section in developer tools. Give it a try, it’s really cool.
I haven’t actually tried it out as far as I remember, but why would it not survive a restart? The automation is saved, and the input helper won’t change value. I can see how it would not work if the scheduled time is during a restart, or during downtime of the system. But other than that I think it should work, no? Or am I missing something?