evcc icon indicating copy to clipboard operation
evcc copied to clipboard

Still incorrect calculation of the total generated PV output in the history (see also issue #33602)

Open TeutoRockA opened this issue 3 months ago • 5 comments

Describe the bug

Here is the trace log

evcc-20260822-145015-trace.log

and the required screenshots of the configuration

Image Image Image

Steps to reproduce

  1. issue #33062

Configuration details

[main  ] INFO 2026/08/22 15:36:09 config file not found, database-only mode
[main  ] INFO 2026/08/22 15:36:09 using sqlite database: /var/lib/evcc/evcc.db?_pragma=busy_timeout(5000)&_pragma=foreign_keys(1)&_pragma=auto_vacuum(INCREMENTAL)
[eebus ] INFO 2026/08/22 15:36:13 Local SKI: c21ee3af18035ed563ee6efdd8ff9cca6215c658

Version: `0.314.2`

Log details

see log file provided

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

evcc version 0.314.2

TeutoRockA avatar Aug 22 '26 13:08 TeutoRockA

Thanks for following up with a trace log. This looks like the same report as #33062 (which was closed for lack of detail) — the underlying question there was never answered, so I still can't confirm a genuine calculation bug versus a device/config issue.

Recap of the code path (assets/js/views/History.vue, groupTotalLabel and entityLegends): the PV tile's total and the per-entity legend values are computed from the exact same seriesByGroup['pv'] data — both just sum slot.energy per entity. A plain summation bug that makes the total diverge from the visible per-entity values is unlikely from code inspection.

The most likely explanation remains device categorization: entities are only included in the PV total if their history entries are stored with group = "pv" (core/metrics/db_history.go). If the Shelly or the Kostal inverter is configured as an additional/aux meter rather than under pv: in evcc.yaml, its energy is still shown correctly as its own tile, but intentionally excluded from the PV group total — that produces exactly "individual values look right, total is too low".

To confirm or rule this out, could you provide as plain text in the issue (not only a screenshot):

  • The pv: / meter section of your evcc.yaml (or the device list from the config UI) showing whether the Shelly and the Kostal inverter are each configured under pv:, or as an additional/aux meter
  • The exact period (day/month/year) from the screenshot, the total evcc shows for the PV tile, and the sum you'd expect from the individual entity values shown in the same screenshot

I wasn't able to fetch/parse the attached trace log or screenshots programmatically in this session, so I can't confirm anything from them directly — the text answers above are what's needed to actually diagnose this.

🤖 Generated with Claude Code

github-actions[bot] avatar Aug 22 '26 13:08 github-actions[bot]

  1. Both Shelly and Kostal are configured under pv:
  2. August 20th, 2026 / Total (German: Erzeugung): 14,0 kWh (incorrect), but Shelly (in my config called "Balkonkraftwerk"): 4,8 kWh and Kostal (in my config called "Dachkraftwerk"): 18,8 kWh >> assumably correct

TeutoRockA avatar Aug 22 '26 13:08 TeutoRockA

Thanks for the plain-text numbers — that's enough to pin this down.

The arithmetic lines up exactly with a real display bug in assets/js/views/History.vue:

  • The PV group total (groupTotalLabel, assets/js/views/History.vue:438-467) sums slot.energy and slot.returnEnergy across all entities first, then computes the net as Math.abs(sumEnergy - sumReturnEnergy).
  • Each entity's legend value (entityLegends, assets/js/views/History.vue:412-425) computes its own net (energy - returnEnergy) per entity and then takes Math.abs(sum) before displaying it.

If one entity's net for the period is negative (i.e. it recorded more returnEnergy than energy — this happens whenever a PV meter is read via power integration and briefly reports negative power, e.g. core/metrics/accumulator.go's AddPower routes negative readings into ReturnEnergy), the per-entity legend shows a positive number (its magnitude), while the group total still sums the signed value, so that entity effectively subtracts from the total instead of adding to it.

This matches your numbers precisely: 18.8 − 4.8 = 14.0, i.e. if "Balkonkraftwerk" (Shelly) had a negative net for Aug 20 (net = ‑4.8 kWh, e.g. because the Shelly is wired at a point that also sees standby/house consumption), the legend would still show 4.8 kWh (its absolute value) while the total correctly nets it against the Kostal's 18.8 kWh, landing on 14.0 kWh — exactly what you're seeing.

So: the per-entity legend numbers and the group total are computed consistently in terms of underlying data, but the legend silently drops the sign via Math.abs(), making it look like the total should be the sum of the two positive-looking legend numbers when it isn't. This looks like a genuine, fixable frontend bug (the legend should either show the signed value, or an indicator that the entity net was negative for the period), independent of any specific device/config mistake on your side.

🤖 Generated with Claude Code

github-actions[bot] avatar Aug 22 '26 13:08 github-actions[bot]

i configured the shelly in pv as: "Shelly 1PM, EM, Plug S, Pro 3EM in monophase mode" - shall i change it to a new configuration (it is a Plug S) to solve the problem - as the configuration was made in a older version? Or wouldn't that change anything?

TeutoRockA avatar Aug 22 '26 14:08 TeutoRockA

Pls don't double-post

andig avatar Aug 23 '26 10:08 andig