Track total 'running time' since last service

I have multiple appliances, each attached to a smart plug that tracks the power draw. I can set thresholds on the power draw to determine when the machines are running or not.

What I would like to do is trigger an alert telling me to service the machine after, say, 100 hours of total running time. And I would like to be able to reset that counter manually after doing the maintenance.

I’m looking for a solution that is quick and easy to roll out to many different appliances. Something as easy as a blueprint or script.

Here’s what I’ve got currently, but it requires a lot of steps and entities for each appliance being monitored:

  1. Attach a power monitoring smart plug to the appliance
  2. Set a threshold sensor based on the power draw to signal when the appliance is running/not
  3. Create a timer to track one hour of run time
  4. Create a counter to store the total number of hours since last reset
  5. Create four automations:
    5a. Automation to start the timer when the threshold is on
    5b. Automation to pause the timer when the threshold is off
    5c. Automation to increment the counter and reset the timer, each time the timer reaches one hour
    5d. Automation to send the ‘Maintenance Required’ notification when the counter reaches 100 hours
  6. Finally, I reset the counter manually when the service is done.

Is there a better and simpler way to do all of this?

I looked into the History Stats but I couldn’t see how to make that manually resettable.

Would it be possible for me to put this all into a blueprint or script so I can quickly deploy it to more appliances?

Thanks

Did you ever figure out a better solution for this? I would like to set up a similar automation to track hours for filter changes.

No, sorry. I’m still using the solution I listed in the question. Let me know if you have any ideas!

Here’s a package and automation I use to track UV filter life.

homeassistant:
  customize:
    sensor.um_hvac_uv_uv_usage:
      unit_of_measurement: hours

input_number:
  um_hvac_uv_filter_life:
    min: 0
    max: 50000
    step: 1
    unit_of_measurement: hours
    mode: box

input_button:
   um_hvac_uv_filter_reset:
     name: um_hvac_uv_filter_reset


template:
  - trigger:
      - platform: time_pattern
        minutes: "/1"
    sensor:
      - name: um_hvac_uv_per_hour
        unit_of_measurement: hours
        state: >-
          {{ iif(is_state("switch.hvac_uv","on"),1,0) }}
        attributes:
          triggered_at: "{{ now().hour }}"
  - sensor: 
      - name: um_hvac_uv_filter_life
        unit_of_measurement: "%"
        state: "{{ (((1.0 - ( states('sensor.um_hvac_uv_uv_running')|float(0) / states('input_number.um_hvac_uv_filter_life')|float(0) )))*100.0)|round(1) }}"

sensor:
  - platform: integration
    source: sensor.um_hvac_uv_per_hour
    name: um_hvac_uv_uv_usage
    unit_time: h
    method: left
    round: 2

utility_meter:
  um_hvac_uv_uv_running:
    source: sensor.um_hvac_uv_uv_usage

recorder:
  include:
    entities:
      - sensor.um_hvac_uv_uv_running
      - sensor.um_hvac_uv_uv_usage
      - sensor.um_hvac_uv_per_hour
      - input_number.um_hvac_uv_filter_life
      - input_button.um_hvac_uv_filter_reset
      - sensor.um_hvac_uv_filter_life
- id: reset um_hvac_uv filter
  alias: reset um_hvac_uv filter
  description: ""
  mode: single
  trigger:
    - platform: state
      entity_id: input_button.um_hvac_uv_filter_reset
  action:
    - service: utility_meter.calibrate
      data:
        value: "0"
      target:
        entity_id: sensor.um_hvac_uv_uv_running
1 Like