ChargeX: fix phase state reg type (#27199)
This commit is contained in:
parent
42c588fd3f
commit
0fd07134be
1 changed files with 5 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue