I think you can kind of do this by having the same entity name as the original but it would be nice if there was a better way to do this. When I changed the firmware on my VUE 2 to ESPHOME and replaced the sources I did not realize that previous days also lost the statistics from the energy meter entities i had originally.
Maybe there should be an option when you remove a device from the energy dashboard to keep a frozen record of its historical data in the dashboard even if it is removed so the data is not just lost and you can remove the original device and associated entities.
Other systems have a “replace device” button, where you can tell the system that this new device is now the replacement for a currently active one. This also makes it possible to replace a device after one has died, for example…
There’s even a few integrations available from HACS that enable you to do this, in fact, i just used one of them to copy longtime stats from my old pv meter onto the new one.
However, that this scenario is entirely uncovered by HA - after all this time - is incomprehensible (and should be changed - so vote )
I learned the hard way and created a template sensor that just links to the power sensor i have. If i change the power sensor i just update the template sensor
This isn’t only an energy issue. Any entity should be replaceable by another. Sometimes a smart plug or bulb dies and you replace it with another. Going through all the automations, dashboards, etc. to change the ID is a pain.
I “lost” years of energy data this way by replacing my cloud solar inverter integration by the newer local modbus integration.
It would be fantastic if successor entities could be linked.
Lost between quotes because I know it’s still in the database somewhere.
I concur this is useful in a broader context than just energy.
I feel you. I have used three different integrations to monitor my solar installation. I keep the integrations disabled but still there so I wont loose anything. It’s very annoying.
I think they should create some ‘facade’ entities that are part of the core and they just point to wherever entities you configure, that way you can just switch your entities and the facades would still be there.
While not really user friendly, it is possible to switch devices and not loose the history.
LTS data is linked to the enity_id of your energy sensor (or any other type of sensor for which LTS is stored).
So, you need to ensure the new device uses the same entity_id as the old one. To do so, the entity_id has to be available for the new device, so it is important to remove the old device from HA first (by removing it from the integration). You can’t rename the old entity_id, because that will move all LTS to the new entity_id.
This also means you can’t run the old and the new device in parallel, as then they both have data from the same time span, and then they can’t merge the data.
So, these are the steps to move LTS from one device to another:
Make a backup, in case it goes wrong you can always revert to this backup
Note down all entity_id’s from the old device for which LTS should be moved to the new device
Remove the old device in HA
Check in Settings > Tools > States if the old enitty_id’s are no longer shown, and available for the new device
Integrate the new device in HA. It is important not to do this prior to this step, as there can be LTS data in the same period as the existing data you want to move then)
Change the entity_id’s from the new integration to match the old entity_id’s
(optional) After you have confirmed that all is working, and the old data is visible and new data is recorded, you can change the entity_id’s back to how they were provided by the integration, as LTS will be moved to the new entity_id then.
So it is possible to move LTS between devices without having to modify the database records directly, but I agree it is not really user friendly.
For important data (solar, energy from your smart meter, etc) you can also use a template entity. Create a template entity which is basically a copy of the sensor for solar/energy/whatever. Whenever you change a device, you only need to change the template sensor.
However, if you do this when you already have data and you want to merge it into the template sensor, you need to remove the current integration to make sure the same entity id can be use for the template sensor and the data can be merged.
So, I did upvote this request, as it would be very nice if a user-friendly method of merging LTS was available.
I used this one as well when replacing my P1 meter. Works good, but it’s quite risky. So a proper replacement function that transfers the history of an old entity to a new one is definitely a welcome improvement!