From 82cb1ff27a6390200e683aea03bfcf114fea2112 Mon Sep 17 00:00:00 2001 From: Timo Tomasini Date: Sun, 17 Aug 2025 13:46:37 +0200 Subject: [PATCH] Zaptec: add passive mode for externally managed load distribution systems (#23023) --- charger/zaptec.go | 14 ++++++++++++-- templates/definition/charger/zaptec.yaml | 10 ++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/charger/zaptec.go b/charger/zaptec.go index 073593008..b73738208 100644 --- a/charger/zaptec.go +++ b/charger/zaptec.go @@ -48,6 +48,7 @@ type Zaptec struct { version int enabled bool priority bool + passive bool } func init() { @@ -62,6 +63,7 @@ func NewZaptecFromConfig(ctx context.Context, other map[string]interface{}) (api User, Password string Id string Priority bool + Passive bool Cache time.Duration }{ Cache: time.Second, @@ -75,11 +77,11 @@ func NewZaptecFromConfig(ctx context.Context, other map[string]interface{}) (api return nil, api.ErrMissingCredentials } - return NewZaptec(ctx, cc.User, cc.Password, cc.Id, cc.Priority, cc.Cache) + return NewZaptec(ctx, cc.User, cc.Password, cc.Id, cc.Priority, cc.Passive, cc.Cache) } // NewZaptec creates Zaptec charger -func NewZaptec(ctx context.Context, user, password, id string, priority bool, cache time.Duration) (api.Charger, error) { +func NewZaptec(ctx context.Context, user, password, id string, priority bool, passive bool, cache time.Duration) (api.Charger, error) { log := util.NewLogger("zaptec").Redact(user, password) if !sponsor.IsAuthorized() { @@ -90,6 +92,7 @@ func NewZaptec(ctx context.Context, user, password, id string, priority bool, ca Helper: request.NewHelper(log), log: log, priority: priority, + passive: passive, } // setup cached values @@ -235,6 +238,13 @@ func (c *Zaptec) Enable(enable bool) error { } func (c *Zaptec) chargerUpdate(data zaptec.Update) error { + if c.passive { + if data.MaxChargeCurrent != nil || data.MinChargeCurrent != nil || data.OfflineChargeCurrent != nil { + c.log.DEBUG.Println("zaptec: passive mode: skipping chargerUpdate with current fields set") + return nil + } + } + uri := fmt.Sprintf("%s/api/chargers/%s/update", zaptec.ApiURL, c.instance.Id) req, _ := request.New(http.MethodPost, uri, request.MarshalJSON(data), request.JSONEncoding) diff --git a/templates/definition/charger/zaptec.yaml b/templates/definition/charger/zaptec.yaml index 84d062805..d536fa0d5 100644 --- a/templates/definition/charger/zaptec.yaml +++ b/templates/definition/charger/zaptec.yaml @@ -19,8 +19,18 @@ params: en: Charger ID - name: user - name: password + - name: passive + type: bool + description: + de: "Passivmodus" + en: "Passive mode" + help: + 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 render: | type: zaptec id: {{ .id }} user: {{ .user }} password: '{{ .password }}' + passive: {{ .passive }}