Long term statistics on "input_boolean"?

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:

  1. Does it make sense/work to set this “input_boolean.spulmaschine_lauft” to state_class measurement (total or total_increasing do not make any sense here) to get the data also in long term statistics?

  2. 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) }}

Input booleans do not support a state_class and thus can not have LTS generated for them.

The history stats sensor only works on state history anyway, not LTS.

Thanks. So this won’t work with input_boolean.
But I guess the same applies for counter too? I added “state_class: totoal” to the counter but it disappeared after restart of HA.
Also in the docu there is no “state_class” listed for counter, so looks like it is also not supported here:

Is there a way to store the number of runs (incl. history) on long term?
What I want then is to analyze later e.g. “How many runs did I have in 2024”.