From 20058f6e0d360c0fcccfb69898ad7c584439a406 Mon Sep 17 00:00:00 2001 From: tbaehler Date: Fri, 21 Aug 2026 08:52:11 +0200 Subject: [PATCH] Zaptec: optional fix for auto-charging (#32996) --- charger/zaptec.go | 53 ++++++++++++++---------- templates/definition/charger/zaptec.yaml | 11 +++++ 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/charger/zaptec.go b/charger/zaptec.go index 423bb0c22..5ca5e1c2e 100644 --- a/charger/zaptec.go +++ b/charger/zaptec.go @@ -47,14 +47,15 @@ const _ZaptecGo2PhaseSwitchCurrent = 32.0 // threshold (in A) at which Zaptec Go type Zaptec struct { *request.Helper implement.Caps - log *util.Logger - statusG util.Cacheable[zaptec.StateResponse] - instance zaptec.Charger - version int - enabled bool - priority bool - passive bool - lastStatus int + log *util.Logger + statusG util.Cacheable[zaptec.StateResponse] + instance zaptec.Charger + version int + enabled bool + priority bool + passive bool + startPrevention bool + lastStatus int session string // last seen SessionIdentifier sessionStart time.Time // start of the current session @@ -67,11 +68,12 @@ func init() { // NewZaptecFromConfig creates a Zaptec Pro charger from generic config func NewZaptecFromConfig(ctx context.Context, other map[string]any) (api.Charger, error) { cc := struct { - User, Password string - Id string - Priority bool - Passive bool - Cache time.Duration + User, Password string + Id string + Priority bool + Passive bool + Cache time.Duration + AutoStartPrevention bool }{ Cache: time.Second, } @@ -84,11 +86,11 @@ func NewZaptecFromConfig(ctx context.Context, other map[string]any) (api.Charger return nil, api.ErrMissingCredentials } - return NewZaptec(ctx, cc.User, cc.Password, cc.Id, cc.Priority, cc.Passive, cc.Cache) + return NewZaptec(ctx, cc.User, cc.Password, cc.Id, cc.Priority, cc.Passive, cc.Cache, cc.AutoStartPrevention) } // NewZaptec creates Zaptec charger -func NewZaptec(_ context.Context, user, password, id string, priority bool, passive bool, cache time.Duration) (api.Charger, error) { +func NewZaptec(_ context.Context, user, password, id string, priority bool, passive bool, cache time.Duration, startPrevention bool) (api.Charger, error) { log := util.NewLogger("zaptec").Redact(user, password) if !sponsor.IsAuthorized() { @@ -96,11 +98,12 @@ func NewZaptec(_ context.Context, user, password, id string, priority bool, pass } c := &Zaptec{ - Helper: request.NewHelper(log), - Caps: implement.New(), - log: log, - priority: priority, - passive: passive, + Helper: request.NewHelper(log), + Caps: implement.New(), + log: log, + priority: priority, + passive: passive, + startPrevention: startPrevention, } // Add User-Agent header for Zaptec API compliance @@ -205,7 +208,7 @@ func (c *Zaptec) Status() (api.ChargeStatus, error) { } currentStatus, err := res.ObservationByID(zaptec.ChargerOperationMode).Int() if err == nil && currentStatus == zaptec.OpModeDisconnected && currentStatus != c.lastStatus { - err = c.MaxCurrentMillis(0) + err = c.preventAutoStart() } c.lastStatus = currentStatus @@ -224,6 +227,14 @@ func (c *Zaptec) Status() (api.ChargeStatus, error) { } } +func (c *Zaptec) preventAutoStart() error { + if !c.startPrevention { + return nil + } + + return c.MaxCurrentMillis(0) +} + // Enabled implements the api.Charger interface func (c *Zaptec) Enabled() (bool, error) { res, err := c.statusG.Get() diff --git a/templates/definition/charger/zaptec.yaml b/templates/definition/charger/zaptec.yaml index 9cedeb842..c68b78274 100644 --- a/templates/definition/charger/zaptec.yaml +++ b/templates/definition/charger/zaptec.yaml @@ -28,9 +28,20 @@ params: de: "evcc erteilt nur Ladefreigaben/Ladesperren (keine Stromregelung). Aktiviere diese Option nur, wenn die Wallbox Teil eines externen Lastmanagement Systems ist und Stromänderungen ablehnt (HTTP 403)." en: "evcc only grants charging authorisations/blocks (no current control). Only activate this option if the wallbox is part of an external load management system and rejects current changes (HTTP 403)." advanced: true + - name: autoStartPrevention + description: + de: Automatischen Ladestart verhindern + en: Prevent automatic charging + help: + de: Verhindert einen automatischen Ladestart beim Einstecken eines Fahrzeugs. Kann die Authorisierung beeinflussen + en: Prevents automatic charging when a vehicle is plugged in. May break auth. + type: bool + advanced: true + default: false render: | type: zaptec id: {{ .id }} user: {{ .user }} password: {{ .password }} passive: {{ .passive }} + autoStartPrevention: {{ .autoStartPrevention }}