Hi
Trying to link 3 switches states together.
Having used the script as found on How to link 2 switches together that works great on 2 switches I tried to expand it to 3 switches with mixed results.
It is not working are expected.
- alias: Living Room Light
trigger:
- platform: state
entity_id: switch.sonoff_100064f420_3, switch.sonoff_10007ecf5a_2, light.sonoff_10009951b8_1
from: 'on'
to: 'off'
- platform: state
entity_id: switch.sonoff_100064f420_3, switch.sonoff_10007ecf5a_2, light.sonoff_10009951b8_1
from: 'off'
to: 'on'
action:
service_template: >
{% if trigger.to_state.state == "on" %}
switch.turn_on
{% elif trigger.to_state.state == "off" %}
switch.turn_off
{% endif %}
data_template:
entity_id: >
{% if trigger.from_state.entity_id == "switch.sonoff_100064f420_3" %}
switch.sonoff_10007ecf5a_2, light.sonoff_10009951b8_1
{% elif trigger.from_state.entity_id == "switch.sonoff_10007ecf5a_2" %}
switch.sonoff_100064f420_3, light.sonoff_10009951b8_1
{% elif trigger.from_state.entity_id == "light.sonoff_10009951b8_1" %}
switch.sonoff_10007ecf5a_2, switch.sonoff_100064f420_3
{% endif %}