Replacing Grid Consumption Sensor without Losing Data

I’ve been using the Energy Dashboard for over two years and already have a lot of historical data.

Currently, I’m using the Toon Smartmeter integration (configured via configuration.yaml).

Later this month, my electricity, gas, and water meters will be replaced with digital ones.
As a result, I won’t be able to use the Toon Smartmeter integration anymore and will switch to a Smartgateway P1 meter.

This means I’ll get entirely new entities, and the Toon Smartmeter integration will be removed.

However, this also means I will lose all my historical data from the Toon Smartmeter integration.

It should be possible to retain the data in the Energy Dashboard, even after removing the original entities.

Also lost some historical data due to this missing feature

So I have had old device that ended with 30000kwh, now new one started on 0.
My meter changed and also I need new device to read it.
How do I continue in HA so it adds new value to old ones?
As Going from 300000 to 1 would make it think it is export of 30000kWh or something.

I am currently using a CircuitSetup EM programmed through ESPHome but I would like to swap over to an Emporia Vue 3 also programmed through ESPHome. What would be the best way to swap over while maintaining historical data?