Using climate.preset_mode in a data_template

I am not sure why this automation doesn’t pass the Check Config test. Any ideas?

  ##### Manual Setting/Unsetting of Downstairs Away Mode for Thermostats
  - id: downstairs_away_mode
    alias: Downstairs Away Mode
    trigger:
      - platform: state
        entity_id: input_boolean.downstairs_away_mode
    action:
      ## Turn on/off thermostat "Away Mode".
      - service: climate.set_preset_mode
        data_template:
          entity_id: 
            - climate.basement_heater
            - climate.shop_ac
            - climate.shop_heater
            - climate.finishing_room_heater
          preset_mode: > 
            {% if trigger.to_state.state == 'on' %}
              away
            {% else %)
              none
            (% endif %)

I get the following error:

Invalid config for [automation]: invalid template (TemplateSyntaxError: expected token 'end of statement block', got '%') for dictionary value @ data['action'][0]['data_template']['preset_mode']. Got None. (See /config/configuration.yaml, line 185). Please check the docs at https://home-assistant.io/components/automation/

If I just set preset_mode': 'away' then the config check passes.

You are using parentheses instead of braces in a number of places. Shoudl be:

          preset_mode: > 
            {% if trigger.to_state.state == 'on' %}
              away
            {% else %}
              none
            {% endif %}
1 Like

Yup, that was it. Thank you so much. I couldn’t see that for the life of me.