History Stats - Manual Reset

It would be nice to be able to manually reset history stats sensors.

Use case: I total the hours my HVAC system has run with a history stats sensor. When it hits 250 hours I get a notification to change the filter. I’d like to be able to reset the hours counter once I’ve changed the filter to restart the count.

I think this has some merit:

Unless I’ve misunderstood something along the way statistic sensors are calculated from the database and history stats are a just a cumulative counter, no? That would be quite the refactor!

Sounds like he just needs to be able to specify start/end times for the statistic sensors to meet his use case. I just need to be able to reset the history stats to meet mine :slight_smile:

Yes, history_stats-like durations on statistics sensors would work just fine for me. As would statistics-like analysis on history_stats sensors. But then they start to look remarkably similar. Maybe it isn’t so much a refactor as making either one do both things and deleting the other? (Or aliasing it, to avoid breaking things:-) He says, knowing almost nothing about the innards of home assistant and how difficult this would be.

Steve.

@jazzyisj Hi, did you find a solution? I have the same need as you to do maintenance every given number of hours and then reset the sensor.

Create a template button and use the state of that (timestamp when last pressed) as the parameter value for the start time.

template:
  - button:
      - name: "HVAC Filter Reset"
        unique_id: hvac_filter_reset
        icon: mdi:air-filter
        press: []

sensor:
  - platform: history_stats
    name: "HVAC Filter Hours"
    entity_id: binary_sensor.hvac_active
    state: "on"
    type: time
    start: >
      {% set start = states('button.hvac_filter_reset') %}
      {{ iif(start in ['unknown','unavailable'],now(),start|as_datetime) }}
    end: "{{ now() }}"
3 Likes

Try this:

action:
service: homeassistant.turn_off
entity_id: sensor.tiempo_secadora_funcionando

You will have to replace “sensor.tiempo_secadora_funcionando” with your own sensor

hello.
Im searching for the same. the ability to reset a history stats. because my history stats must reset at midnight (0:00) but not allways reset :frowning:

I try your aproach but not works :frowning: