ABL eMH: force re-enable outlet (#17950)

This commit is contained in:
premultiply 2025-01-07 10:56:05 +01:00 • committed by GitHub
parent d78d4bda02
commit a24b8b89f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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.
@ -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)