Amperfied: fix phase switching (#20090)

This commit is contained in:
premultiply 2025-03-25 08:40:32 +01:00 • committed by GitHub
parent 74bf6c8a5e
commit 3b3fae252d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

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