Template comparison result does not change state

I’m trying the following automation.

alias: Turn off HVACs when Nordpool spot prices over limit
description: ''
trigger:
  - platform: template
    value_template: >-
      {{ states('sensor.nordpool_kwh_fi_eur_4_095_024 | float') > 
      states('input_number.elec_price_slider | float')  }}
condition: []
action:
  - device_id: 821bbee522b44841af684cb1c0a5a7ab
    domain: climate
    entity_id: climate.pana_mek
    type: set_hvac_mode
    hvac_mode: 'off'
  - device_id: c6d59cfa6cf443c19a372b6f317e22e7
    domain: climate
    entity_id: climate.pana_halli
    type: set_hvac_mode
    hvac_mode: 'off'
mode: single

The action part works fine, but the comparison not.

This is the problem:

I can freely alter the “slider” value, but whatever is the value, the comparison result does not change.

It seems to be handling the values as strings according to the text above the result box, but this is the case only when i put several clauses into the editor. If inserted one at the time, the result type seems to be correct, that is “boolean” for comparison and number for the parameters (however, when using “float” it becomes “string”)

However, in my dashboard when using e.g. entities card or others alike, it displays the value correctly and e.g. in the following automation it handles it nicely as number:

alias: Turn on HVACs when Nordpool spot prices under limit
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.nordpool_kwh_fi_eur_4_095_024
    attribute: current_price
    below: '10.1'
condition: []
action:
  - device_id: 821bbee522b44841af684cb1c0a5a7ab
    domain: climate
    entity_id: climate.pana_mek
    type: set_hvac_mode
    hvac_mode: heat
  - device_id: c6d59cfa6cf443c19a372b6f317e22e7
    domain: climate
    entity_id: climate.pana_halli
    type: set_hvac_mode
    hvac_mode: heat
mode: single

Trying to convert with float does not work, it just returns “unknown”

I have tried e.g. if else statement, no change

What gives? How can I make the comparison (and automation) work?

You need to rearrange a couple parts of your template. The float() filter is not part of your sensor or input numbers’ entity id, so it shouldn’t be included between the quotes or inside the parenthesis.

alias: Turn off HVACs when Nordpool spot prices over limit
description: ''
trigger:
  - platform: template
    value_template: >-
      {{ states('sensor.nordpool_kwh_fi_eur_4_095_024') | float(0) > 
      states('input_number.elec_price_slider') | float(0)  }}
condition: []
action:
  - device_id: 821bbee522b44841af684cb1c0a5a7ab
    domain: climate
    entity_id: climate.pana_mek
    type: set_hvac_mode
    hvac_mode: 'off'
  - device_id: c6d59cfa6cf443c19a372b6f317e22e7
    domain: climate
    entity_id: climate.pana_halli
    type: set_hvac_mode
    hvac_mode: 'off'
mode: single

Hi Drew, and thx!

It seems to be in order now. I notice I followed a sample from an old thread, where the syntax was different, however probably mistake even then :slight_smile:

Jus a note, I also noticed my previous structure DID work, but very randomly. Sometimes it changed the state and more often not…