WTH: I loose all energy data history if I need to change a energy entity

I as home owner, who is very invested in energy monitoring would want my energy data be persistent within home assistant, so all data stays available, even though a single sensor integration changes, or a sensor needs replacement.

→ Therefore when ever I add a sensor to the energy dashboard as a value providing entity I would want HA, to make a copy of the sensor data that will stay persistent, even though I chose to switch a data providing entity. Once I switch a entity the data of the new entity will be added from that moment on to the persistent data, while the deleted entity data will stay persistent with all data points until to minute it has been deleted from the energy dashboard.

Current behaviour:

  • once something changes (e.g. because I want to switch from a Shelly 3EM for energy monitoring to the smart meter data, all historic data will no longer be available within the energy dashboard.

Because of that I have multiple times lost historic data of our energy production (of our PV system), Gas usage (once switching from the values of our heater to the direct readout of our gas meter), and next big data loss will come, once I now switch to reading out the smart meter directly.

Especially when it comes to energy monitoring historic data is of very high value to be able to make year over year comparisons etc.

From what I can see there are no working solutions for this problem. At least not, if the old entity is still active and working. And even if the old entity is inactive I would see it as quite messy to keep a growing list of old entity’s on the dashboard settings, not being able to disable unused integrations.

I think you have two options here to solve the problem. One is cleaner.

  1. Delete the old entity and rename the new entity to match the old one. HA will automatically fix things so the new entity has all of the old entity’s historical data.
  2. If it was for a single device and not your whole home energy, I believe you can delete the old entity, but leave it in the list for devices and it will continue to use the historical data even though there is no existing entity for new data. I’m not 100% on this, and I think it will be messy regardless.

If you go with route #1, you can then just re-add the Shelly CT and give it a new name to start a new set of statistics for it. Also note that you do not need to keep the weird auto generated entity names. You can make them more generic and describe the function and location rather than the device model, etc. HA will automatically update the recorded history to match the new entity name.

I think it is important to also understand that the energy dashboard uses recorder information primarily. So you just need to keep your recorded data in order and it will work fine.

I have personally lost a bunch of data when I switched from Sense to my actual meter because I did not yet understand how all this stuff worked. Since then I have swapped several smart plugs while maintaining the recorder functional information from one device to the next.

I agree with this WTH

I used this integration once. It worked. But I don’t consider this very user friendly :slight_smile:

1 Like

Using device ids makes a mess and cause these exact situations which is why many on the forum warns users against them.
Using entity ids makes it much easier.

How do you achieve this @richie510 ? I have been trying this approach for the last 3 hours with a Tasmota smart plug and it’s driving me absolutely bananas. I have restored from backups around 8 times to try a different approach and I am confident that what you are suggesting is simply not possible.

I deleted the “old” device (Tasmota smart plug) from HA.
I added the “new” device (Unraid connected UPS) to HA.
I gave the UPS power tracking entity the same entity ID as from the “old” plug.
The energy history is transferred across and the new device is seen in the energy dashboard with all historic data.
BUT: the second I re-add the Tasmota plug, even though I have factory reset it, renamed it etc, it instantly re-pairs itself to that old energy data. So the energy dashboard now shows the plug again, but with a different name. I’m also now seeing some super weird shit in the energy dashboard such as “-950kWh” from the new device, because it’s been reset back down to 0.

Huge PITA and is really making me never want to use HA for energy monitoring again, it simply is not worth the hassle at all. Rather be locked into a vendor like Tuya using their own app, where the data isn’t going to get scrambled for no reason.

That sounds like a device id have been used instead of an entity id.

Your experience does not match my experience. Maybe show us some screenshots. Maybe WallyR is on to something with the device ID stuff. I have never used tasmoda, maybe it has some weird shenanigans going on.

If you get weird spikes in your energy history, you can go to developer tools → statistics and then find the entity with a spike. There is a ramp on the right with an arrow inclined up. If you click “outliers” it may just jump right to the “spike” or you can find it in the date time picker. When you find the spike, you can zero it out.

There are a lot of features here, and some are more complex to use than others. In this case it is inherently complicated due to the flexibility of the data history system. Since you got it to “work” right up until re-adding this Tasmoda device, I think it is worth paying some extra attention to that device and its integration. Is this device particularly valuable to you (don’t need to re-add it at all?)? Maybe if WallyR is right about the device ID there are some database commands you can do to clean it up.

If this is the straw that broke the camels back and has you ditch HA, I would think that HA was never a good fit for you in the first place, and you may be better served by a proprietary vendor with a 1-800 telephone number for support.