Skip to content

Commit

Permalink
ABL eMH: force re-enable outlet (#17950)
Browse files Browse the repository at this point in the history
  • Loading branch information
premultiply authored Jan 7, 2025
1 parent d78d4bd commit a24b8b8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions charger/abl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package charger
// LICENSE

// Copyright (c) 2019-2022 andig
// Copyright (c) 2022 premultiply
// Copyright (c) 2022-2024 premultiply

// This module is NOT covered by the MIT license. All rights reserved.

Expand Down Expand Up @@ -157,15 +157,20 @@ func (wb *ABLeMH) Status() (api.ChargeStatus, error) {
return api.StatusNone, err
}

r := rune(b[1]>>4-0x0A) + 'A'
s := string(rune((b[1]>>4)-0x0A) + 'A')

switch r {
case 'A', 'B', 'C':
return api.ChargeStatus(r), nil
switch s {
case "A", "B", "C":
return api.ChargeStatusString(s)
default:
// ensure Outlet is re-enabled after wake-up
if b[1] == 0xE0 { // Outlet is disabled
return api.StatusB, wb.set(ablRegModifyState, 0xA1A1)
}

status, ok := ablStatus[b[1]]
if !ok {
status = string(r)
status = s
}

return api.StatusNone, fmt.Errorf("invalid status: %s", status)
Expand Down

0 comments on commit a24b8b8

Please sign in to comment.