Skip to content

Commit

Permalink
Tesla: allow customizing the command proxy (#14616)
Browse files Browse the repository at this point in the history
  • Loading branch information
FraBoCH committed Jun 30, 2024
1 parent 4d94026 commit 82add3a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
7 changes: 7 additions & 0 deletions templates/definition/vehicle/tesla.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,20 @@ 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
vin: {{ .vin }}
tokens:
access: {{ .accessToken }}
refresh: {{ .refreshToken }}
commandProxy: {{ .commandProxy }}
{{ include "vehicle-common" . }}
{{ include "vehicle-identify" . }}
features: ["coarsecurrent"]
18 changes: 10 additions & 8 deletions vehicle/tesla.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 82add3a

Please sign in to comment.