Message malformed: expected float for dictionary value @ data['above']

Why do I get: “Message malformed: expected float for dictionary value @ data[‘above’]” in the automation code below?

trigger:
  - platform: numeric_state
    entity_id: sensor.anna_temperature
    above: "{{ states('input_text.maximumtemp') | float }}"

I also try it with an input_number, but I get the same warning.

I believe this is not (yet) allowed for ‘above’ (or below) …noting clearly that I cannot keep up with changes so if I am wrong then the experts will chime in

If I am right, you could write a template trigger instead., e.g.

{{ (states(sensor.anna_temperature) | float) > (states('input_text.maximumtemp') | float) }}
1 Like

The above configuration variable does not accept templates, it will however accept an entity id of certain types of entities:

  1. Number helpers (input_number entities)
  2. number entities (state or trigger-based template numbers)
  3. sensor entities that contain a numeric value

To make it work in a Numeric state trigger you would need to set up and use an Input number helper instead of an Input text.

trigger:
  - platform: numeric_state
    entity_id: sensor.anna_temperature
    above: input_number.maximumtemp
1 Like

The template option has the advantage that it will trigger immediately if you change the input helper to below your sensor value. The numeric state trigger only watches for changes of the sensor, not changes of the input helper or sensor entity in the above: section.

This was brought up as an issue but was closed as expected behaviour.

If you do use a template and input text instead of an input number then you need to supply a default for your float conversation filter in case someone enters text instead of a number.

Preferably you should use an input number helper.

1 Like

Question as confused… states are supposed to be strings so I would expect ‘input_number.maximumtemp’ to return a string … and this not work

The trigger always supported strings in the above and below fields as long as they could be converted to numbers. E.g. this is valid:

trigger:
  - platform: numeric_state
    entity_id: sensor.anna_temperature
    above: "42"

I think. I have never actually tested it.

I can confirm what Tom stated, the field will accept a numeric string if it’s typed in directly. I think the limitation on accepted entity types comes from the configuration checking mechanism, but that’s above my pay grade.

I have same error with triger state … trying to change “for” condition to my helper

 trigger:
  - platform: state
    entity_id:
      - switch.b14a_lazienka_uv_sb_b14a_lazienka_uv_sb_relay
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: input_number.minuty_1|float
      seconds: 10
condition: []
action:
  - service: switch.turn_off
    data: {}
    target:
      entity_id: switch.b14a_lazienka_uv_sb_b14a_lazienka_uv_sb_relay
mode: single

can I use a helper in this trigger ?

input_number.minuty_1|float is just a string of letters as far as the program is concerned.
You need to use an actual template, as shown in the trigger docs in the Numeric state section:

image

 trigger:
  - platform: state
    entity_id:
      - switch.b14a_lazienka_uv_sb_b14a_lazienka_uv_sb_relay
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: "{{ states('input_number.minuty_1') | int(0)}}"
      seconds: 10
1 Like

Yes !!! it is working :slight_smile:
thanks

1 Like