I’ve fiddled so much wth this over the last few hours, adding energy support to a third party solar inverter component. Accordingly the data in the graphs is incomplete/garbage. Does anyone know how to clean out the database and effectively start from scratch now that I have it working as it should?
Afaik stop ha. Delete the contents /config/.storage/energy. Start ha.
Seems risky A bit more digging got me to this post…a little further down he explains how to use SQLLite Web to expunge the “dirty” records. Worked a treat
This process worked for me to ninja-delete a specific days worth of data due to a haywire sensor.
Just a nutshell for anyone who might want to take an easier route and simply delete all the energy data of a specific day, this query will work:
DELETE
FROM "statistics"
WHERE "created" like '2021-09-16%'
Of course change the date itself, but leave the % symbol, as it is the wildcard (since the timestamp is always different).
You can delete only a specific sensor instead of a whole day by more closely following the post linked above.
This only deletes the dashboard to start from scratch. The long term statistics will remain and appear again after you add the sensor again.
This seems indeed the solution. If you want to start from scratch delete all rows (truncate) from statistics and statistics_meta. (stop HA before and start after the truncate)
Though… it i hope it does not starts reading from 0kwh now… as it would calculate from a 0kwh meter reading… this is almost never the case for most users…
Oh well… 2 hours wait now
It worked like a charm
Hello ! Sorry to revive this old topic, but it seems to be the right place to ask:
Does this solution force Home Assistant to recompile old data?
I mean, if all data are in the state table, and if I delete the folder and drop the statistics tables, will Home Assistant compile past days’ data? If not, do you know how to force it to do so?
My statistics data are incomplete and/or corrupted, and I want to recompile to start afresh with clean data.
Thanks in advance!