Tesla: allow customizing the command proxy (#14616)

This commit is contained in:
FraBoCH 2024-06-30 12:22:21 +02:00 • committed by GitHub
parent 4d940265ce
commit 82add3a58f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 8 deletions

View file

@ -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"]

View file

@ -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,