Strange behavior when changing unit_of_measurement on Statistics

It seems that Home Assistant behaves strangely when you change the unit_of_measurement of a statistics sensor.

Here is the experiment I conducted:

Last night, in an integration I use to monitor my home’s energy consumption, I changed the unit_of_measurement for a sensor from kilowatts to watts. Then I restarted the integration, but without restarting Home Assistant.

In the states table, I could see this change.

entity_id	state	last_changed	unit_of_measurement
sensor.linky_easf01	72789.04688	2/7/2026 23:20	kWh
sensor.linky_easf01	72789.07031	2/7/2026 23:21	kWh
sensor.linky_easf01	72789.08594	2/7/2026 23:22	kWh
sensor.linky_easf01	72789.10938	2/7/2026 23:23	kWh
sensor.linky_easf01	unavailable	2/7/2026 23:23	kWh
sensor.linky_easf01	72789120	2/7/2026 23:24	Wh
sensor.linky_easf01	72789144	2/7/2026 23:24	Wh
sensor.linky_easf01	72789168	2/7/2026 23:25	Wh
sensor.linky_easf01	72789184	2/7/2026 23:26	Wh
sensor.linky_easf01	72789208	2/7/2026 23:27	Wh
sensor.linky_easf01	72789224	2/7/2026 23:28	Wh
sensor.linky_easf01	72789248	2/7/2026 23:29	Wh

We can see that at 23:23:44 the sensor becomes unavailable and the unit of measurement changes from kWh to Wh. Then at 23:24:01 the sensor value becomes available again and is multiplied by 1000. So far, the behavior seems logical in relation to the modification I made to the sensor.

Now, if I look at the statistics tables, I see that practically nothing has changed. In the statistics_meta table, there is no new entry with the same name and a different unit_of_measurement?

And if we look at the statistics_short_term table, practically nothing changed except that from 23:20:00 onwards, the sensor accuracy changes, which seems to indicate that Home Assistant is automatically converting the sensor values from Wh to kWh???

statistic_id	period_start	state	sum
sensor.linky_easf01	2/7/2026 23:05	72788.80469	883.484375
sensor.linky_easf01	2/7/2026 23:10	72788.90625	883.5859375
sensor.linky_easf01	2/7/2026 23:15	72789.01563	883.6953125
sensor.linky_easf01	2/7/2026 23:20	72789.144	883.8236875
sensor.linky_easf01	2/7/2026 23:25	72789.248	883.9276875
sensor.linky_easf01	2/7/2026 23:30	72789.344	884.0236875
sensor.linky_easf01	2/7/2026 23:35	72789.448	884.1276875
sensor.linky_easf01	2/7/2026 23:40	72789.552	884.2316875

Next test
This morning, I restarted Home Assistant to test what is happening after a reboot. The first surprise was that before the restart, the values were correctly displayed in Wh but after restart in kWh ???

entity_id	state	last_changed	unit_of_measurement
sensor.linky_easf01	72813296	2/8/2026 8:56	Wh
sensor.linky_easf01	72813368	2/8/2026 8:56	Wh
sensor.linky_easf01	72813440	2/8/2026 8:57	Wh
sensor.linky_easf01	72813520	2/8/2026 8:59	Wh
sensor.linky_easf01	unavailable	2/8/2026 9:00	kWh
sensor.linky_easf01	72813.6	2/8/2026 9:00	kWh
sensor.linky_easf01	72813.68	2/8/2026 9:00	kWh
sensor.linky_easf01	72813.768	2/8/2026 9:02	kWh
sensor.linky_easf01	72813.848	2/8/2026 9:02	kWh

We can see that at 09:00:35 (time of reboot), the sensor became unavailable and, then inexplicably, its unit of measurement reverted to kWh. And at 09:00:36, the sensor becomes available again and reverted back to recording the values in kWh, even though the integration continues to provide the data in Wh ???

I don’t understand why Home Assistant, when it receives information from a sensor in Wh, decides on its own to convert this data into kWh. What is this decision based on?

Now, if I look at the statistics_short_term table, it continues to behave as if nothing has changed. It continues, like the states table, to record information with the wrong old unit of measurement ???

statistic_id	period_start	state	sum
sensor.linky_easf01	2/8/2026 8:50	72813.216	907.8956875
sensor.linky_easf01	2/8/2026 8:55	72813.52	908.1996875
sensor.linky_easf01	2/8/2026 9:00	72813.928	908.6076875
sensor.linky_easf01	2/8/2026 9:05	72814.312	908.9916875
sensor.linky_easf01	2/8/2026 9:10	72814.704	909.3836875

As for the statistics, a new entry used to be created in the statistics_meta table with a different unit of measurement. The recording of the sensor with the old unit of measurement was stopped, and the recording of the sensor with the new unit of measurement was taking over.

I would like to know if there is a description somewhere of how Home Assistant behaves when the unit of measurement is changed? Are there any documents somewhere in the Home Assistant documentation that describe these behavioral changes?

Note that I chose a unit change that is easy to convert because it only requires multiplying by 1000, but what happens if the unit of measurement is changed from degrees Celsius to degrees Fahrenheit?