All energy data lost?

I collected proud statistics over my power consumption over the past months. I used “sensor.kWh” that was exposed by my Emporia Vue Utility Connect.

Today I got solar so I changed the the grid entity to “sensor.kWh_consumed” and the Return to Grid to “sensor.kWh_returned” *that was previously unused).

Now I shockingly see all my previous energy data is gone!!

Is there a way to get it back?

Prior to version 2022.10.0, renaming an entity would effectively dissociate the renamed entity from its long-term statistics (i.e. such as energy data). See the comment in the following post:

In version 2022.10.0, the following enhancement was designed to preserve the entity’s long-term statistics.

If you are using a recent version of Home Assistant, renamed the entity via the UI, and it still failed to preserve long-term statistics, report it as an Issue in the GitHub Core repository.

Thank you!
I am not sure if I understand correctly – I actually did not rename anything. I just changed the entity that I use for “Grid Consumption”.

I am on 2022.12, so the patch should work.

Or are you suggesting renaming “sensor.kwh” to “sensor.kwh_old_unsed” and “sensor.kwh_consumed” to “sensor.kwh” and use it for “Grid Consumption”?

EDIT: Let me clarify further: The Vue Utility Connect in its normal configuration provided a sensor “sensor.kwh”. Since this doesn’t perfectly capture the consumption when power is sent back to the grid, there is an alternative configuration for solar. In this config, it provides “sensor.kwh”, “sensor.kwh_consumed” and “sensor.kwh_returned”. In my understanding, the latter two should be used now.

My apologies, I misread your post and thought you had renamed sensor.kwh.

From what I read… changing from one entity to another indeed does not retain the history. Or did you add the new entity next to the ‘old’ one? If you only have one sensor now, then you can try to retrieve the history via the db, i.e. copy from old to new entity.