Zaptec: optional fix for auto-charging (#32996)
This commit is contained in:
parent
a578893edd
commit
20058f6e0d
2 changed files with 43 additions and 21 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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 }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue