Automation: dynamically get thermostat preset_mode attribute in a service call action

I’m trying to synchronise 2 thermostats. states.
When preset mode is changed on one of those 2 thermostat, the other sould follow too.

I’ve made this automation:

description: ""
mode: single
triggers:
  - trigger: state
    entity_id:
      - climate.jeedom_thermostat_cuisine_thermostat_cuisine
    attribute: preset_mode
    id: thermo_cuisine
  - trigger: state
    entity_id:
      - climate.jeedom_thermostat_salon_thermostat_salon
    attribute: preset_mode
    id: thermo_salon
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - thermo_cuisine
        sequence:
          - action: climate.set_preset_mode
            target:
              entity_id: climate.jeedom_thermostat_salon_thermostat_salon
            data:
              preset_mode: "{{ state_attr(‘climate.jeedom_thermostat_cuisine_thermostat_cuisine’, ‘preset_mode’) }}"
      - conditions:
          - condition: trigger
            id:
              - thermo_salon
        sequence:
          - action: climate.set_preset_mode
            data:
              preset_mode: "{{ state_attr(‘climate.jeedom_thermostat_salon_thermostat_salon, ‘preset_mode’) }}"
            target:
              entity_id: climate.jeedom_thermostat_cuisine_thermostat_cuisine
alias: Synchro thermostats salon cuisine

I can’t save it with this error:

Message malformed: template value should be a string for dictionary value @ data[‘actions’][0][‘choose’][0][‘sequence’][0][‘data’]

Seems it doesn’t like the jinja preset_mode: “{{ … }}”

Any help ?

Thanks

You are using the wrong sort of “fancy” single quotes:

preset_mode: "{{ state_attr(‘climate.jeedom_thermostat_cuisine_thermostat_cuisine’, ‘preset_mode’) }}"

Should be:

preset_mode: "{{ state_attr('climate.jeedom_thermostat_cuisine_thermostat_cuisine', 'preset_mode') }}"

ho my gosh you’re right. Lost in copypasta. Sorry for the mess.

Thanks

1 Like