evcc icon indicating copy to clipboard operation
evcc copied to clipboard

Fix wrong data in history after #30950

Open klrth opened this issue 5 months ago • 3 comments

Describe the bug

It seems I experienced #30950 which left some wild data in my history.

Image

Is there a way to clean that up?

Regards klrth

Steps to reproduce

  1. 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

klrth avatar Jun 22 '26 16:06 klrth

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.

naltatis avatar Jun 22 '26 16:06 naltatis

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).

Image

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;

Image

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)

Image

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

Image

klrth avatar Jun 22 '26 17:06 klrth

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"

Image

Hope that helps.

poozu avatar Jun 23 '26 13:06 poozu