Hi, i have a problem and I don’t know how to solve it:
I have 3 switches (let’s call switch1, 2, 3 to make things simple) connected to the same light and I need to turn all the switches on when I turn on physically switch1 for example. Or when I turn off, always physically, switch1, switch2 and switch3 must turn off.
The same thing when I turn on/off switch2, switch1 and switch3 must turn on/off
Same thing for switch3
There’s any way to do it with home assistant?
The story is: i have 3 smart switch compatible with tuya, 1 downstairs and 2 upstairs ( one in my bedroom the other in the bathroom) the switches are connected witch the light of the stairs. And if I turn on the light in the switch downstairs i can’t turn off the light in the switches upstairs or otherwise.
This is why I thought if I could solve it as I reported above, I hope it can be done
If you assume that turning an on switch on does no harm (similar for off) then it becomes simple with a bit of templating:
trigger:
- platform: state
entity_id:
- switch.one
- switch.two
- switch.three
to: # a null 'to' triggers on any state change but ignores attribute changes
action:
- service: "switch.turn_{{ trigger.to_state.state }}"
target:
entity_id:
- switch.one
- switch.two
- switch.three
- delay: 1
mode: single
max_exceeded: silent
There is a minor issue. When one of the switches changes it now changes the other two switches, triggering the automation again. It wont loop forever, just one extra time, then all the switch states are the same.
I included this to try to prevent this extra triggering of the automation:
- delay: 1
mode: single
max_exceeded: silent
With the short delay the automation takes a second to finish and during that time will skip the subsequent unneeded triggers as it can only run one instance at a time (mode: single). It will also not log warnings about the missed triggers due to the last line, max_exceeded: silent
If your switches take longer than a second to report their state to home assistant you may need to increase the delay time.
Or just leave it out and ignore the extra triggering of the automation.
There’s probably a better way to do this but it may be more complicated.
One further thing to note is that you cant use lists of entities in the UI editor. You must use the YAML view.
hi, I have same problem but my wall switches are recognized as lights. So I dont think I can use the solution that you suggested. Can you help?
i have 4 switches each with 3 buttons. i want one of these buttons on each switch to control the same lamp. I can do this using aumatization, where the trigger is a ‘button on’ and ‘button off’ action for each switch. Each switch has an LED, and when I turn the lamp on the other switch the LED does not light up.
Sure, just use light services instead of switch services. And don’t use Device triggers conditions or actions, they seem easier to understand at first but they will cause you grief in future.
I’m sorry but I don’t get it.
Can you be more specific, or suggest where I can read more?
Obviosuly I read the documentation and some guides but that did not help me.
You can control multiple switches in home assistant. That is usually a case on stairs or hallways where you have two or more switches controling one light.
First go to integrations helpers and create group and put all the entities you want to control in it.
Than create automation something like this
alias: Stairs lights turn on
description: ""
trigger:
- platform: device
type: turned_on
device_id: e4ef8039bce780153fafdc3054f696b5
entity_id: switch.stairs_main_switch
domain: switch
- platform: state
entity_id:
- switch.stairs_switch_2
to: "on"
- platform: state
entity_id:
- switch.stairs_switch_3
to: "on"
condition: []
action:
- service: switch.turn_on
data: {}
target:
entity_id: switch.stairs
mode: restart
And you have to create another automation for turning it off.
I could not get this code to work. After much trying and educating myself I noticed that there was a typo…it should be homeassistant.turn_ instead of home_assistant.
Thank you for your help!