yeah that’s what we figured out, rename it to something random which will take the history along with it under that new entity ID then just delete it and leave the records orphaned they’ll get cleaned up over time.
Sorry, see no logic here.
After these actions you will have in DB two sets of data of what you call “orphaned entity”, of course both will be deleted in purge interval. What is a purpose of this?
because sometimes you’re playing around and have a lot of stupid data in your database. then when you finally get it all working you want that old data all cleared up…
Your answer was to “why would I want to delete old history” question - but not to “why would I want to have 2 sets of data to be deleted” ))
I have no idea how we even got here haha. I just wanted to post how to delete statistical data for a utility meter. Better answers were given not sure what others are talking about still. The use I need is solved
This is for who don’t know want edit database.
Editing database it’s not hard after all.
metadata_id
SELECT * FROM "statistics_meta" WHERE statistic_id = 'sensor.eb3a_adc_addon_r'
387 sensor.eb3a_adc_addon_r
check for bad values
SELECT * FROM "statistics" WHERE metadata_id = 387 AND min < 100
remove it
DELETE FROM "statistics" WHERE metadata_id = 387 AND min < 100
state_class: total_increasing. can be fixed from UI in dev tools.
state_class: measurement. only editing DB.
Delete things it’s the last resort to fix wrong values.
In the begin I just delete all DB.
yours is great for a few bad reading, if you want to go full scorched earth. I am in the process of writing a SQL Query to fix these bad records… just subtract the bad value reading from the state in all 3 tables state, statistics, statistics_short_term
In this thread it is claimed that the current behaviour is a bug:
after changing “entity_id” for an entity with “unique_id” a history for this entity should be retained.
Currently it is not retained according to my test.