I have previously used very simple template to calculate so called heating number, which I use for certain energy related optimizations. However, 2025.12 version of Home Assistant changed the way statistics are collected and saved, and changes were made to templates too, if I have understood it correctly.
The code below output float before 2025.12. After 2025.12, it outputs string and messes rest of template, because one can’t perform math operations with strings, which is logical:
{% set temp_ave = states('sensor.24h_average_outdoor_temp') | default(0) | float %}
sensor.24h_average_outdoor_temp likely to float, because it’s source is HomeAssistant’s builtin Filter (moving average), which in turn receives temp from my EcoWitt weather staion in float/measurement form.
I have tried to study how to correct the code line above to work with current versions. I have tried float/default commands in different order in dev tools, only result being different errors. This is propably very simple thing to fix, but I just don’t know, how to change that line of code. Any help is greatly appreciated!
EDIT
complete template below, as well as error:
{% if now().month <= 6 and states('sensor.24h_average_outdoor_temp') | float >= 10 %}
0
{% elif now().month <= 6 and states('sensor.24h_average_outdoor_tempa') | float < 10 %}
{{ 17 - temp_ave }}
{% elif now().month >= 7 and states('sensor.24h_average_outdoor_temp') | float >= 12 %}
0
{% else %}
{{ 17 - temp_ave }}
{% endif %}
produces error:
ValueError: Template error: float got invalid input ‘unknown’ when rendering template ‘{% if now().month <= 6 and states(‘sensor.24h_average_outdoor_temp’) | float >= 10 %} 0 {% elif now().month <= 6 and states(‘sensor.24h_average_outdoor_tempa’) | float < 10 %} {{ 17 - temp_ave }} {% elif now().month >= 7 and states(‘sensor.24h_average_outdoor_temp’) | float >= 12 %} 0 {% else %} {{ 17 - temp_ave }} {% endif %}’ but no default was specified