Getting Error: Message malformed: expected float for dictionary value @ data['below']

Hello,

I am getting the following error when setting the “below” value from an input_number.

alias: Heizung an
description: ""
trigger:
  - type: temperature
    platform: device
    device_id: 74a10c5e1d2c32d0aeed1384d0322cc2
    entity_id: 6a9096938d526bd0356a5ff06604e3ca
    domain: sensor
    below: input_number.solltemperatur
    for:
      hours: 0
      minutes: 0
      seconds: 10
condition: []
action:
  - type: turn_on
    device_id: a601df3b20b12879fdb98e4d6e6b3897
    entity_id: b4559c0fc1d8a81c0db4a7ecba91cb0c
    domain: switch
mode: single

Also I tried

input_number.solltemperatur | float

Can anyone help me please?

Howdy Egmont,

That doesn’t work because device triggers do not accept templates, you didn’t have the correct template format there either.

My guess is that that input number does not exist. Did you create it?

Why and how to avoid device_ids in automations and scripts.

Look at that in the developer tools and see if it exixts and if it’s currenrtly a number.

Open your Home Assistant instance and show your state developer tools.

Hi!

Yes, I did create the input_number.solltemperatur before:

I read the very good advices in: Why and how to avoid device_ids in automations and scripts .
Following that I changed from device to entitie and now it should work.

One more question. How to do this:

above: input_number.solltemperatur + 1

You will need to change the entity to a variable much like you would a blueprint !input and put that into a template.
Blueprints: Get your !input value into a template.

I made now a template and the template testing was okay, but in the real life the switch ist not triggered:

alias: HeizungSchalterAn
description: HeizungSchalterAn
trigger:
  - platform: template
    value_template: |
      "{{ states('sensor.thermostat_eingang_temperatur') | float < 
      states('input_number.solltemperatur') | float }}"
condition: []
action:
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.schalter_test
mode: single

I know you said to change the entity in a variable, but I didn’t understand how ro do it.

I have now managed to create and integrate a variable. Unfortunately, switches are still not addressed.

alias: HeizungSchalterAn
description: HeizungSchalterAn
trigger:
  - platform: template
    value_template: |
      "{{ states('_thermostat_eingang_temperatur') | float(0) < 
      states('input_number.solltemperatur') | float }}"
condition: []
action:
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.schalter_test
variables:
  _thermostat_eingang_temperatur: "{{ states('sensor.thermostat_eingang_temperatur') | float }}"
mode: single

This isn’t correct. You’re using YAML multiline notation and quotes. You have to use 1 or the other, not both.

e.g.

    value_template: "{{ states('_thermostat_eingang_temperatur') | float(0)  < states('input_number.solltemperatur') | float }}"

or

    value_template: |
      {{ states('_thermostat_eingang_temperatur') | float(0)  < states('input_number.solltemperatur') | float }}

Secondly, _thermostat_eingang_temperatur is not a valid entity_id.

Lastly, variables are resolved after triggers, not before. Therefore you cannot use them in a template trigger.

With those changes in mind…

alias: HeizungSchalterAn
description: HeizungSchalterAn
trigger:
  - platform: template
    value_template: |
      {{ states('sensor.thermostat_eingang_temperatur') | float(0) < states('input_number.solltemperatur') | float }}
condition: []
action:
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.schalter_test
mode: single

Thanks for help. Now it works to switch on and off.
Here is the template for switching off:

value_template: >
      {{ states('sensor.thermostat_eingang_temperatur') | float(0) >
      (states('input_number.solltemperatur') | float(0) + 1 | float) }}

But what did @Sir_Goodenough mean with the variable instead of the entity in the template?

If it’s working, it’s working. Don’t break it. Otherwise if you are interested in that for another project I did leave links you can read first to discuss this more.

What I’m proposing isn’t better, it’s just different.