How to fix inproper energy consumption from Shelly

Hi community,

I’m using several Shelly pm to measure energy consumption. Lately I noticed a strange bug which caused total energy consumption to skyrocket, from 40 kWh to 15.000 on one device and another from from 71 kWh to 21.000 kWh, all within one day. The data is actually sent wrong by my Shelly device, so the Shelly Home Assistant integration is not doing something wrong by showing the numbers as they are received.
Shelly has no way to correct the internal numbers, other than completely reseting them to 0.

For my energy monitoring I need the proper value from before the big jump. What is the best way to solve this issue?
I thought about creating a template helper for the sensor to apply an negative offset. But this means the sensor helper will have only data from the time I create it. Already gathered data and consumption from past years will be lost.
Or is there a way to offset a sensor from a integration without creating a new sensor? So offseting the original one, which is used in energy dashboard etc?

Or any suggestion how to solve the issue?

Thanks for your help.
Best regards,

Ynnus