I recently had a corrupted database which I managed to recover.
However, in the meantime the statistics etc. move on and the old and new database are out of sync.
This is because when Home Assistant recreated the database after it was corrupted all statistic entities got new ID’s.
Is there an existing script or something that can merge the old longterm statistics with the new one?
Basically the following would need to be done:
- Create a new database with all the regular entities and history of the current active (new) database.
- First add all longterm statistics from the recovered (old) database.
- Record by records add the long term statistics from the active (new) database.
- It will nee to create entities on the fly if they do not exist in the old database and also needs to parse the record ID’s to the old database values.
Any ideas/suggestions are very welcome!