Need help with input_number in an automation

Hello all,
I have an issue with an integration where I need to compare two temperatures (one read from a DS18B20 sensor and the other one set by the user via input_number. When sensor temperature is below the value from input_number, needs to start the thermostat_controller.
The code is presented below, my issue is that it never turns on the thermostat_controller. Please help with some advice.

Thank you in advance.

alias: Thermostat on
description: >-
  Automation that turns on the heating if the outside temperature drops below
  15C
trigger:
  - platform: state
    entity_id:
      - sensor.outside_temperature
      - input_number.temperature
condition:
  - condition: template
    value_template: >-
      {{states('input_number.temperature')|float >
      states('sensor.outside_temperature')|float}}
action:
  - device_id: fbda5f63af4123b8a48a3bad1f080494
    domain: climate
    entity_id: climate.thermostat_climate_controller
    type: set_hvac_mode
    hvac_mode: heat
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - type: turn_on
    device_id: fbda5f63af4123b8a48a3bad1f080494
    entity_id: switch.heating_relay
    domain: switch
mode: single

What does the automation’s trace report?

I do not understand very well your question, Taras. Can you please provide more details? I attached the trace diagram if this is what you meant.

Thank you.

Have you tried putting your template code into the Developer tools > Templates to see what each part of your expression returns? Put it into the Templates tool like this to see what each part returns.

{{states('input_number.temperature')|float }}
{{ states('sensor.outside_temperature')|float}}

The trace shows that the automation executed its State Trigger (the value of outside temperature changed) but determined that the new value wasn’t less than the value of the input_number. What were the values of the outside temperature and the Input number? That information is also recorded in the trace.

BTW you should provide the float filter with a default value.

    value_template: >-
      {{ states('input_number.temperature') | float(0) >
        states('sensor.outside_temperature') | float(0) }}

Thank you Taras for the tip. Using

value_template: >-
      {{ states('input_number.temperature') | float(0) >
        states('sensor.outside_temperature') | float(0) }}

did solve my issue.

The thread can be closed now. Many thanks once again.

1 Like

Hi templeton_nash,
I did and it returned an error. Using @123 Taras suggestion solved my issue. Thank you too for your support.