Automation: condition in action won't work

Hello everyone,
I can’t get it to work, so I’m looking for some support here… I want to change the target temperatures of my thermostat based on the preset state. The trigger works, but not the action…

alias: Thermostat - Change Temperature Targets (Duplicate)
description: ''
trigger:
  - platform: mqtt
    topic: Tasmota_HVAC/HASS/Preset_mode
condition: []
action:
  - service: climate.set_temperature
    data:
      data_template: >
        {% if state_attr('climate.study_mqtt', 'preset_mode') == 'Vacation' %}
          target_temp_low: '{{ states.input_number.mode_confort_mini.state }}'
          target_temp_high: '{{ states.input_number.mode_confort_maxi.state }}'
        {% else %}
          target_temp_low: '18.2'
          target_temp_high: '22.3'
        {% endif %}
    entity_id: climate.study_mqtt
mode: single

I read a lot on the forum but haven’t been able to pin point what I’m doing wrong…

What you are doing wrong is you are attempting to include options, target_temp_low and target_temp_high, inside a template.

A template can only be used to generate a value for an option.

some_kind_of_option: "{{ your template goes here }}"

In addition, you are using an invalid combination of two options (data and data_template).

Try this version of the action. Each option has its own template.

action:
  - service: climate.set_temperature
    data:
      target_temp_low: >
        {{ states.input_number.mode_confort_mini.state if state_attr('climate.study_mqtt', 'preset_mode') == 'Vacation' else 18.2 }}
      target_temp_high: >
        {{ states.input_number.mode_confort_maxi.state if state_attr('climate.study_mqtt', 'preset_mode') == 'Vacation' else 22.3 }}
      entity_id: climate.study_mqtt
1 Like

Awesome!!! Thanks for the help, very much appreciated!

1 Like