Helper input_number isn't a number it is a string

I’m not sure if this is a new problem, but having defined a helper input_number, I find it isn’t a number when trying to use it, it is a string.

Checking it in the developer tools

{{(states('input_number.agile_upper_threshold_price')) < 0}}

I get


Is this expected behaviour?

The helper config allows unit_of_measurment but not device_class. I tried using customize to set the device_class but the config would not validate.

State values are always strings. Use the int or float filter to convert it to a number.

This is not new behaviour.


@tom_l - if so why is this unknown?

It’s mentioned in the documentation (and in the community forum). Refer to the description of an entity’s state property and to what is returned by the states() function.

In addition, an entity’s state property can only store a string whose maximum length is 255 characters (it will truncate anything longer).

In contrast, an entity’s attributes can store values whose type is string, int, float, dict, list, boolean, etc up to about 16 Kb.


Admittedly, those last two characteristics might not exist in the documentation.

1 Like