Hi,
I’m new to HA and have running HA on a Raspberry PI 5 for some weeks now.
For tracking my dishwasher runs I created a helper “input_boolean.spulmaschine_lauft” that is set to “on” whenever it is running and “off” once it is finsihed (changed via automations based on energy consumption).
Based on this I have created a history stats that counts the number of runs this year:
- platform: history_stats
name: Spülmaschinenläufe dieses Jahr
entity_id: input_boolean.spulmaschine_lauft
state: "on"
type: count
start: "{{ now().replace(month=1, day=1, hour=0, minute=0, second=0) }}"
end: "{{ now() }}"
This was running fine until recently when I found out that numbers are not correct anymore.
I then found out that the “input_boolean.spulmaschine_lauft” is only kept in short term statistics for 10 days (default), so the history counter just counts the runs during the last 10 days:
When checking the link here:
it says that long term statistics (1 hour aggregate) is only available for state classes: measurement
, total
or total_increasing
.
My questions are now:
-
Does it make sense/work to set this “input_boolean.spulmaschine_lauft” to state_class
measurement
(total
ortotal_increasing
do not make any sense here) to get the data also in long term statistics? -
In parallel I also have another helper “counter.spulmaschine_anzahl_laufe” that is increased by the automation script everytime. So a better solution might be to set this to
total_increasing
and do somehow a calculation: Number of runs this year = Number of runs “{{ now() }}” - Number of runs "{{ now().replace(month=1, day=1, hour=0, minute=0, second=0) }}