Synchronize the on/off state of 2 entities - Single Run Mode

Simple blueprint copied from Adrien Chevrier Synchronize the on/off state of 2 entities to synchronize the state of 2 entities. But this one use the “Single Run Mode”.

blueprint:
  name: Synchronize states
  description: 'Synchronize the on/off state of 2 entities'
  domain: automation
  input:
    entity_1:
      name: First entity
      selector:
        entity:
    entity_2:
      name: Second entity
      selector:
        entity:
mode: single
max_exceeded: silent
variables:
  entity_1: !input 'entity_1'
  entity_2: !input 'entity_2'
trigger:
  - platform: state
    entity_id: !input 'entity_1'
  - platform: state
    entity_id: !input 'entity_2'
condition:
  - condition: template
    value_template: '{{ states(entity_1) != states(entity_2) }}'
action:
  - service: homeassistant.turn_{{ trigger.to_state.state }}
    data:
      entity_id: '{% if trigger.from_state.entity_id == entity_1 %} {{ entity_2 }} {% else %} {{ entity_1 }} {% endif %}'
1 Like

Stop working after upgrade to core-2021.4.6

The blueprint is still working for me with 2022.9.6 but it does cause the repairs feature quite some grief (see below). Came here to see if there was an updated or alternative blueprint to use that wouldn’t generate the warnings.

The automation "Master Bedroom - Synchronize states - Mini" (automation.master_bedroom_synchronize_states_mini) has an action that calls an unknown service: homeassistant.turn_unavailable.

This error prevents the automation from running correctly. Maybe this service is no longer available, or perhaps a typo caused it.

To fix this error, edit the automation and remove the action that calls this service.

Click on SUBMIT below to confirm you have fixed this automation.
1 Like

I just updated mine for this exact reason. I changed it to the following, which I believe should prevent the issue:

blueprint:
  name: Synchronize states
  description: Synchronize the on/off state of 2 entities
  domain: automation
  input:
    entity_1:
      name: First entity
      selector:
        entity: {}
    entity_2:
      name: Second entity
      selector:
        entity: {}
  source_url: https://community.home-assistant.io/t/synchronize-the-on-off-state-of-2-entities-single-run-mode/270813
mode: single
max_exceeded: silent
variables:
  entity_1: !input "entity_1"
  entity_2: !input "entity_2"
trigger:
  - platform: state
    entity_id: !input "entity_1"
  - platform: state
    entity_id: !input "entity_2"
condition:
  - condition: and
    conditions:
      - condition: template
        value_template: "{{ states(entity_1) != states(entity_2) }}"
      - condition: template
        value_template: '{{ trigger.to_state.state != "unavailable" and trigger.to_state.state !=  "unknown" }}'
action:
  - service: homeassistant.turn_{{ trigger.to_state.state }}
    data:
      entity_id:
        "{% if trigger.from_state.entity_id == entity_1 %} {{ entity_2 }} {%
        else %} {{ entity_1 }} {% endif %}"