Setting a counter value to a sensor

I’m a relative noob with respect to HA and yaml so I would appreciate any assistance.
This is my first post here. I think I’ve posted in the correct area here in the forum. If not, please direct me to a better one.
I’ve really enjoyed HA and have gotten a ton of good info from this community.
What would be best practice to accomplish the problem stated below?

Problem:

What I’d like to do is create a sensor for my dehumidifer that would store a counter value, updating at midnight & resetting the counter to zero. It might run like this.

At midnight:

  1. Set sensor.dehumidifier_daily_count equal to the value of counter.dehumidifer_cycles
  2. reset counter.dehumidifier_cycles to zero.

The sensor would then keep a history of the daily counter total.

I’m not set on using a sensor or counter if there’s a better way, just looking for some input from the community.

Background:

I’ve used the Emporia Energy integration to create states for appliances based on their power draw, i.e for a dehumidifier:

< 5 watts, State = “Standby”
< 20 watts, State = “Fan”
else State = “Run”

I created counter.dehumidifier_cycles to increment each time the state changes to “Run” (count run cycles).

This bit is working great but necessary to understand to explain the problem I’m having.

My goal is to keep a history of the daily cycles of the dehumidifer to see if it changes over weeks, months, etc.

Next Step:

Ideally I’d like to count the total number of minutes in a day it’s running. Why?
When coils need to be cleaned or the refrigerant in the system is low, the compressor tends to run longer for each cycle.
This way I can get a baseline of the normal operating time per day.
If it starts to go up significantly this can indicate maintenance needs to occur before it actually fails.
This could also be used for a refrigerator, A/C system, etc.

Thanks!!!

That’s great. Thank you!!