TRV temperature sync automation broken with 2021.3

Hi guys, I have an automation in place that syncs TRVs placed in the same room, so when I turn physical dial on one of them, it will automatically adjust the two others to mirror the temperature setting.

Unfortunately with the newest 2021.3 update, it has broken.
The messages in the log are the following:

2021-03-14 21:16:58 ERROR (MainThread) [homeassistant.components.automation.trv_sync_common_room] TEM04 - TRV Sync - Common Room: Choose at step 1: choice 2: Error executing script. Invalid data for call_service at pos 1: must contain at least one of temperature, target_temp_high, target_temp_low.
2021-03-14 21:16:58 ERROR (MainThread) [homeassistant.components.automation.trv_sync_common_room] TEM04 - TRV Sync - Common Room: Error executing script. Invalid data for choose at pos 1: must contain at least one of temperature, target_temp_high, target_temp_low.
2021-03-14 21:16:58 ERROR (MainThread) [homeassistant.components.automation.trv_sync_common_room] Error while executing automation automation.trv_sync_common_room: must contain at least one of temperature, target_temp_high, target_temp_low.

So it appears that Home Assistant requires me to set a temperature, even though I just want it to mimic the one I changed manually.

Any ideas on how to make Home Assistant happy?

The automation is below:

- id: '1613419540106'
  alias: TEM04 - TRV Sync - Common Room
  trigger:
  - platform: state
    entity_id: climate.living_roomtrv1_thermostat, climate.living_roomtrv2_thermostat,
      climate.dining_roomtrv_thermostat
    attribute: temperature
  action:
  - choose:
    - conditions:
      - condition: template
        value_template: '{{ trigger.to_state.entity_id == ''climate.living_roomtrv1_thermostat''
          }}'
      sequence:
      - service: climate.set_temperature
        data: {}
        target:
          entity_id: climate.living_roomtrv2_thermostat, climate.dining_roomtrv_thermostat
    - conditions:
      - condition: template
        value_template: '{{ trigger.to_state.entity_id == ''climate.living_roomtrv2_thermostat''
          }}'
      sequence:
      - service: climate.set_temperature
        data: {}
        target:
          entity_id: climate.living_roomtrv1_thermostat, climate.dining_roomtrv_thermostat
    - conditions:
      - condition: template
        value_template: '{{ trigger.to_state.entity_id == ''climate.dining_roomtrv_thermostat''
          }}'
      sequence:
      - service: climate.set_temperature
        data: {}
        target:
          entity_id: climate.living_roomtrv1_thermostat, climate.living_roomtrv2_thermostat
  mode: single

I’m not sure that would have ever worked. As the error message says, the climate.set_temperature service requires one of those parameters.

Give the following a try. Let me know if it works for you, or if you have any problems with it. It uses some new features and I haven’t fully tested it out.

- id: '1613419540106'
  alias: TEM04 - TRV Sync - Common Room
  trigger_variables:
    thermostats:
    - climate.living_roomtrv1_thermostat
    - climate.living_roomtrv2_thermostat
    - climate.dining_roomtrv_thermostat
  trigger:
  - platform: state
    entity_id: "{{ thermostats }}"
    attribute: temperature
  action:
  - service: climate.set_temperature
    target:
      entity_id: "{{ thermostats|reject('eq', trigger.entity_id)|list }}"
    data:
      temperature: "{{ trigger.to_state.attributes.temperature }}"
1 Like

Thank you for you input Phil, it did indeed work, as the requirement wasn’t there previously.

But alas, I tested your version out, and it failed with the following:

2021-03-15 23:54:11 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: Entity ID {{ thermostats }} is an invalid entity ID for dictionary value @ data['entity_id']. Got None. (See /config/configuration.yaml, line 33).

Oops. Yeah, the state trigger’s entity_id parameter doesn’t accept a template. Ok, there’s more than one way… Try this instead:

- id: '1613419540106'
  alias: TEM04 - TRV Sync - Common Room
  trigger:
  - platform: state
    entity_id: &thermostats
    - climate.living_roomtrv1_thermostat
    - climate.living_roomtrv2_thermostat
    - climate.dining_roomtrv_thermostat
    attribute: temperature
  variables:
    thermostats: *thermostats
  action:
  - service: climate.set_temperature
    target:
      entity_id: "{{ thermostats|reject('eq', trigger.entity_id)|list }}"
    data:
      temperature: "{{ trigger.to_state.attributes.temperature }}"
4 Likes

I can confirm this is working, thank you Phil!

1 Like

Just to follow up on this point, I think you’re mistaken. Calling the climate.set_temperature service without a temperature setting makes no sense. It could never have worked. And I just noticed in the other topic where you were discussing this, you first posted this automation that did contain a temperature, but later changed it to this one without a temperature and said it didn’t work because the HA version changed. I think you somehow removed the temperature at the same time as changing versions and got confused.

But, regardless, I’m glad it’s working for you now! :smiley:

1 Like

You really made me scratch my head.

Because honest to god, I can say I didn’t delete those lines deliberately.

What I think might have happened, was after the upgrade and the automation failed, I went to the GUI editor of the automation, and it somehow didn’t accept the temperature values that was already there (as it wasn’t a number), and pressed save by a mistake with no value present.

But again, no point in speculating now, as it is happily working! :slight_smile:

1 Like

Hi, I appreciate that this is an old post but I stumbled on this code whilst trying to implement something similar, however it’s showing an error regarding the following lines:

  variables:
    thermostats: *thermostats

If I remove them it doesn’t throw an error. I’m on 2023.11.3. I don’t know what is causing the error, please can anyone help?

I just copied & pasted that into:

https://yaml-online-parser.appspot.com/

It doesn’t have a problem with it. Maybe you didn’t enter it correctly into your configuration. Can you share exactly what you entered?

Hi Phil,

This is what my automation looks like. I entered it through the front end by creating a new automation and switching to YAML view.

alias: Sync Hall TRVs
description: ""
trigger:
  - platform: state
    entity_id:
      - climate.hall_radiator
      - climate.small_hall_radiator
    attribute: temperature
condition: []
action:
  - service: climate.set_temperature
    target:
      entity_id: "{{ thermostats|reject('eq', trigger.entity_id)|list }}"
    data:
      temperature: "{{ trigger.to_state.attributes.temperature }}"
mode: single

Ok, but I don’t see what you said was causing an error. What do you need help with?

ah, sorry…I originally removed the bit causing the error so it would save. I made the following change directly in automations.yaml:

- id: "1700931303786"
  alias: Sync Hall TRVs
  description: ""
  trigger:
    - platform: state
      entity_id: &thermostats
        - climate.hall_radiator
        - climate.small_hall_radiator
      attribute: temperature
  variables:
    thermostats: *thermostats
  condition: []
  action:
    - service: climate.set_temperature
      target:
        entity_id: "{{ thermostats|reject('eq', trigger.entity_id)|list }}"
      data:
        temperature: "{{ trigger.to_state.attributes.temperature }}"
  mode: single

When viewed from the automations panel:

and then changing to yaml view:

alias: Sync Hall TRVs
description: ""
trigger:
  - platform: state
    entity_id:
      - climate.hall_radiator
      - climate.small_hall_radiator
    attribute: temperature
variables:
  thermostats:
    - climate.hall_radiator
    - climate.small_hall_radiator
condition: []
action:
  - service: climate.set_temperature
    target:
      entity_id: "{{ thermostats|reject('eq', trigger.entity_id)|list }}"
    data:
      temperature: "{{ trigger.to_state.attributes.temperature }}"
mode: single

Ok, so that is perfectly valid YAML (I mean the one that uses the anchor and alias.) The problem is that the GUI automation editor doesn’t support it / understand it. I’m not sure, based on what you show, whether it is the anchor & alias that is causing the GUI editor heartburn, or if it’s the variables part.

Thanks Phil, I’ve confirmed that it works now so will ignore the issues seen with the gui editor.

1 Like