Cfos: ignore zero meter readings (#24997)

This commit is contained in:
Marco 2025-11-04 08:24:50 +01:00 • committed by GitHub
parent d6e304f1b9
commit d630fbb578
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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