ChargeX: fix phase state reg type (#27199)

This commit is contained in:
premultiply 2026-02-03 14:22:40 +01:00 • committed by GitHub
parent 42c588fd3f
commit 0fd07134be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -120,7 +120,7 @@ func (wb *ChargeX) setCurrent(current float64) error {
return err
}
state := binary.BigEndian.Uint16(b)
state := binary.BigEndian.Uint32(b)
// Bit 1: ChMode - 0=single phase, 1=3 phase
phases := 3
if (state & (1 << 1)) == 0 {
@ -128,7 +128,10 @@ func (wb *ChargeX) setCurrent(current float64) error {
}
b = make([]byte, 4)
binary.BigEndian.PutUint32(b, uint32(230*current*float64(phases)))
targetPower := uint32(230 * current * float64(phases))
binary.BigEndian.PutUint32(b, targetPower)
wb.log.DEBUG.Printf("set charge power: %dW (%.1fA, %dp)", targetPower, current, phases)
_, err = wb.conn.WriteMultipleRegisters(chargexRegTargetPower, 2, b)
return err