From 82add3a58fb23f237fe4e80eddd7ea00e7e08a6b Mon Sep 17 00:00:00 2001 From: FraBoCH <19388397+FraBoCH@users.noreply.github.com> Date: Sun, 30 Jun 2024 12:22:21 +0200 Subject: [PATCH] Tesla: allow customizing the command proxy (#14616) --- templates/definition/vehicle/tesla.yaml | 7 +++++++ vehicle/tesla.go | 18 ++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/templates/definition/vehicle/tesla.yaml b/templates/definition/vehicle/tesla.yaml index afd25a12b..82c2a838b 100644 --- a/templates/definition/vehicle/tesla.yaml +++ b/templates/definition/vehicle/tesla.yaml @@ -31,6 +31,12 @@ params: advanced: true - name: control deprecated: true + - name: commandProxy + default: https://tesla.evcc.io/ + advanced: true + help: + en: "When using a TWC3 (or other 'dumb' charger not capable of control), evcc can manage the charge directly by communicating with the vehicle through a Command Proxy. By default, the proxy provided by evcc is used. With this parameter, you set the base URL of a custom Command Proxy to use instead of the default evcc one. See for example https://github.com/wimaha/TeslaBleHttpProxy for a proxy sending commands via bluetooth." + de: "Bei Verwendung eines TWC3 (oder eines anderen 'dummen' Ladegeräts, das nicht steuerbar ist) kann evcc die Ladung direkt verwalten, indem es über einen Command Proxy mit dem Fahrzeug kommuniziert. Standardmäßig wird der von evcc bereitgestellte Proxy verwendet. Dieses parameter setzt die Basis-URL eines benutzerdefinierten Command Proxy, der anstelle des standardmäßigen evcc-Proxy verwendet werden soll. Siehe zum Beispiel https://github.com/wimaha/TeslaBleHttpProxy für einen Proxy, der Kommandos über Bluetooth sendet." - preset: vehicle-identify render: | type: tesla @@ -38,6 +44,7 @@ render: | tokens: access: {{ .accessToken }} refresh: {{ .refreshToken }} + commandProxy: {{ .commandProxy }} {{ include "vehicle-common" . }} {{ include "vehicle-identify" . }} features: ["coarsecurrent"] diff --git a/vehicle/tesla.go b/vehicle/tesla.go index 8e1076275..9bdb4dbff 100644 --- a/vehicle/tesla.go +++ b/vehicle/tesla.go @@ -37,14 +37,16 @@ func init() { // NewTeslaFromConfig creates a new vehicle func NewTeslaFromConfig(other map[string]interface{}) (api.Vehicle, error) { cc := struct { - embed `mapstructure:",squash"` - Tokens Tokens - VIN string - Timeout time.Duration - Cache time.Duration + embed `mapstructure:",squash"` + Tokens Tokens + VIN string + CommandProxy string + Cache time.Duration + Timeout time.Duration }{ - Timeout: request.Timeout, - Cache: interval, + CommandProxy: tesla.ProxyBaseUrl, + Cache: interval, + Timeout: request.Timeout, } if err := util.DecodeOther(other, &cc); err != nil { @@ -107,7 +109,7 @@ func NewTeslaFromConfig(other map[string]interface{}) (api.Vehicle, error) { if err != nil { return nil, err } - tcc.SetBaseUrl(tesla.ProxyBaseUrl) + tcc.SetBaseUrl(cc.CommandProxy) v := &Tesla{ embed: &cc.embed,