Last active
July 15, 2025 18:16
-
-
Save itayavra/612bf464c80200b79602f6f3b08dd090 to your computer and use it in GitHub Desktop.
Bidirection switch and light/group sync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| blueprint: | |
| name: Sync Switch or Light with Target (Bi-directional) | |
| description: > | |
| Keeps a switch or light (controller) in sync with another light or switch (target), | |
| which can be a group or a single entity. Toggling either will toggle the other. | |
| Prevents feedback loops using state checks. | |
| domain: automation | |
| input: | |
| controller: | |
| name: Controller | |
| description: A switch or light that toggles the target (e.g. wall switch) | |
| selector: | |
| entity: | |
| domain: | |
| - switch | |
| - light | |
| target: | |
| name: Target | |
| description: A light, switch, or group that should stay in sync with the controller | |
| selector: | |
| entity: | |
| domain: | |
| - switch | |
| - light | |
| trigger: | |
| - platform: state | |
| entity_id: !input controller | |
| to: | |
| - "on" | |
| - "off" | |
| - platform: state | |
| entity_id: !input target | |
| to: | |
| - "on" | |
| - "off" | |
| variables: | |
| controller_entity: !input controller | |
| target_entity: !input target | |
| controller_state: "{{ states(controller_entity) }}" | |
| target_state: "{{ states(target_entity) }}" | |
| mode: queued | |
| action: | |
| - choose: | |
| # Controller changed → mirror to target if states differ | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ trigger.entity_id == controller_entity }}" | |
| - condition: template | |
| value_template: "{{ controller_state != target_state }}" | |
| sequence: | |
| - service: > | |
| {% if controller_state == 'on' %} | |
| homeassistant.turn_on | |
| {% else %} | |
| homeassistant.turn_off | |
| {% endif %} | |
| target: | |
| entity_id: !input target | |
| # Target changed → mirror to controller if states differ | |
| - conditions: | |
| - condition: template | |
| value_template: "{{ trigger.entity_id == target_entity }}" | |
| - condition: template | |
| value_template: "{{ target_state != controller_state }}" | |
| sequence: | |
| - service: > | |
| {% if target_state == 'on' %} | |
| homeassistant.turn_on | |
| {% else %} | |
| homeassistant.turn_off | |
| {% endif %} | |
| target: | |
| entity_id: !input controller |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment