Does there exist a blueprint that toggles all selected lights to a single on or off state, regardless of what state the light is in?
Let me explain… Currently I have the “light toggle” action assigned to a remote so that I can toggle state of two lights (actually an area that includes two lights). It works as expected when both lights are ON or both are OFF but if one of the lights is turned on then pressing the button toggles both - the light that was off turns on and the one that was on turns off.
I would like to have a “toggle” action that synchronizes the state of lights if they are not in sync. So if at least one of the lights is ON AND not all the lights are ON then either turn ON or turn OFF all.
It feels like there should already exist a blueprint for that but I can’t find one.
Doing this for only two lights is trivially easy without a blueprint. Post the code of your existing automation and someone will modify it for you. (Important: Be sure to mark it up as code or indentation etc. will be all broken.)
Doing it for an arbitrary set of lights in a target selector, well that is slightly more complicated but also very doable.
Light groups do more-or-less what you want.
You can turn all lights on/off whatever the current state
You can toggle all lights off if they are on and vice-versa.
The only corner case is that if some are on, the group will be on, so a toggle will turn them all off, but you have to choose one or the other approach, anyway (mixed status; some are on toggle put them all off or all on)
Thanks, didn’t think of that but honestly that feels redundant if I’m already using an area to “group” my lights. That means that I have to not only manage the area associations but also have to keep in sync a group when adding or removing lights.
Not sure I understand. The action is assigned to a button that is meant to act as a toggle. So I can’t explicitly use turn_off or turn_on unless there is additional logic that checks the current state of the lights (thus me asking if a blueprint for that already exists).
If you change all the lights to a certain defined state no matter what the current state of the light is then it’s not a “toggle”. “toggle” denotes switching the state to the other state no matter the current state.
What you need to do is use the light.turn_on or light.turn_off action.
Semantics… As established earlier, the light group has a notion of toggle and works like that already so I’m not the one to come up with such a concept.
The only problem with using groups is that I have to create and maintain those separately which feels unnecessary if I already have area associations that correspond with the group I want, in my case. More things to maintain, more likely for things to get out of sync.