Hi there,
the above feature was introduced with 2023.12 and I am still trying to figure out why it’s not working as expected for some of my template sensors calculating EUR.
The template sensors that do show long-term statistics in the history dashboard are the the ones with
state_class: total_increasing
device_class: energy
unit_of_measurement: "kWh"
and
state_class: measurement
device_class: power
unit_of_measurement: "W"
But the ones with
state_class: total
unit_of_measurement: "EUR"
do not show long-term statistics in the history dashboard, these are purged with the purge_keep_days:
I’ve configured in my recorder.yaml. Here’s a full example of a template sensor that does not show long-term stats:
- trigger:
- platform: time_pattern
minutes: 54
sensor:
- name: "Stromkosten Verbrauch Haus Jährlich"
unique_id: stromkosten_haus_verbrauch_yearly
state_class: total
unit_of_measurement: "EUR"
icon: mdi:currency-eur
state: "{{ (states('sensor.verbrauch_haus_jahrlich' ) | float * states('input_number.strompreis_pro_kwh' ) | float ) | round(2) }}"
I’ve had a look at Developer Tools → Statistics for those template sensors that do not show long-term statistics in the history dashboard and I can see that stats are collected. I can also create a statistics card and see long-term statistics for these sensors.
If I interpreted the long-term stats documentation correctly all it takes is a state_class:
but that does not appear to be working for above - what am I missing?