evcc icon indicating copy to clipboard operation
evcc copied to clipboard

Vaillant: report energy per circuit (heating vs. hot water)

Open Johannes-del opened this issue 3 months ago • 7 comments

Problem

Two Vaillant chargers on the same myVaillant system (one for hot water, one with zone: for the heating circuit) report the same power to both loadpoints. charger/vaillant.go decorates the meter with the MPC sum over all devices of the system (#17994), which has no notion of circuits. Every kWh gets counted twice, and the prioritizer credits one loadpoint with the other's consumption.

A 0 W dummy meter on the heating loadpoint (the workaround suggested in #32535) stops the double counting, but then heating sits at 0 kWh forever and hot water absorbs the entire heat pump consumption:

evcc for 2026-08-20: 2.58 kWh hot water, 0 kWh heating. myVaillant app, same day: 1.6 kWh hot water plus 1.1 kWh heating.

What I'd like

myVaillant does report electrical energy per circuit. That is where the app's own split comes from: /emf/v2/{systemId}/devices/{uuid}/buckets with operationMode=HEATING|DOMESTIC_HOT_WATER and energyType=CONSUMED_ELECTRICAL_ENERGY, summed over heat pump and backup heater. sensonet already wraps it (GetEnergyData, device list via GetDeviceData), evcc just never calls it. Decorating the charger with api.MeterEnergy (HEATING when zone is configured, DOMESTIC_HOT_WATER otherwise) would give each loadpoint its real energy, since evcc prefers meter totals over power integration.

I ran this outside evcc first, as loadpoint meters fed by a small local service reading those buckets. It matches the app to within rounding. Three things I hit doing that:

  • Power stays system-wide, there is no per-circuit power. Only the energy side can be fixed this way.
  • Buckets are hourly and get revised downwards occasionally. The total has to be accumulated monotonically, otherwise SetEnergyMeterTotal re-anchors to the lower value and books the same energy again on the way back up.
  • Standby (~12 W here) appears in no bucket, so both circuits together stay slightly below the system total. The app has the same gap.

evcc 0.314.0. Happy to send a PR if you want this.

Johannes-del avatar Aug 20 '26 15:08 Johannes-del

Investigated charger/vaillant.go — this matches the report.

The meter decorator added in #17994 does exactly what's described:

if devices, _ := conn.GetMpcData(systemId); len(devices) > 0 {
    implement.Has(res, implement.Meter(util.Cached(func() (float64, error) {
        res, err := conn.GetMpcData(systemId)
        return lo.SumBy(res, func(d sensonet.MpcDevice) float64 {
            return d.CurrentPower
        }), err
    }, cc.Cache)))
}

It sums CurrentPower over the whole MPC device tree of the myVaillant system, with no concept of circuits (heating zone vs. DHW). When two vaillant chargers are configured against the same system, both get the identical system-wide value, so the same consumption is booked twice. This is a design limitation from when power reading was first added, not a regression — there is no per-circuit split anywhere in the current code.

The proposed fix (decorating with api.MeterEnergy fed from sensonet's per-circuit /emf/.../buckets energy data, split by operationMode) sounds like a reasonable way to give each loadpoint its own energy total, given evcc prefers meter totals over power integration when available. I can't verify the exact sensonet wrapper API surface (GetEnergyData/GetDeviceData) from here, and the monotonic-accumulation handling for revised/backdated buckets adds real complexity, so this needs implementation against real hardware/API responses to get right — not something to attempt blind.

Marking as heating since this is heat-pump/circuit specific. Happy to see a PR for this given you've already validated the approach externally.

🤖 Generated with Claude Code

github-actions[bot] avatar Aug 20 '26 16:08 github-actions[bot]

Both open points are covered.

sensonet (v0.0.7, the version in go.mod) already has what is needed, and evcc references neither function today:

  • GetEnergyData(systemId, deviceUuid, operationMode, energyType, resolution, startDate, endDate) in connection.go:165, on ENERGY_URL = /emf/v2/%s/devices/%s/buckets?. The response carries TotalConsumption, so one query per circuit is enough.
  • GetDeviceData(systemId, whichDevices) in connection.go:136, on DEVICES_URL = /emf/v2/%s/currentSystem, for the device UUIDs.

One catch: currentSystem lists more than one emf device. Here it returns the aroTHERM plus (HEATPUMP) and the hydraulic station (ELECTRIC_AUXILIARY_HEATER), both exposing CONSUMED_ELECTRICAL_ENERGY for HEATING and DOMESTIC_HOT_WATER, and both have to be summed. For 2026-08-20 that gives 1.60 kWh DHW and 1.07 kWh heating against the app's 1.6 and 1.1.

The monotonic accumulation is less work than it looks: poll HOUR buckets from local midnight, keep a persistent counter, add only max(0, sum - lastSum), and on a day rollover pull the previous day's final sum once before starting the new day. It does matter though, since SetEnergyMeterTotal skips a decrease but re-anchors the baseline to it, so a bucket revised downwards would be booked twice on the way back up.

Two details for an implementation: DAY buckets use UTC boundaries while HOUR buckets come back in local time, so HOUR is what matches the app's day, and the current hour is already populated, so a 5 minute poll is plenty.

Running as loadpoint meters here since yesterday, both loadpoints report charge: power ✓ energy ✓ with totals matching the app.

Johannes-del avatar Aug 20 '26 16:08 Johannes-del

A logfile or PR would help. Somehow this needs a device selector.

andig avatar Aug 20 '26 17:08 andig

On the device selector: I don't think it needs to be user-facing. Here is what /emf/v2/{systemId}/currentSystem returns for this system, condensed (UUIDs shortened):

aroTHERM plus       HEATPUMP                    26f3d3ec-…   CONSUMED_ELECTRICAL_ENERGY: HEATING, DOMESTIC_HOT_WATER
Hydraulic station   ELECTRIC_AUXILIARY_HEATER   385b6899-…   CONSUMED_ELECTRICAL_ENERGY: HEATING, DOMESTIC_HOT_WATER

Both devices report both operation modes, and the app's per-circuit figures are the sum over both (heat pump plus backup heater). So the selection the charger has to make is the operationMode, not the device: HEATING when zone: is configured, DOMESTIC_HOT_WATER otherwise, then sum CONSUMED_ELECTRICAL_ENERGY over every device in currentSystem that offers that mode. No config option needed, the split follows from what the charger already knows.

On the logfile: an evcc trace won't show anything useful here, evcc never calls the emf endpoints. What I can provide instead is the redacted currentSystem device list above and a raw buckets response sample. The sample has to wait until the call-volume quota resets here (around Aug 24), I'll attach it then.

Happy to build the PR on that basis: decorate with api.MeterEnergy, operationMode derived from the zone: config, sum over the devices offering that mode, monotonic accumulation against revised buckets, and a conservative poll interval.

Johannes-del avatar Aug 21 '26 08:08 Johannes-del

The monotonic accumulation is less work than it looks: poll HOUR buckets from local midnight, keep a persistent counter, add only max(0, sum - lastSum), and on a day rollover pull the previous day's final sum once before starting the new day.

That doesn't sound feasible. If the meter doesn't provide an actual total we won't implement this.

andig avatar Aug 21 '26 08:08 andig

The meter does provide a total. The buckets response carries a top-level totalConsumption for the queried range, and sensonet already exposes it as EnergyData.TotalConsumption, returned by GetEnergyData. With a fixed startDate and resolution=MONTH, one call per device gives an absolute counter, not something evcc has to accumulate.

The paragraph you quoted describes my external service, which asks only for the current day and therefore has to carry the counter itself. That was implementation detail from my side, not a requirement for evcc, and I shouldn't have put it in the issue.

What is left is summing heat pump and backup heater, two absolute values, one call each per circuit.

I'll post a raw response so you can see the field instead of taking my word for it. The emf endpoints here are locked by the API's call-volume quota until around Aug 24, I'll attach it then.

Johannes-del avatar Aug 21 '26 09:08 Johannes-del

Pls read our AI policy.

andig avatar Aug 21 '26 10:08 andig