The current situation is unsatisfactory. I have integrated the sensors from my inverter. I now want to replace the sensor for grid import/export with a reading head that sits directly on my meter. I no longer need the old entities, but I can’t replace them because then I would lose the statistics. If I rename the entities, it just leads to total chaos. Then the entity names no longer match the devices, and who is supposed to make sense of it all in the end?What has long been overdue is that the statistical values for the Energy Dashboard are not 1:1 tied to the sensors. Instead, the sensors should write their values into an additional separate storage area, where they remain even if you later delete the sensor or replace it with another sensor that measures the same thing
I also couldn’t understand why there isn’t a built-in way to do this yet, so I created a custom HACS component that solves exactly this problem: HA Merge Sensor History.
It migrates both the raw states and the long-term statistics (the data used by the Energy Dashboard) from your old entity to your new one, right from the Home Assistant UI.
Quick overview of what it does:
- Sidebar Panel: Adds a “Merge History” UI where you just select your Source and Destination entities.
- Safe: It uses atomic database transactions (if anything fails, it fully rolls back) and only imports data older than the destination’s oldest record, so you never get duplicates.
- Bulk Import: If you’re replacing a whole system (like moving away from Ecowitt) and have dozens of sensors, you can paste a comma/tab-separated list to migrate them all at once.
You can grab it via HACS Custom Repositories (https://github.com/mayerwin/HA-Merge-Sensor-History). Just remember to make a database backup before doing any migrations!