Fiat: add wake up (requires pin) (#21463)

This commit is contained in:
drfisheye 2025-05-29 09:49:10 +02:00 • committed by GitHub
parent 02d3a362b2
commit 5d355f5f00
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 5 deletions

View file

@ -9,13 +9,13 @@ params:
- name: pin
mask: true
help:
en: Required for evcc to refresh the SoC while charging. When connected to TWC3, used to start/stop charging.
de: Benötigt zur Aktualisierung des Ladestands während der Ladung. Bei Nutzung mit TWC3 kann der Ladevorgang mittels PIN gestartet und gestoppt werden.
en: Required for evcc to wake up the vehicle for charging and to refresh the SoC while charging. When connected to TWC3, used to start/stop charging.
de: Benötigt um das Fahrzeug zum Laden aufzuwecken and zur Aktualisierung des Ladestands während der Ladung. Bei Nutzung mit TWC3 kann der Ladevorgang mittels PIN gestartet und gestoppt werden.
- preset: vehicle-features
render: |
type: fiat
{{ include "vehicle-base" . }}
{{- if .pin }}
pin: {{ .pin }} # mandatory to deep refresh Soc & start/stop charge
pin: {{ .pin }} # mandatory to wake up, deep refresh Soc & start/stop charge
{{- end }}
{{ include "vehicle-features" . }}

View file

@ -60,7 +60,7 @@ func NewFiatFromConfig(other map[string]interface{}) (api.Vehicle, error) {
if err == nil {
v.Provider = fiat.NewProvider(api, cc.VIN, cc.PIN, cc.Expiry, cc.Cache)
v.Controller = fiat.NewController(v.Provider, api, cc.VIN, cc.PIN)
v.Controller = fiat.NewController(v.Provider, api, log, cc.VIN, cc.PIN)
}
return v, err

View file

@ -159,6 +159,10 @@ func (v *API) Action(vin, pin, action, cmd string) (ActionResponse, error) {
return res, err
}
func (v *API) ChargeNow(vin, pin string) (ActionResponse, error) {
return v.Action(vin, pin, "ev/chargenow", "CNOW")
}
func (v *API) UpdateSchedule(vin, pin string, schedules []Schedule) (ActionResponse, error) {
var res ActionResponse

View file

@ -5,20 +5,23 @@ import (
"time"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util"
)
type Controller struct {
pvd *Provider
api *API
log *util.Logger
vin string
pin string
}
// NewController creates a vehicle current and charge controller
func NewController(provider *Provider, api *API, vin string, pin string) *Controller {
func NewController(provider *Provider, api *API, log *util.Logger, vin string, pin string) *Controller {
impl := &Controller{
pvd: provider,
api: api,
log: log,
vin: vin,
pin: pin,
}
@ -100,3 +103,19 @@ func (c *Controller) disableConflictingChargeSchedule(schedule *Schedule) {
schedule.EnableScheduleType = false
}
}
var _ api.Resurrector = (*Controller)(nil)
func (c *Controller) WakeUp() error {
if c.pin == "" {
c.log.DEBUG.Printf("Pin needs to be configured to wakeup vehicle")
return nil
}
res, err := c.api.ChargeNow(c.vin, c.pin)
if err == nil && res.ResponseStatus != "pending" {
err = fmt.Errorf("invalid response status: %s", res.ResponseStatus)
}
return err
}