Remove dedicated Audi type, replace with eTron (#8547) (BC)
This commit is contained in:
parent
2687f0b3ba
commit
cf1234a6a6
6 changed files with 36 additions and 153 deletions
|
|
@ -1,14 +0,0 @@
|
|||
template: etron
|
||||
products:
|
||||
- brand: Audi
|
||||
description:
|
||||
generic: e-tron
|
||||
params:
|
||||
- preset: vehicle-base
|
||||
- preset: vehicle-identify
|
||||
- name: vin
|
||||
example: WAUZZZ...
|
||||
render: |
|
||||
type: etron
|
||||
{{ include "vehicle-base" . }}
|
||||
{{ include "vehicle-identify" . }}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
template: audi
|
||||
covers: ["etron"]
|
||||
products:
|
||||
- brand: Audi
|
||||
description:
|
||||
generic: legacy
|
||||
params:
|
||||
- preset: vehicle-base
|
||||
- preset: vehicle-identify
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
product:
|
||||
brand: Audi
|
||||
description: legacy
|
||||
render:
|
||||
- default: |
|
||||
type: template
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
product:
|
||||
brand: Audi
|
||||
description: e-tron
|
||||
render:
|
||||
- default: |
|
||||
type: template
|
||||
template: etron
|
||||
title: # Wird in der Benutzeroberfläche angezeigt (Optional)
|
||||
user: # Benutzerkonto (bspw. E-Mail Adresse, User Id, etc.)
|
||||
password: # Passwort des Benutzerkontos (bei führenden Nullen bitte in einfache Hochkommata setzen)
|
||||
vin: WAUZZZ... # Erforderlich, wenn mehrere Fahrzeuge des Herstellers vorhanden sind (Optional)
|
||||
capacity: 50 # Akkukapazität in kWh (Optional)
|
||||
advanced: |
|
||||
type: template
|
||||
template: etron
|
||||
title: # Wird in der Benutzeroberfläche angezeigt (Optional)
|
||||
user: # Benutzerkonto (bspw. E-Mail Adresse, User Id, etc.)
|
||||
password: # Passwort des Benutzerkontos (bei führenden Nullen bitte in einfache Hochkommata setzen)
|
||||
vin: WAUZZZ... # Erforderlich, wenn mehrere Fahrzeuge des Herstellers vorhanden sind (Optional)
|
||||
capacity: 50 # Akkukapazität in kWh (Optional)
|
||||
phases: 3 # Die maximale Anzahl der Phasen welche genutzt werden können (Optional)
|
||||
icon: car # Icon in der Benutzeroberfläche (Optional)
|
||||
cache: 15m # Zeitintervall nach dem Daten erneut vom Fahrzeug abgefragt werden (Optional)
|
||||
mode: # Möglich sind Off, Now, MinPV und PV, oder leer wenn keiner definiert werden soll (Optional)
|
||||
minSoc: 25 # Ladung mit maximaler Geschwindigkeit bis zu dem angegeben Ladestand unabhängig PV-Erzeugung, wenn der Lademodus nicht auf 'Aus' steht (Optional)
|
||||
targetSoc: 80 # Bis zu welchem Ladestand (Soc) soll das Fahrzeug geladen werden (Optional)
|
||||
minCurrent: 6 # Definiert die minimale Stromstärke pro angeschlossener Phase mit welcher das Fahrzeug geladen werden soll (Optional)
|
||||
maxCurrent: 16 # Definiert die maximale Stromstärke pro angeschlossener Phase mit welcher das Fahrzeug geladen werden soll (Optional)
|
||||
identifiers: # Kann meist erst später eingetragen werden, siehe: https://docs.evcc.io/docs/guides/vehicles/#erkennung-des-fahrzeugs-an-der-wallbox (Optional)
|
||||
priority: # Priorität des Ladepunktes oder Fahrzeugs in Relation zu anderen Ladepunkten oder Fahrzeugen für die Zuweisung von PV-Energie (Optional)
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
package vehicle
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/evcc-io/evcc/api"
|
||||
"github.com/evcc-io/evcc/util"
|
||||
"github.com/evcc-io/evcc/util/request"
|
||||
"github.com/evcc-io/evcc/vehicle/audi/etron"
|
||||
"github.com/evcc-io/evcc/vehicle/vag/idkproxy"
|
||||
"github.com/evcc-io/evcc/vehicle/vag/service"
|
||||
"github.com/evcc-io/evcc/vehicle/vag/vwidentity"
|
||||
"github.com/evcc-io/evcc/vehicle/vw/id"
|
||||
)
|
||||
|
||||
// https://github.com/TA2k/ioBroker.vw-connect
|
||||
// https://github.com/arjenvrh/audi_connect_ha/blob/master/custom_components/audiconnect/audi_services.py
|
||||
|
||||
// Etron is an api.Vehicle implementation for Audi eTron cars
|
||||
type Etron struct {
|
||||
*embed
|
||||
*id.Provider // provides the api implementations
|
||||
}
|
||||
|
||||
func init() {
|
||||
registry.Add("etron", NewEtronFromConfig)
|
||||
}
|
||||
|
||||
// NewEtronFromConfig creates a new vehicle
|
||||
func NewEtronFromConfig(other map[string]interface{}) (api.Vehicle, error) {
|
||||
cc := struct {
|
||||
embed `mapstructure:",squash"`
|
||||
User, Password, VIN string
|
||||
Cache time.Duration
|
||||
Timeout time.Duration
|
||||
}{
|
||||
Cache: interval,
|
||||
Timeout: request.Timeout,
|
||||
}
|
||||
|
||||
if err := util.DecodeOther(other, &cc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if cc.User == "" || cc.Password == "" {
|
||||
return nil, api.ErrMissingCredentials
|
||||
}
|
||||
|
||||
v := &Etron{
|
||||
embed: &cc.embed,
|
||||
}
|
||||
|
||||
log := util.NewLogger("etron").Redact(cc.User, cc.Password, cc.VIN)
|
||||
|
||||
// get initial VW identity id_token
|
||||
q, err := vwidentity.Login(log, etron.AuthParams, cc.User, cc.Password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// exchange initial VW identity id_token for Audi AAZS token
|
||||
idk := idkproxy.New(log, etron.IDKParams)
|
||||
ats, its, err := service.AAZSTokenSource(log, idk, etron.AZSConfig, q)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// use the etron API for list of vehicles
|
||||
api := etron.NewAPI(log, ats)
|
||||
|
||||
vehicle, err := ensureVehicleEx(
|
||||
cc.VIN, func() ([]etron.Vehicle, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), cc.Timeout)
|
||||
defer cancel()
|
||||
return api.Vehicles(ctx)
|
||||
},
|
||||
func(v etron.Vehicle) string {
|
||||
return v.VIN
|
||||
},
|
||||
)
|
||||
|
||||
if err == nil {
|
||||
if v.Title_ == "" {
|
||||
v.Title_ = vehicle.Nickname
|
||||
}
|
||||
|
||||
api := id.NewAPI(log, its)
|
||||
api.Client.Timeout = cc.Timeout
|
||||
|
||||
v.Provider = id.NewProvider(api, vehicle.VIN, cc.Cache)
|
||||
}
|
||||
|
||||
return v, err
|
||||
}
|
||||
|
|
@ -1,28 +1,31 @@
|
|||
package vehicle
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/evcc-io/evcc/api"
|
||||
"github.com/evcc-io/evcc/util"
|
||||
"github.com/evcc-io/evcc/util/request"
|
||||
"github.com/evcc-io/evcc/vehicle/audi"
|
||||
"github.com/evcc-io/evcc/vehicle/audi/etron"
|
||||
"github.com/evcc-io/evcc/vehicle/vag/idkproxy"
|
||||
"github.com/evcc-io/evcc/vehicle/vag/service"
|
||||
"github.com/evcc-io/evcc/vehicle/vw"
|
||||
"github.com/evcc-io/evcc/vehicle/vag/vwidentity"
|
||||
"github.com/evcc-io/evcc/vehicle/vw/id"
|
||||
)
|
||||
|
||||
// https://github.com/davidgiga1993/AudiAPI
|
||||
// https://github.com/TA2k/ioBroker.vw-connect
|
||||
// https://github.com/arjenvrh/audi_connect_ha/blob/master/custom_components/audiconnect/audi_services.py
|
||||
|
||||
// Audi is an api.Vehicle implementation for Audi cars
|
||||
type Audi struct {
|
||||
*embed
|
||||
*vw.Provider // provides the api implementations
|
||||
*id.Provider // provides the api implementations
|
||||
}
|
||||
|
||||
func init() {
|
||||
registry.Add("audi", NewAudiFromConfig)
|
||||
registry.Add("etron", NewAudiFromConfig)
|
||||
}
|
||||
|
||||
// NewAudiFromConfig creates a new vehicle
|
||||
|
|
@ -51,21 +54,42 @@ func NewAudiFromConfig(other map[string]interface{}) (api.Vehicle, error) {
|
|||
|
||||
log := util.NewLogger("audi").Redact(cc.User, cc.Password, cc.VIN)
|
||||
|
||||
idk := idkproxy.New(log, audi.IDKParams)
|
||||
ts, err := service.MbbTokenSource(log, idk, audi.AuthClientID, audi.AuthParams, cc.User, cc.Password)
|
||||
// get initial VW identity id_token
|
||||
q, err := vwidentity.Login(log, etron.AuthParams, cc.User, cc.Password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
api := vw.NewAPI(log, ts, audi.Brand, audi.Country)
|
||||
api.Client.Timeout = cc.Timeout
|
||||
// exchange initial VW identity id_token for Audi AAZS token
|
||||
idk := idkproxy.New(log, etron.IDKParams)
|
||||
ats, its, err := service.AAZSTokenSource(log, idk, etron.AZSConfig, q)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cc.VIN, err = ensureVehicle(cc.VIN, api.Vehicles)
|
||||
// use the etron API for list of vehicles
|
||||
api := etron.NewAPI(log, ats)
|
||||
|
||||
vehicle, err := ensureVehicleEx(
|
||||
cc.VIN, func() ([]etron.Vehicle, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), cc.Timeout)
|
||||
defer cancel()
|
||||
return api.Vehicles(ctx)
|
||||
},
|
||||
func(v etron.Vehicle) string {
|
||||
return v.VIN
|
||||
},
|
||||
)
|
||||
|
||||
if err == nil {
|
||||
if err = api.HomeRegion(cc.VIN); err == nil {
|
||||
v.Provider = vw.NewProvider(api, cc.VIN, cc.Cache)
|
||||
if v.Title_ == "" {
|
||||
v.Title_ = vehicle.Nickname
|
||||
}
|
||||
|
||||
api := id.NewAPI(log, its)
|
||||
api.Client.Timeout = cc.Timeout
|
||||
|
||||
v.Provider = id.NewProvider(api, vehicle.VIN, cc.Cache)
|
||||
}
|
||||
|
||||
return v, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue