From d630fbb578935a6c6e5bc9a66da9b3cadb5dcf80 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 4 Nov 2025 08:24:50 +0100 Subject: [PATCH] Cfos: ignore zero meter readings (#24997) --- charger/cfos.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/charger/cfos.go b/charger/cfos.go index ea9ed3b71..c982bb1f0 100644 --- a/charger/cfos.go +++ b/charger/cfos.go @@ -167,7 +167,28 @@ func (wb *CfosPowerBrain) totalEnergy() (float64, error) { return 0, err } - return float64(binary.BigEndian.Uint64(b)) / 1e3, nil + res := float64(binary.BigEndian.Uint64(b)) / 1e3 + + // cfos wallboxes sometimes return 0 erroneously shortly after startup + // to work around this, we retry once more, and if it is still 0, we return ErrMustRetry + // + // this has the drawback with new wallboxes that actually have 0 total energy + // it will return ErrMustRetry until the wallbox has been used + // + // see https://github.com/evcc-io/evcc/discussions/12886 + if res == 0 { + b, err = wb.conn.ReadHoldingRegisters(cfosRegEnergy, 4) + if err != nil { + return 0, err + } + + res = float64(binary.BigEndian.Uint64(b)) / 1e3 + if res == 0 { + return 0, api.ErrMustRetry + } + } + + return res, nil } // currents implements the api.PhaseCurrents interface