Fix wrong data in history after #30950
Describe the bug
It seems I experienced #30950 which left some wild data in my history.
Is there a way to clean that up?
Regards klrth
Steps to reproduce
- Look in history after #30950
...
Configuration details
Original bug seems to be fixed.
Not relevant.
Log details
Not relevant.
What type of operating system or environment does evcc run on?
Linux
External automation
- [x] I have made sure that no external automation like HomeAssistant or Node-RED is active or accessing any of the mentioned devices when this issue occurs.
Nightly build
- [x] I have verified that the issue is reproducible with the latest nightly build
Version
No response
The history feature is still experimental. So broken/wrong data can happen. The only way to fix is right now is on db level: stop evcc, fix energy-value in meters table (sqlite db), start evcc. We may include some kind of basic trimming/editing in the future, but it's not high on our list right now.
This is how I fixed the data in the history.
In the history find the day with the wrong data and export the CSV. In the CSV find the incorrect data entry and note the meter name in row 1 (pv.Dachanlage...) and the wrong value (723765).
I use the Raspberry version, so first I need the sqlite cli tool.
sudo apt update && sudo apt install -y sqlite3
Stop evcc and open the database with the command line tool
systemctl stop evcc
sqlite3 /var/lib/evcc/evcc.db
In the command line tool look for the entity id of the problematic meter, mine is 4.
sqlite> select * from entities;
From the meters table find the problematic entry (value in table is a float, divide value in CSV by 1000)
sqlite> select * from meters where meter = 4 and energy = 723.765;
Note the timestamp (1781049600)
Now fix the data
sqlite> update meters set energy=0.0 where meter = 4 and ts = 1781049600;
Repeat as necessary. Exit sqlite3 cli. Don't forget to restart evcc.
systemctl start evcc
Done
Looks a lot better now
Inspired by @klrth I also corrected my DB. I am running evcc on a Synology NAS. I copied the evcc.db to my WIN PC and used https://sqlitebrowser.org/dl/ to edit the DB. If you open the meters data table and filter column "return_energy" by any value >2 you get all the peaks, can mark all lines and set them at once to "0.0" In the column "energy" you can also filter by values >2, yet here I simply pasted an average value instead of "0.0"
Hope that helps.