Custom_integration statistics problem

I have a problem with the development of a custom integration.
There was already a modbus yaml script to read out a Lambda heat pump, but unfortunately almost all sensors are created with state_clase:total, which is wrong for a temperature sensor, for example, it should be “measurement”.
old solution:

- name: EU08L_Boil1_actual_high_temperature
address: 2002
input_type: holding
unit_of_measurement: "°C"
state_class: total
scale: 0. 1
precision: 1
data_type: int16 

Now I write an integration and define the sensors correctly

"EU08L_Boil1_actual_high_temperature": {
"relative_address": 2002,
"name": "Actual High Temperature",
"unit": "°C",
"scale": 0.1,
"precision": 1,
"data_type": "int16",
"firmware_version": 1,
"device_type": "boil",
"writeable": False,
"state_class": "total",
} 

and lose the long-term statistics.
Is there any way around this?
Are there database scripts that I can use to migrate the statistics?

If the state class was wrong, the old statistics are useless for measurements because they are stored as deltas for state class total. But why didn’t you just change the state class in the yaml, and why didn’t you fix it in your new integration?It still says total.

if I set the state_class to total in the new integration, the user gets a warning in the logs that the state_class is configured incorrectly. Home assistant then reports all temperature, power, volume flow, etc. sensors.

““Entity sensor.eu08l_boil1_actual_high_temperature (<class ‘custom_components.lambda_heat_pumps.sensor.LambdaSensor’>) is using state class ‘total’ which is impossible considering device class (‘temperature’) it is using; expected None or one of ‘measurement’””

Use measurement not total, it makes no sense for a temperature to have a value of total.