I was having a heck of a time trying to delete the long term stats (LTS) data for a sensor. I thought by deleting the sensor it would also delete the LTS but ithe data stayed persistent. Keep in mind this is because f you create the sensor again and it give it the same entity ID it will pull that entity ID’s history from the database. this is kind of a really cool feature if you don’t want to delete your LTS, but you want to recreate the sensor. if you do want to delete the sensor and its LTS this was really annoying as I had a very bad reading on one of my Heater Sensors that was a Utility Meter. I was using this meter to figure out how much it was costing us in the energy dashboard. I saw a spike of 1300kWh in a short period of time and then on the energy dashboard it was shown outrageous amount in the cost field. Editing this sensor using the developer > statistics tools it did not seem to work properly. all the statistics reported in there other than one were correct. I corrected the one wrong read but the history kept showing 1300+ kWh used. So after looking all over the internet with no real answers I decided to dive into the database and found a way to manually remove the data and wanted to share incase others wanted to do the same!
I would love to hear some feedback if I missed anything or if anything was not clear!
PS obligatory warning about editing databases if you don’t know what you’re doing. BACK UP FIRST! you have been warned.