Still missing the priority system, but if using webhooks this could possibly be outsourced to something external.
Note if we don’t require the priorities we can use a queued script with scenes for a generalized approach that works for lights and other platforms.
Actually you cannot prioritise using conditions.
Using conditions you get the downsides I explicitly mentioned:
All automations need to be aware of all others to do prioritization
There are race conditions since your condition and action are not atomic
There’s a good example on race conditions here: Race condition - Wikipedia and what you’re proposing (using conditions) maps perfectly to the bugs mentioned in the article.
I agree ! Home assistant needs things like this to keep pace as automations become ever more complex and intertwined. Consider the current model - a state change or similar triggers an automation, The automation checks various conditions and exits or performs an appropriate action. This is a very linear approach and as pointed out, makes it difficult to react to and deal with multiple / parallel actions. Some kind of list / queue helper would be a good start. I think a lot of these issues can actually be resolved within the existing framework by add some new helper types or extending existing ones. In relation to this I have made a number of feature requests, which have sadly all been ignored.
How about timers that can be actually useful for measuring durations and sequencing events ?
A mutex helper so automations can obtain a lock on critical resources
Want to make an automation react based on the mean value of a sensor ? Sorry we can’t do that. You can look at a pretty chart though.
And if we want to move to a more holistic view, it is going to be a lot easier if we can combine various sensors in more flexible way. Exactly what I proposed here Make the Combine Sensors helper be super useful
Sorry for going a bit off topic, but the one thing all these requests have in common is that they start to move away from the simplistic trigger/condition/action model which is starting to look a bit obsolete. The same way we moved from controlling individual lights to lighting groups, we need to stop considering all things in isolation and add in these kinds of things which allow a more joined up view.
I found this addon that tries to add background state and priorities to at least lighting. It looks promising, and is a lot easier to wrap my head around coming from theatrical lighting compared to trying to actively push the correct state every time anything changes.
I was mistaken about timers, my apologies, but regarding the other FRs, I don’t believe there is currently a way to replicate all the requested functionality. Regardless of this, I believe the point is still valid, the current design seems still too focused on individual devices/scripts and maybe ought to be rethought.
Or, you could re-think the way you automate. Nearly everything should be state driven. If you have one entity who’s state drives multiple automations, consider combining them into one automation.
If you have one entity who’s state drives multiple automations, consider combining them into one automation.
Imagine I have an entity who tells you whether someone is home, many things will relate to this, alarm, heating, lighting. Obviously maintaining all of that in a single automation would be maintenance hell.
Automations should be small and specific, similar to how you’d prefer to write software code they should obey the Single Responsibility Principle.
I am thinking of using a local todo list as ‘the queue’ to store items. Each item contains a ‘unit of work’ (turn on light, wait 1 sec, etc).
HA already has services to:
add an item to the list
delete an item from the list
I am missing service calls for:
“sort the to do list according to some value (due date, priority) and give me the first item”
“get me the first item off the list + delete that item from the list”
If I have the missing services I can implement all kind of queues like:
first in first out (FIFO)
last in first out (LIFO)
And because the queue is a todo list I can display the list in a dashboard.
Here is a use case in which I need a queue.
I have a home thermostat entity which sometimes is unavailable (for hours). In scripts/automations I change the thermostat value. The error handling in case the thermostat is not available is cumbersome. How do I remember what needs to be done while the thermostat is unavailable?
My idea is to store all thermostat state changes in a queue. The queue runner has the option to execute all state changes or decide to take only the last one.
Of course I can create a queued script to change the thermostat value. I am not sure of the limits.
How many script executions can be queued?
And I cannot “see” how many scripts are queued.
What happens when Home Assistant is restarted and there are queued scripts?
Using a “todo list” as a queue as the advantages:
I can see the todo list / queue of outstanding wok to be done
a todo list survies a restart
number of items in a to do list is greater then the maximum number of queued scripts
hahaha, I agree. In this case it is a Nefit thermostat with a cloud component.
The cloud component is out of my reach, so I want to queue up all the commands until the thermostat becomes available again (compensating for the fact that Nefit has an uptime of less than 100%).
And there are other use cases where queues are handy. Home Assistant already caters for the specific ‘light state’ use case by creating a scene on the fly. But there are other entities for which you may want to queue up commands (eg an entity object wich sends out notifications and you want to merge messages to reduce the number of messages sent within a certain time period)
Well the issue is I can’t think of a storage solution for queues without resorting to coding. I want to code as little as possible. That’s why I am thinking of using a to do list as a queue.
Do you have a suggestion for storage?