Replace Energy meter, keep statistics

So a couple of weeks ago i had a lightning strike at my house.
Lot’s of equipment was destroyed among a couple of energy meters.

One of them was my solar system energy meter.
So the meter was not long in place at all (around 3 months).

So what i did using some node-red and sql data, is copy the statistics from the old meter to the new one.

But this resulted in a big spike in data at the time of replacing the sensor. The counter value went from 695 kWh to 0.

What i figured would fix the problem would be to re calculate the sum values, so that the new meter would start at 0, and the sum counter values of the previous values would just be nagative.

This results in shifting the problem to the beginning of measurement. I now have a big negative energy delivery for one of my solar systems on the start date:

How would be my best approach to resolve this ?

I’ve solved this.

Turns out all you need to do is do a correction of meter statistic in the development panel.
If you adjust the statistic that has the large step, it will solve all the issues.

Dear Jammie,

May I ask you how you managed to do the data copy with node-red and sql ?
I have a similar situation after replacing a sensor (new entity names).
Did you install and add-on to export and reimport data ?
Thank you in advance.

Sorry i don’t have the flow anymore.

But i used SQL commands and some python math to do it.