hi i try to do a kind of 2 way switch
have 2 separate light that i want to control at the same time
right now have an automation that wen uptair its toggle the downstair one toggle
but want to have same automation when downstair is toggle to switch upstair one
try to duplicate this script at reverse but do a loop and dont work
any one have an idea
thanks for reading and help or comentary im pretty new in home assisatant
here my action
- action:
- data:
entity_id: switch.sonoff_powe1r
service: switch.toggle
alias: Multi Switch Hall Lights
condition: []
id: ‘0’
trigger:
- entity_id: switch.sonoff_wall
from: ‘on’
platform: state
to: ‘off’
- entity_id: switch.sonoff_wall
from: ‘off’
platform: state
to: ‘on’
here what i want to do but within ha no esp easy https://www.youtube.com/watch?v=xQltSHSVleI
The way I would do this is as a group, so in your groups.yaml file (or config file, depending how your HA is set up) do the following:
hall_lights:
view: no
name: 'Hallway Lights'
entities:
- switch.sonoff_powe1r
- switch.sonoff_wall
What you’ll end up with is a group card with both switches in it, and a master toggle, so any time the master toggle is switched on or off, it’ll trigger both lights. After you’ve created the group, you can put group.hall_lights in your front end and just have a single switch controlling both.
I have the same set up for my bedroom lights:
1 Like
thanks icaman004 for your answer
yes group work well from the gui and or automation to schedule
try more to get the 2 switch working in pair for normal user
now with my first automation if it toggle wall plate both get on
try to get same if i toggle downstair wall plate
Ahh yes, sorry, I completely forgot about the out of HA part…
You should create 2 automations, something like this will work well:
- alias: Hall Lights On
initial_state: 'on'
trigger:
platform: state
entity_id: group.hall_lights
to: 'on'
action:
service: homeassistant.turn_on
entity_id: group.hall_lights
- alias: Hall Lights Off
initial_state: 'on'
trigger:
- platform: state
entity_id: switch.sonoff_powe1r
to: 'off'
- platform: state
entity_id: switch.sonoff_wall
to: 'off'
action:
service: homeassistant.turn_off
entity_id: group.hall_lights
Note that you need to specify both switches in the Off automation, otherwise it won’t work. Due to how HA is programmed, when any device in a group is switched ‘on’, the whole group then shows as switched on, so the on automation is more simple.
EDIT: You can also use the individual switch triggers in the ‘on’ component as the ‘off’ instead of the group.
Hope this works for you!
1 Like
Thanks so much for this. Exactly what I needed