Continue counting when cumulative counter resets

Recently I’ve been looking into getting a bunch of smart plugs for power measurement. One thing I noticed while reading reviews here and there is that there are smart plugs that can randomly reset the cumulative energy counter for whatever reason, mostly due to power loss and volatile memory it seems.

What I am curious about is if there’s a way to get Home Assistant to continue counting instead of giving some strange values when a cumulative counter resets, in this example the cumulative energy counter of a smart plug but I guess this applies to any device with such a counter (no matter what it measures).

Does Home Assistant (or it’s energy dashboard) have anything build in to deal with something like this or does this require a template sensor that is capable of dealing with such a situation?

If it has a state class of total_increasing it won’t affect the energy dashboard.

If you want to keep a running total for any length of time outside the energy dashboard use a utility meter helper.