Get old Sensor Data to new Sensor

Hi,

i have a new Sensor for my currently Power.
I had an old one, named: sensor.smartmeter_consumption

I renamed it to sensor.smartmeter_consumption_old and the new one to the old name sensor.smartmeter_consumption but i didnt get any old data from that…?

I was doing it last year also and there it was working without problems.
How to get the data right now than? :confused:

I dont want to loose all the historical data of two years… the new sensor works but just with data from now

The behavior changed in 2023.4:
https://github.com/home-assistant/core/pull/89963

I believe the new procedure would be (but I have not tested it):

  1. Rename old sensor to the name of the intended new sensor (or leave as-is if you’re replacing a sensor)
  2. Delete the old sensor
  3. Restart HA
  4. Delete the dead sensor entities. This will leave history data as long as you don’t go into dev tools / stats and “fix” the orphaned data. So don’t do that.
  5. Add your new sensor with the new intended name

In your case, you’ll first have to delete your new sensor and remove the entities (and probably even “fix” the orphaned data, which will delete the day or two of data you recorded with your new sensor). Then you can start the process outlined above.

If you don’t want to lose the day or two of data, you can go into the database and mess around with it, but that is complicated and I wouldn’t know how to do it.

1 Like

So, if i will name the new sensor as the same old sensor that named sensor.smartmeter_consumption, than i can just delete the old one and change the entity_id to the same name?

But i mean, thats exactly the same way like before or not?

sensor.smartmeter_consumption is the entity_id that i want to use and that was also the old name of my old sensor

Because (since 2023.4) the historical data follows along with a sensor rename, that means all your historical data should currently be attached to the name sensor.smartmeter_consumption_old. You can check that by going to dev tools, the statistics tab, and searching for that entity name. If you find it, definitely DO NOT “fix issue” because that will delete the data.

To utilize that data, you need to rename a sensor to that same name. So you need a working sensor and you’ll need to rename it to sensor.smartmeter_consumption_old.

Okay, understand!

So i need change the name back from sensor.smartmeter_consumption_old to sensor.smartmeter_consumption and than delete the sensor and change the new sensor to sensor.smartmeter_consumption?

Is that right?
Where do i delete the old sensor? The hole entity?
But the delete button is greyed out…

If you restart HA it should give you the option to delete.