[Energy Measurement calculation from Power] Libre Hardware Monitor & Integration helper

Hi,

I’ve been using Libre Hardware Monitor for some time, and trying to implement a Energy monitoring for CPU and GPU (or for computer in general). For that I leverage the Power sensors, and then use the Integration helper to calculate kWh and the template sensor to make it detect by HA as an energy sensor for the energy monitoring.
However, I have one big issue: When I shutdown my PC, LHM is not sending a ‘null’, I just keep having the latests received value. However, when i turn it on, then the integration helper gets updated and, for some reason, assumes that all that time that my PC was off (and not reporting new data), as if it was actually on and consuming constantly the latest value received.

  • Is anyone using some similar approach?
  • An ideas how to solve this without creating a template sensor out of my power sensor that is set to null/0 if no updates received after eg 3 minutes?

Thanks!

PD: I prefer Libre over Open because it includes support for network card and GPU. And I prefer Libre over any other because haven’t seen any better alternative that supports GPU power reporting either (for example glances). Happy to hear about alternatives on that for a better monitoring integration than Libre.

Just to illustrate what I mean.
This is the Libre Hardware Monitor history sensor:


It can be seen how I turned off the computer at 01:14h, and the last measurement was 17,6W until nearly 9:00am.
Then, the Riemann integration sensor shows the following:

It can clearly be seen the spike right when the first data sample is received on restart of PC, and then the integral sensor just calculates all that time where no new samples came in as if the device was at 17.6W (~8h x 17.6W ~ 0.14kWh energy, which is exactly the spike value shown).
I guess it would be best to update the libre hardware monitor integration (or source program) to gracefully handle shutdowns, but, is there any other way?

Thanks!