From 3b3fae252d547f395482873994d39dc129bf5ead Mon Sep 17 00:00:00 2001 From: premultiply <4681172+premultiply@users.noreply.github.com> Date: Tue, 25 Mar 2025 08:40:32 +0100 Subject: [PATCH] Amperfied: fix phase switching (#20090) --- charger/amperfied.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/charger/amperfied.go b/charger/amperfied.go index 80115ecec..53b1c8c8c 100644 --- a/charger/amperfied.go +++ b/charger/amperfied.go @@ -35,6 +35,7 @@ type Amperfied struct { log *util.Logger conn *modbus.Connection current uint16 + phases int wakeup bool } @@ -346,6 +347,8 @@ func (wb *Amperfied) phases1p3p(phases int) error { b := make([]byte, 2) binary.BigEndian.PutUint16(b, uint16(phases)) + wb.phases = phases + _, err := wb.conn.WriteMultipleRegisters(ampRegPhaseSwitchControl, 1, b) return err } @@ -357,5 +360,10 @@ func (wb *Amperfied) getPhases() (int, error) { return 0, err } - return int(binary.BigEndian.Uint16(b)), nil + phases := int(binary.BigEndian.Uint16(b)) + if phases == 0 { + return wb.phases, nil + } + + return phases, nil }