Entity to sum heat pump power consumption

Hello folks,

I have a heatpump which delivers tons of information to Home Assistant. The problem however is to sum all energy it consumed. It delivers this information to HA but problem is that each time heatpump restarts (power failure or whatever) then the counter goes back to 0 and start measuring from 0. Graph below explains it exactly.

So there is entity called “energy consumption” but whenever heatpump has power cut and restarts this value goes back to 0.

Question is - how to make another entity which based on that entity will sum consumed energry regardless of sudden drops to 0 because of power failure or restart.

Another problem is that this entity reports it’s value wrong - what it reports as 1000 kWh is actually 100 kWh but this is easly fixable. If I create this new entity mentioned above it will just divide source data by 10. You can see that consumption showed on graph is absurd - it’s because decimal place is shifted. But main question remains - how to sum this in another entity even though it occasionally drops to 0.

And being in the topic of decimal place shifted - I have another devices like Tuya WIFI socket with current measurement. Many of them has same issue reporting current or voltage with decimal place shifted resulting in showing voltage as 2300V for example. Is there any simple way to fix that within the entity itself or does it requires creating another entity which takes data from source entity and devides this data by 10?