I’m not even sure that the problem is as simple as just converting a string to float to resolve the issue, but here’s the situation I’m in:
I’ve got a sensor that checks the difference between the min and the max temperature in a list of sensors.
e4_temperature_differential:
friendly_name: "ΔT"
value_template: >
{% set e4_temps = states("sensor.e4_2ndfl_temperature") | float, states("sensor.e4_mainfl_temperature") | float, states("sensor.e4_bsmt_temperature") | float %}
{{ (e4_temps | max) - (e4_temps | min) }}
unit_of_measurement: "°C"
and then there is a binary sensor that will determine whether a circulation fan is turn on or off if the difference is greater than 1.5 degC.
circulation_fan:
friendly_name: "Circulation Fan"
value_template: >-
{% if states.sensor.e4_temperature_differential.state >= 1.5 %}
on
{% else %}
off
{% endif %}
However, when i check in the developer’s tools, i see that binary_sensor.circulation_fan is “unavailable”. And in the Template section, i see that the error is:
TypeError: '>=' not supported between instances of 'str' and 'float'
I figured that means the calculation where i do the subtraction is outputting a string and not a float, so i modified that line to say:
{{ ((e4_temps | max) - (e4_temps | min)) | float }}
The error persists and i’m not sure what the real issue is anymore. Can anyone shed some light?