Replies: 2 comments 10 replies
Use case, night light:I have two concerns in a night light scenario: a dimmed down light that's on to help kids sleep or people navigate. In one instance, the light has to be at a low level if it's on. It must only turn on at this level, or be off. We could do this by at night time setting a high priority state that says "brightness: 2%", but not turn it on ( The inverse of this is my ceiling lights in the bedroom must not turn on at night. I've done this by mistake a few times and its never popular. So specifically for this room, at night, that light must be off at a high priority. |
|
I must be missing something, how is this not just a scene? I've done similar things with my ecobee where I wanted to implement a "pause" while windows are open. You basically just set an input_text to the existing ecobee state, pause the ecobee, then when resolved you set the ecobee state to be the stored input_text. A similar concept could work for states here. |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I've been struggling for a while with an issue I've been trying to solve for my outdoor lights. I want many things of them to make them as helpful as possible, without immense amounts of logic to achieve it.
The issue
For example, I want:
I've achieved this using an automation that triggers on all the possible changes, and then using a large
choose:to filter down through the most likely to least likely options until finally arriving at a fallback (off). This works great for single lights or sets of lights that are all the same, but the moment I introduce things like overrides or wanting to turn off some lights at night because they're in the yard, it becomes very complex.Second issue
Another example is I have LEDs internally on my wall switches which show state, like "lights are on". If I click these buttons, the lights turn off and the LED also turns off, reflecting that lights have indeed been turned off. Great for shutting down at night.
Now, I have many LEDs, showing various things around the house. I also want these LEDs to be less bright at night, so they themselves don't light up the rooms too much. I've solved this now with a central brightness helper (a number), and then an automation for each LED button I have, that controls that individual light. At present, I have 15 of these automations that are mostly similar, and they all reference this central brightness helper (and trigger on it).
I originally wanted brightness controlled outside these automations, as to not litter them with this concept, but I couldn't do it cleanly. I ended on this design as the least of many worries. But if I in the future want to add, say, security blinking lights, I then need to go back to all these automations and add a trigger and a
choose:condition for "security triggered", which enables blinking. And if I add a new LED, I need to ensure its automation(s) have the same logic as the others.Layered states
I've arrived at "layered states", and also found this post on HA forums referencing "BACnet" which I had no idea what was. That post dives into the "security alert" situation where a lot of entities have to be overridden for a short while, ignoring whatever automations they might have, but still allowing to go "back" to the original state once the security incident is over.
In my layered states thinking, I could simplify my previous issues down to a series of layers, which control aspects of the entities. Each layer is accumulated to arrive at a final state. For example, a light might have on/off, brightness and color as parts of its state. The layers could then say:
{ state: On, brightness: 10% }{ brightness: 40% }{ color: red }If we accumulate this, in order, we arrive at
{ state: On, brightness: 40%, color: red }. But if we then remove the layer setting brightness to 40%, we arrive at{ state: On, brightness: 10%, color: red }, letting us revert back to a "previous" state - its not lost.If we take the example with the outdoor lights, my layers could be, in order of lowest priority to highest:
nullfor this layerlight.turn_oncall from me, the user - anything set here overrides the restThis thinking really shows its value when I want a layer to apply to many entities, and another layer to only a few. Then I can centrally define my indoor LEDs as having a brightness that follows the day/night cycle, but their colors are controlled by more specific automations. And finally, I can centrally have some overarching override that makes them all blink red.
A possible solution?
One way I've arrived at, inspired by Christopher Piggott, was that a service call could embed a priority value, making whatever it sets be applied to that priority:
These calls set up a series of layers for the
light.turn_onservice, with the final state arriving at all lights blinking bright red, but once thatpriority 2(the "security" incident) has been cleared, we're back at a low brightness blue color on some of the lights, while other lights ideally turn off.I have some troubles reconciling the final state from the actions nature. By nature, an action (a service call) is a mutation of the state of an entity, and not a state in itself we can simply "apply". For example,
light.turn_onandlight.turn_offare mutually exclusive, so we can't simply store all turn_ons in a big list and aggregate them. We also have some service-specific things like color, color_name etc, which are also mutually exclusive.So I hope this could work in the service call level, as its a very natural way to express intent, and that this issue could be resolved. :)
Resources:
All reactions