Editing long term statistics in HA (such as temperature)

I’ve moved my main DB over to MariaDB, and I wanted to edit an incorrect temperature reading.
In the main interface you can edit some stats by going to Home / Dev Tools / Statistics, and then clicking on the ski ramp icon on the right - but not all statistics.

To fix my one odd measurement I searched for a simple answer and couldn’t find one, so here is mine for anyone else.

Note, this assumes you’re using MariaDB and it’s working fine.

Before playing with the database I strongly advising doing a full backup.

  1. Install phpMyadmin admin & configure as per the many other use guides (Home Assistant Community Add-on: phpMyAdmin)
  2. Go to phpMyadmin and click on homeassistant/statistics_meta - This will show you your entities, and their related tag used in the database.
  3. Click on Search - in the menu bar at the top
  4. Enter the entity ID you need to fix (you can get this from developertools / states) in ‘statistics_id’
  5. Look for the id in the results - you need this for the next step
  6. Go to the statistics part of the database (using menu on the left)
  7. Click on search (menu at the top)
  8. Enter the ID into ‘metadata_id’ you found in step 5, hit ‘Go’.
  9. You’ll now have all entries in the database for that entity
  10. Click edit next to the incorrect entry + enter correct details
  11. Click ‘Go’ - you should be sorted.

I hope this helps someone else

That is not all of the story, for recent data, at some point data from statistics_short_term kick in and disrupt the above

Yep, this is specifically for long term stats.