Unable to correct massive spikes in graphs, despite editing utility readings in statistics

I have experienced several times where utility meters get ruined by rogue readings.
On my heatpump after on occasional reboots of the heatpump (reqired after configm changes) the power meter from (PZEM-004) registers in the megawatts momentarily.
As i run daily, monthly and yearly stats this corrupts all three and seems to be irrecoverable.
I can edit the statistics and then correct the current state on the entities for only a short time as this only corrects things till a restart of HA or a rerun of the statistics generation process on the hour.
The only fix is to roll back the database.

  • Am i doing something wrong here, or does the ability to correct statistics not work?
  • How on earth are the current stats cached after a removal of the table and a reboot?

In this graph, i have removed the utility “monthly daikin energy”,
restarted HA,
removed this table from the db,
restarted HA
re-added utility meter
restarted HA
then the table entry “monthly daikin energy” gets repopulated with a massive entry:

after a big clean up of the STATES, STATISTICS and STATISTICS_SHORT_TERM tables and flattening of the stats, i set the STATE to 710.
This lasted till the next statistic run, wherby it shot back up to 3360874 kWh
I’m getting pretty pissed at this

STATE last_updated_ts
710	1699884264.22125
710	1699885134.23229
710	1699886469.22737
3360874.001	1699890145.04994
799	1699890210.35863
3360874.101	1699890423.38152