Sorry team I’m a little confused on how to achieve this.
I have 3 (well even 4 and up to 8) switches with multiple gangs each.
Each of them has one gang that should switch on and off a light (light.1).
Let’s say that switch.gang is the name
I need to have 1.3 - 2.2 - 3.1 that all switch on/off light.1
My expectation is that if press 1.3 then 2.2 andf 3.1 get pressed too and light.1 is turned on
If I press 2.2 and the light is on… then light.1 is turned off and 1.3 and 2.2 are off too
I’m not sure what you mean. Multiple switches can operate the same light. The state of the light will be shown in HA. But the switches have no state in Home assistant, so they do not change when another switch is operated.
If you want each switch to toggle the light, then each change of the button should call the service light.toggle:
As for the light itself and keeping the toggles in sync, I assume 0.01 is physically connected to the light. So if you switch that from HA the light should react. Other switches should have an automation to toggle that entity in HA to make the light react, and the automation should sync the states of all switches in HA to reflect the proper state. Don’t know what that will do to the led.
Wait: I was thinking way too complicated. Just adjusted the code above. All switches must mimic each other, and if is not a problem to switch the same switch again. As all switches always go to the same state, the risk of this endlessly looping is gone. But keep it in single mode though so it won’t run too often by triggering itself again. Just tested and it works. Also adjusted it a little bit so it works on anything you can turn on and off.
I tried making light_switches.yaml then calling it from the configuration.yaml but it is saying “Integration error: light_switches - Integration ‘light_switches’ not found”.
Any tips appreciated, first time messing around with yaml and your solution is exactly what I need for my multiple switches toggling a single light.
It is an automation. If you create a new auto ation in the automation editor, switch to yaml mode in the menu on the top right menu, you can replace the contents with this. You should of course replace the entity id’s with your own.
A light that is already on should not do anything when already on, and thus not cause a loop. If it is, it might be the integration changes an attribute and trigger again. If it does, a loop may occur. Try changing it to:
There are greater legends here, but I kindly take the compliment. Thank you.
Edit: note this may fire as many times as there are entities in the trigger. The way it is now, all switches will try to sync the others, until they are all set the same. If only one switch should trigger them all (and not the other way around), you can limit the trigger to just that one switch.
The from says: it must come from either on or off (so do not respond when a light was unavailable and comes back online)
The to says: it is turned either on or off (so do not respond when a light goes unavailable)
{{ trigger.to_state.state }} is what the new state of the light is, so either on or off. I use it as the end of name of the service that is called on each light. So I get turn_on or turn_off as the service. One of the lights is already in that state, but that does not matter.
You can do this with as many lights as you want, they will always stay in sync, no matter what.
Legends … I had tried different techniques but compared to this… they were all amateur and clunky!
Thank you Thank you Thank you… this is true brilliance!