Skip to content

Commit

Permalink
ABL: fix detecting enabled state (evcc-io#1815)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Oct 31, 2021
1 parent 7de8729 commit 788fc72
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions charger/abl.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type ABLeMH struct {
const (
ablRegFirmware = 0x01
ablRegStatus = 0x04
ablRegEnabled = 0x0F
ablRegAmpsConfig = 0x14
ablRegStatusLong = 0x2E

Expand Down Expand Up @@ -145,13 +146,13 @@ func (wb *ABLeMH) Status() (api.ChargeStatus, error) {

// Enabled implements the api.Charger interface
func (wb *ABLeMH) Enabled() (bool, error) {
_, _ = wb.conn.ReadHoldingRegisters(ablRegStatusLong, 5)
b, err := wb.conn.ReadHoldingRegisters(ablRegStatusLong, 5)
_, _ = wb.conn.ReadHoldingRegisters(ablRegEnabled, 5)
b, err := wb.conn.ReadHoldingRegisters(ablRegEnabled, 5)
if err != nil {
return false, err
}

u := binary.BigEndian.Uint16(b[2:]) & 0x0FFF
u := binary.BigEndian.Uint16(b[6:]) & 0x0FFF
return u != ablAmpsDisabled, nil
}

Expand Down

0 comments on commit 788fc72

Please sign in to comment.