Automation condition is template

I had an automation where the set points were hardcoded into the automation.

alias: 01. HW2 Cyl2 Valve On/Off
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.hot_water_2_output
    to: "on"
    id: "on"
  - trigger: state
    entity_id:
      - binary_sensor.hot_water_2_output
    to: "off"
    id: "off"
  - entity_id: sensor.mixer_wwc2_current_temperature
    above: "59"
    id: hot
    trigger: numeric_state
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: "on"
          - condition: numeric_state
            entity_id: sensor.mixer_wwc2_current_temperature
            below: "58"
        sequence:
          - data: {}
            target:
              entity_id:
                - switch.hw_cyl2
            action: switch.turn_on
      - conditions:
          - condition: trigger
            id:
              - "off"
              - hot
        sequence:
          - data: {}
            target:
              entity_id:
                - switch.hw_cyl2
            action: switch.turn_off
mode: single

I wanted to move the setpoints into an input_number.
This works

alias: 01. HW2 Cyl2 Valve On/Off
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.hot_water_2_output
    to: "on"
    id: "on"
  - trigger: state
    entity_id:
      - binary_sensor.hot_water_2_output
    to: "off"
    id: "off"
  - trigger: template
    value_template: >-
      {{ states('sensor.mixer_wwc2_current_temperature')|int -
      states('input_number.dhw2_set_temperature')|int + 1 }}
    for:
      hours: 0
      minutes: 0
      seconds: 10
    id: hot
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: "on"
        sequence:
          - data: {}
            target:
              entity_id:
                - switch.hw_cyl2
            action: switch.turn_on
      - conditions:
          - condition: trigger
            id:
              - "off"
              - hot
        sequence:
          - data: {}
            target:
              entity_id:
                - switch.hw_cyl2
            action: switch.turn_off
mode: single

but I can’t reproduce the second condition which is intended to stop the valve opening if the temperature is already above 58C.
I tried

      - conditions:
          - condition: trigger
            id: "on"
          - condition: template
            value_template: >-
              {{ states('sensor.mixer_wwc2_current_temperature')|int -
                 states('input_number.dhw2_set_temperature')|int + 2 }}

Any ideas? TIA.

A numeric state condition accepts an input_number as an argument:

The same is true for triggers, except the value is only evaluated when the entity itself changes, not immeditely if you change the input_number itself:

tldr: you didn’t need to use templates but hou could just use the automtion as it was.

Are you sure it’s working the way you intend? Normally people use mathematical comparison operators like >,<, ==, etc in Template triggers because they only fire when their rendered vale changes from false to true.

As currently configured, the trigger will only fire when the difference between the sensor and input number changes from -1 to another number and stays “not -1” for 10 seconds. In HA templates any non-zero integer is considered true. If that’s not how you meant it to work, please clarify what your expectation for this trigger is so we can help.

This condition will always pass unless the difference between the sensor and input number is exactly -2.