Best Method to Keep Track of total time an entity is on

Hi There,

I have a dehumidifier, and would like to create a sensor that tells me the total runtime (HH:MM) and will only reset when I manually reset it to 0.

From all of the integrations, which one is the best to use?

You can use a History Stats sensor with an Input button helper.

  - platform: history_stats
    name: "Dehumidifier On-Time"
    entity_id: switch.dehumidifier
    state: "on"
    type: time
    start: >
      {{ states('input_button.reset_dehumidifier_on_time') | as_datetime }}
    end: "{{ now() }}"

Thanks! From all of the possibilities I was looking at before asking, this wasn’t one of them.

I have a little error here:
Error fetching Dehumidifier On-Time data: float() argument must be a string or a real number, not ‘NoneType’

  - platform: history_stats
    name: Dehumidifier On-Time
    entity_id: binary_sensor.dehumidifier
    state: 'on'
    type: time
    start: > 
      {{ states('input_button.reset_dehumidifier_on_time') | as_datetime }}
    end: '{{ now() }}'

You likely just need to “press” the button to give it an initial timestamp.

Thanks. I’ve noticed that it jumped from 50 to 105 at 12 PM on 2/13.

I also manually set the sensor to what it should be, but it keeps jumping back up to over 100.

Any idea what could be causing this?