Replace solar production senso

Hello,

I want to replace my solar production sensor on the energy dashboard.
but as soon as I do so, my history data isn’t showing up anymore

is there a way to fix this?

of should I just update the statistics table?

  1. Rename existing/old sensor entity_id from sensor.whatever to sensor.whatever_old
  2. Rename your new sensor entity_id to sensor.whatever
  3. Delete sensor.whatever_old if required.

This will ensure continuity of LTS data.

thank you,
I will try this later, for now my new sensor seems to be a little unstable, I need to fix that first.

unfortunately, that didn’t work for me, entities are stored with an id which doesn’t change.
If you remove an entity and replace it it might gets the same id which fixes the issue.

however. I ran this sql and all data is preserved

Delete from statistics where metadata_id = 258
update statistics set metadata_id = 258 where metadata_id = 41

Delete from statistics_short_term where metadata_id = 258
update  statistics_short_term set metadata_id = 258 where metadata_id = 41
 

I’m only a little concerned now for the next hour because an adjustment will be applied, around 100kWh.

i think, the “primary key” is not the id, but the entity name.
when you want to replace an entity, just delete it. All data in statistics table remain.
Then create your new entity with same name. The entity id in statistics table will not change, the history will remain and continue with new source.

Proposed solution with renaming works only, when you rename entity in config. This will create a new entity.