Sensor history stats going wild

I wanted to count the running time of my heatpump.
Therefore i created 2 sensors:

sensor:
  - platform: history_stats
    name: Wärmepumpe Betriebsstunden Gesamt
    entity_id: input_boolean.wp_status
    state: "on"
    type: time
    start: "{{ 0 }}"
    end: "{{ now() }}"
  - platform: history_stats
    name: Wärmepumpe Betriebsstunden Monat
    entity_id: input_boolean.wp_status
    state: "on"
    type: time
    start: '{{ now().replace(day=1).replace(hour=0).replace(minute=0).replace(second=0) }}'
    end: "{{ now() }}"

This worked well in the beginning, but now after some weeks the sensor values are much too high.


After restarting HA it automatically added 60h.
And a few weeks ago 460.000h.
Hope someone already had same werid issue and can helpme.
thank you.

The bug appears evrytime i update und restart home assistant.
Does no nobody face the same issue?

This is not going to work. Your recorder history only goes back 10 days by default.

Understood, can you help me to find a workaround, or is there any other possible solution?

You have to store 31 days worth of data. There are no work arounds. Just configure recorder to store more data.

That will work for the monthly sensor but their first sensor is an attempt at a total run hours (since the Unix epoch).

ah, didn’t notice that. Yep, no way around that.

Thank you, i configured the recorder to 31 days, i will wait and see if it works.