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 {
|
type Zaptec struct {
|
||||||
*request.Helper
|
*request.Helper
|
||||||
implement.Caps
|
implement.Caps
|
||||||
log *util.Logger
|
log *util.Logger
|
||||||
statusG util.Cacheable[zaptec.StateResponse]
|
statusG util.Cacheable[zaptec.StateResponse]
|
||||||
instance zaptec.Charger
|
instance zaptec.Charger
|
||||||
version int
|
version int
|
||||||
enabled bool
|
enabled bool
|
||||||
priority bool
|
priority bool
|
||||||
passive bool
|
passive bool
|
||||||
lastStatus int
|
startPrevention bool
|
||||||
|
lastStatus int
|
||||||
|
|
||||||
session string // last seen SessionIdentifier
|
session string // last seen SessionIdentifier
|
||||||
sessionStart time.Time // start of the current session
|
sessionStart time.Time // start of the current session
|
||||||
|
|
@ -67,11 +68,12 @@ func init() {
|
||||||
// NewZaptecFromConfig creates a Zaptec Pro charger from generic config
|
// NewZaptecFromConfig creates a Zaptec Pro charger from generic config
|
||||||
func NewZaptecFromConfig(ctx context.Context, other map[string]any) (api.Charger, error) {
|
func NewZaptecFromConfig(ctx context.Context, other map[string]any) (api.Charger, error) {
|
||||||
cc := struct {
|
cc := struct {
|
||||||
User, Password string
|
User, Password string
|
||||||
Id string
|
Id string
|
||||||
Priority bool
|
Priority bool
|
||||||
Passive bool
|
Passive bool
|
||||||
Cache time.Duration
|
Cache time.Duration
|
||||||
|
AutoStartPrevention bool
|
||||||
}{
|
}{
|
||||||
Cache: time.Second,
|
Cache: time.Second,
|
||||||
}
|
}
|
||||||
|
|
@ -84,11 +86,11 @@ func NewZaptecFromConfig(ctx context.Context, other map[string]any) (api.Charger
|
||||||
return nil, api.ErrMissingCredentials
|
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
|
// 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)
|
log := util.NewLogger("zaptec").Redact(user, password)
|
||||||
|
|
||||||
if !sponsor.IsAuthorized() {
|
if !sponsor.IsAuthorized() {
|
||||||
|
|
@ -96,11 +98,12 @@ func NewZaptec(_ context.Context, user, password, id string, priority bool, pass
|
||||||
}
|
}
|
||||||
|
|
||||||
c := &Zaptec{
|
c := &Zaptec{
|
||||||
Helper: request.NewHelper(log),
|
Helper: request.NewHelper(log),
|
||||||
Caps: implement.New(),
|
Caps: implement.New(),
|
||||||
log: log,
|
log: log,
|
||||||
priority: priority,
|
priority: priority,
|
||||||
passive: passive,
|
passive: passive,
|
||||||
|
startPrevention: startPrevention,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add User-Agent header for Zaptec API compliance
|
// 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()
|
currentStatus, err := res.ObservationByID(zaptec.ChargerOperationMode).Int()
|
||||||
if err == nil && currentStatus == zaptec.OpModeDisconnected && currentStatus != c.lastStatus {
|
if err == nil && currentStatus == zaptec.OpModeDisconnected && currentStatus != c.lastStatus {
|
||||||
err = c.MaxCurrentMillis(0)
|
err = c.preventAutoStart()
|
||||||
}
|
}
|
||||||
c.lastStatus = currentStatus
|
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
|
// Enabled implements the api.Charger interface
|
||||||
func (c *Zaptec) Enabled() (bool, error) {
|
func (c *Zaptec) Enabled() (bool, error) {
|
||||||
res, err := c.statusG.Get()
|
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)."
|
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)."
|
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
|
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: |
|
render: |
|
||||||
type: zaptec
|
type: zaptec
|
||||||
id: {{ .id }}
|
id: {{ .id }}
|
||||||
user: {{ .user }}
|
user: {{ .user }}
|
||||||
password: {{ .password }}
|
password: {{ .password }}
|
||||||
passive: {{ .passive }}
|
passive: {{ .passive }}
|
||||||
|
autoStartPrevention: {{ .autoStartPrevention }}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue