HA Data misrepresentation in Grafana graphs

I have come across an issue where HA data is somehow missrepresented when collected and displayed in Grafana.

The data that is misrepresented in my case is data from an Off Peak hot water service (HWS). This device turns on and goes from 0 W to about 3.6kW and later down to zero very quickly. The data all looks perfect when looking in HA History for that sensor. However, the graph in Grafana of the same sensor seems to have the measurements when the HWS is on ok. But when it switches off, it does not appear to get the 0W reading and register it. It seems to pick up some non zero value between 3.6kW and 0. So it does not go to zero and stays like that until the HWS turns on again.

To add to this, I have 2 different sensors for the same power meter. It is an Iammeter WEM3080T power meter. And I have an options of reading it :-

  1. Modbus which has the problem described above.
  2. The builting intergration you can see here IamMeter - Home Assistant

Modbus does not seem to work (as described above), but the built in integration seems to be a little better, but still has the issue to some extent. Ie I see the issue described with the Modbus data over 24h (or even less). But when looking at the data with the built in integration, it looks correct when I look at 24h. But if I look at 2d of data, I can see signs of the issue even with the build in integration. I mostly use the Modbus method, because in enables me to read the sensor much faster which I need for Tesla charger control to match charge to excess solar. With Modbus I can read the sensor once a second. With the built in integration it is more like once every 30 seconds.

I suspect the speed of the sensor reading is something to do with the issue, caused as a result of how data is summarised when it is displayed which is causing the corruption in the way things are displayed. But I don’t know how to fix.

If I look at the graph with the “24h view”, it is as described above. But if I zoom in on the graph at the edge when it is dropping to zero, it does in fact correctly drop to zero. But if I zoom in close enough to the points it drops to zero, it does in fact drop to zero. So this would suggest all the data is there and correct in InfluxDB, and the issue is how Grafana is summarising that data and displaying it.

I suspect the explanation is that when it drops to zero, there is only 1 zero value recorded in the database. In all the successive periods of time, nothing is recorded, because it is zero and does not change. So when I have more data to display (because of 1 reading a second) than my screen can display, I am guessing Grafana is doing some sort of summarisation of the data which is stuffing me up eg if there is 1 reading of 3.6kW and 1 reading of zero, maybe it summaries this datapoint to an average of 1.8kW which seems reasonable. But the issue is why the next reading is not recorded as zero which makes it all good?? Maybe something to do with the fact that maybe only 1 zero is recorded and the next time frames have no reading???

I have no idea if it is the fact that multiple readings that are the same are summarised, or in fact if it is the fact of this AND the value is zero??

Anyway, I don’t know enough about InfluxDB/MySQL or Grafana to figure out how to fix this. So all help from the brains trust here would be greatly appreciated.