Help with syntax - automation value template attribute

Hello, I can not manage to get the syntax right on this for my automation to work.
I have home assistant doing the scheduling for a zwave thermostat. For situational awareness I wanted HA to verify that temps where set correctly and if not to notify me.

In attempt to debug I created a test automation to email me on success and on failure, however traces reads BOTH tests of != and == as false.
If I put the == value template in an if statement in developer tools it tests just fine, so it shouldnt be any issue with variable name/type.

Bellow is my automation, thank you for any help you can provide.
FYI the trigger is just an existing toggle I used, and in the real automation there is multiple different actions that vary by trigger which is why I did not put it into conditions).

alias: 01 - Test
description: ""
trigger:
  - platform: conversation
    command: Test template
  - platform: state
    entity_id:
      - input_boolean.at_telegraph
    to: "on"
    id: State
action:
  - if:
      - condition: trigger
        id:
          - State
    then:
      - if:
          - condition: or
            conditions:
              - condition: template
                value_template: >-
                  "{{ state_attr('climate.t6_pro_thermostat_36',
                  'target_temp_high') !=
                  states('input_number.ts_mf1_cold') | int }}"
              - condition: template
                value_template: >-
                  "{{ state_attr('climate.t6_pro_thermostat_36',
                  'target_temp_low') != states('input_number.ts_mf1_heat')
                  | int }}"
        then:
          - service: notify.1stgen
            metadata: {}
            data:
              message: Test Unseccesfull
              title: Thermostat change reads false
      - if:
          - condition: and
            conditions:
              - condition: template
                value_template: >-
                  "{{ state_attr('climate.t6_pro_thermostat_36',
                  'target_temp_high') ==
                  states('input_number.ts_mf1_cold') | int }}"
              - condition: template
                value_template: >-
                  "{{ state_attr('climate.t6_pro_thermostat_36', 'target_temp_low') == states('input_number.ts_mf1_heat') | int }}"
        then:
          - service: notify.1stgen
            metadata: {}
            data:
              title: Test automation worked scucessfully
              message: Thermostat change success
mode: single

the issue is that you have quoted the templates. so the template is now a string.

alias: 01 - Test
description: ""
trigger:
  - platform: conversation
    command: Test template
  - platform: state
    entity_id:
      - input_boolean.at_telegraph
    to: "on"
    id: State
action:
  - if:
      - condition: trigger
        id:
          - State
    then:
      - if:
          - condition: or
            conditions:
              - condition: template
                value_template: >-
                  {{ state_attr('climate.t6_pro_thermostat_36',
                  'target_temp_high') !=
                  states('input_number.ts_mf1_cold') | int }}
              - condition: template
                value_template: >-
                  {{ state_attr('climate.t6_pro_thermostat_36',
                  'target_temp_low') != states('input_number.ts_mf1_heat')
                  | int }}
        then:
          - service: notify.1stgen
            metadata: {}
            data:
              message: Test Unseccesfull
              title: Thermostat change reads false
      - if:
          - condition: and
            conditions:
              - condition: template
                value_template: >-
                  {{ state_attr('climate.t6_pro_thermostat_36',
                  'target_temp_high') ==
                  states('input_number.ts_mf1_cold') | int }}
              - condition: template
                value_template: >-
                  {{ state_attr('climate.t6_pro_thermostat_36', 'target_temp_low') == states('input_number.ts_mf1_heat') | int }}
        then:
          - service: notify.1stgen
            metadata: {}
            data:
              title: Test automation worked scucessfully
              message: Thermostat change success
mode: single

if you use > or |. then you put the template on the next line and don’t quote it. if you don’t use > or | and you keep the template on the same line then you do quote it.

Ok, that seems to fix it now, thank you!
I had pasted the template string into the visual editor and did not know that - was turning the line into a string

1 Like

great. glad it’s working for you now! :slight_smile: