I want to implement a priority mechanism similar to BACnet priorities. I have a few reasons to want to do this. The biggest of them is to get better orchestration between things like automations and temporary overrides. The way a priority array works is that:
- Instead of having one state, each entity has an array of states
- When querying the current state, for each property of that state, you find the highest entry in the priority array that is not null
When you issue commands, you can optionally define a priority. Usually if you don’t specify a priority a middle priority is used (like 8). Automations could write to a lower priority than, for example, a manual override. Higher priorities could be use for things like messages from security systems.
In addition to these commands, there would also be a new ‘reqlinquish’ command. The function of this is basically to null out a given priority level, causing the entity to revert to the next highest priority level that is defined.
The point of all of this is to improve the interactions for entities like outdoor lights that have some default behaviors by automation (e.g. turn on at dusk) but for which I might want to manually override, then release that override some time in the future. The underlying automation would continue to run, so when I reverted my manual override, it would revert back to whatever state the automation put it into. Imagine this scenario: automation turns my fish tank light off at 8pm, but I have guests over so I manually override it back on at 9pm. When I remove the override, what should happen? It could just turn off, but that might be wrong. It could try to remember the state it was in before the manual override and revert to that but, again, that could be wrong because it’s now 9am and an automation tried to turn the light on at 8am. I don’t want that automation to ‘win’ … I want my manual override to be treated as a higher priority command until I relinquish it, but I still want to keep track of the ‘automation’ state.
Another scenario is security overrides. I have a motion detector that turns on the outside lights, then turns them back off 10 minutes after motion stops. But what should they really do after 10 minutes? They should revert back to whatever they were doing before, be that a lower level manual override or an automation.
I’m not sure if anybody else thinks this is a good idea. I posted a question about this back in 2022 that got 500+ views but no replies. I’m willing to go implement this myself but I’d like to get some idea that a PR would be accepted, and I need some guidance on how exactly to do this without having to touch every entity that implements, for example, LightEntity. I feel like the place to implement this is LightEntity and SwitchEntity but I’m not sure.