From 102330cb89c95434c56ebe8f55fd632e9f462da6 Mon Sep 17 00:00:00 2001 From: Andreas Richter Date: Sun, 28 Apr 2024 17:26:26 +0200 Subject: [PATCH] Keba: fixes to api.PhaseGetter - Fixes register read length of kebaRegPhaseState to 32 bits. - This register holds the state of the external contactor ( 2 x normally open), which is used to switch between 1 phase and 3 phases. If this register holds a zero, only one phase is active. If it holds a one, three phases are active. --- charger/keba-modbus.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/charger/keba-modbus.go b/charger/keba-modbus.go index 4aef317455..d868b26a99 100644 --- a/charger/keba-modbus.go +++ b/charger/keba-modbus.go @@ -287,12 +287,14 @@ func (wb *Keba) phases1p3p(phases int) error { // getPhases implements the api.PhaseGetter interface func (wb *Keba) getPhases() (int, error) { - b, err := wb.conn.ReadHoldingRegisters(kebaRegPhaseState, 1) + b, err := wb.conn.ReadHoldingRegisters(kebaRegPhaseState, 2) if err != nil { return 0, err } - - return int(binary.BigEndian.Uint16(b)), nil + if binary.BigEndian.Uint32(b) == 0 { + return 1, nil + } + return 3, nil } var _ api.Diagnosis = (*Keba)(nil)