Zaptec: add passive mode for externally managed load distribution systems (#23023)

This commit is contained in:
Timo Tomasini 2025-08-17 13:46:37 +02:00 • committed by GitHub
parent 044164f1a6
commit 82cb1ff27a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 2 deletions

View file

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

View file

@ -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 }}