Add a "Left Riemann Sum" option to the Integration Sensor Component

For power sources with pulsing or staircase type waveforms the “Left Riemann Sum” integration method is more “real world” accurate than the default “Trapezoidal rule” that is used.

See related discussion here.

Oops, I’ve just created a very similar request.

I suspect that most power sources are stepped or pulsing. The Trapezoid method used by the Integration Sensor is not appropriate in this case. Here is the python script that I wrote to replace the Integration Sensor. It is not any more difficult to setup than Integration Sensor. It updates a sensor which shows the energy change for that hour. The instructions are in the file header.
I have tested it with a histogram type power waveform and with a square wave which crosses the hour boundary. I got a 0.15% error from my manual calculation. The error comes from slight timestamp shifts in the database due to CPU load.

1 Like

https://github.com/home-assistant/home-assistant/pull/21050