Template warning: 'float' got invalid input 'unknown' when rendering template

The value of one of the two sensors (or both) was unknown.

The float filter cannot convert the value "unknown" to a number.

When it cannot convert the value, it can report a default value.

In all previous versions of Home Assistant, the default value was zero.

Starting in version 2021.10.0, you should specify the default value. If you don't, and float cannot convert the value, it will be reported as a warning message and Home Assistant uses zero as a default value.

Starting in version 2021.12.0, you must specify the default value. If you don't, and float cannot convert the value, it will be reported as an error message and the template will fail.

Change it to this:

      value_template: "{{ states('sensor.pzem_016_energy_power') | float(0) + states('sensor.pzem_016_2_energy_power') | float(0) }}"

You should also investigate why the sensor value was unknown.


For more information about specifying default values for filters, refer to the following:

9 Likes