Riemann sum integral for imported energy issue with spikes in import power

I have solar and using an external docker sending MQTT i get the current active energy imported from the grid whilst the MQTT integration does keep a record of Energy Imported from Grid in kWh this gets reset if the docker container is restarted for what ever reason. Hence i am trying to use a Reimann Sum Integral to get the energy using the current power imported from the grid in Watts.
This works when i get continuous readings e.g. overnight when there is no solar BUT during the day if there is a sudden spike in import (when there is a cloud for example) then the Integral has a large increase:


The blue line is the Reimann integral sum (daily using a utility meter) and purple is from the external docker MQTT inputs which works as expected.

This is the graph of Watts imported which has the spikes shown:

Does anyone else see this? Is this just a mathematical limitation or is there some defect here?
My Reimann integral is over 1 hour and in kilo.

Try using method: left in your Riemann Sum config. The default trapezoidal method has large a large error component with spikey data.

Thanks, i have tried this, so far it seems to look much better with the spikes i had today.

1 Like