From 413f184562c514df4364b8fe70fe382f097470d3 Mon Sep 17 00:00:00 2001 From: premultiply <4681172+premultiply@users.noreply.github.com> Date: Thu, 6 Apr 2023 14:19:55 +0200 Subject: [PATCH] Alphatec: workaround status 8 if disabled (#7222) The charger does not allow to detect if a car is plugged or not if it is in disabled state. --- charger/alphatec.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/charger/alphatec.go b/charger/alphatec.go index d82cd7e73..f20549221 100644 --- a/charger/alphatec.go +++ b/charger/alphatec.go @@ -31,7 +31,8 @@ import ( // Alphatec charger implementation type Alphatec struct { - conn *modbus.Connection + conn *modbus.Connection + status api.ChargeStatus } const ( @@ -72,7 +73,8 @@ func NewAlphatec(uri, device, comset string, baudrate int, proto modbus.Protocol conn.Logger(log.TRACE) wb := &Alphatec{ - conn: conn, + conn: conn, + status: api.StatusNone, } return wb, err @@ -93,10 +95,17 @@ func (wb *Alphatec) Status() (api.ChargeStatus, error) { res = api.StatusB case 3: res = api.StatusC + case 8: + res = wb.status + if wb.status == api.StatusC { + res = api.StatusB + } default: return api.StatusNone, fmt.Errorf("invalid status: %d", u) } + wb.status = res + return res, nil }