Tesla: API-Details

Du authentifizierst dich mit deinem Tesla-Konto (oAuth) und erlaubst der App, eine Verbindung zu deinem Fahrzeug herzustellen.
Außerdem muss die App im Fahrzeug registriert werden (wie eine Handy-Schlüssel), damit die App Befehle an das Fahrzeug senden kann.

Fahrzeugdaten werden mittels Intervallabrufen ermittelt. Diese Anfragen wecken das Auto nicht auf. Wenn das Auto jedoch schläft oder offline ist, erhält die App keine aktualisierten Daten.

Die Datenabrufe erfolgen über die Tesla Fleet-API.

Um das Fahrzeug zu steuern, werden Befehle an das Fahrzeug gesendet. Dafür sind zwei Varianten vorgesehen:

Fleet-API

Die App sendet einfache https-Anfragen an die Fleet-API. D.h. die App kontaktiert die zentrale Tesla-API (Tesla-Server). Diese leiten die Anfrage an das Fahrzeug weiter.
Die Abfragen sind verschlüsselt (über https/SSL) und authentifiziert (über deine Anmeldung). Allerdings sind diese Aufrufe damit nur je Tesla-Account steuerbar und nicht je Fahrzeug. Deshalb deaktiviert Tesla diese Methode für die meisten Fahrzeugt ab 2024.
S/X-Modelle vor 2021 müssen diese Option nutzen, da sie das neue Command Protokoll nicht unterstützen.

Tesla Vehicle Command Protocol

Die Übertragung erfolgt ebenfalls über die Fleet-API. Allerdings muss dazu die App im anzusprechenden Fahrzeug registriert sein. Ist dies der Fall, dann sendet die App verschlüsselte und signierte Befehle an das Fahrzeug. Wenn die App in im Fahrzeug als Schlüssel registriert ist, werden diese Befehle vom Fahrzeug zugelassen und verarbeitet. Dies ermöglicht eine durchgängige Verschlüsselung und authorisierung auf App-/Fahrzeug-Ebene.

Die App-Berechtigung kann in den Sicherheitseinstellungen des Fahrzeugs entfernt werden. Damit sind keine Kommandos mehr möglich. Datenabrufe können weiterhin erfolgen.

Soll die Homey-App keinerlei Zugriff mehr erhalten (also auch keinen Datenabruf), so kann die App im Tesla-Account entfernt werden. Der über die oAuth-Anmeldung erteilte Authorisierung wird damit ungültig und die App verliert jeglichen Zugriff auf den Account und die zuvor eingebundenen Fahrzeuge.

Abhängig von deiner Rolle (Besitzer/Fahrer) kann der Zugang zu zum Fahrzeug eingeschränkt sein und es ist nicht gestattet, die App im Fahrzeug zu registrieren. Dies kann der Fall sein, wenn die Leasinggesellschaft der Autobesitzer ist. Bitte kontaktiere in diesem Fall das Leasingunternehmen und/oder Tesla.

Verwendung in der Homey-App

Das Tesla Vehicle Command Protocol wird in der App auf zwei Arten vewendet:

  • Als Proxy (aktueller Standard für Kommandos)
    Die App selbst sendet im Fleet-API-Format an einen Proxy-Server. Dieser ergänzt die Verschlüsselung und Signierung und senden das Kommando an die Tesla-API bzw. in Folge an das Fahrzeug. Der Proxy basiert auf einer von Tesla bereitgestellten Entwicklung:
    https://github.com/teslamotors/vehicle-command
  • Als direkte Anbindung (in Entwicklung)
    In dieser noch in der Entwicklung befindlichen Variante verschlüsselt und signiert die Homey-App die Aufrufe selbst und schickt diese an die Tesla-API bzw. in Folge an das Fahrzeug.

4 Antworten zu „Tesla: API-Details“

  1. Stevens

    Hello, first of all thank you for making the new Tesla app for Homey. love it!
    I have 1 issue though. For some reason, when I want to set the charging power to for example 10A using a flow. It sets my charging power to 0A. Doesn’t matter what charging power I choose, it always sets it to 0A. Is there any way I can fix this? Thank you!

    1. Using the “Command Proxy” connection setting in car device settings will work.
      The “Command Protocol” is not finished yet.

  2. Rechter

    Hello Ronny,
    First of all, I like to thank you for this amazing and useful app.
    As I bought my Tesla a few weeks ago, I’m still looking around. It seems it is possible to set the charge power of the car by the Homey app. So, that should mean I can create a flow that if the power of my solar panels exceeds a certain level (e.g. 2.000 W), my Tesla starts charging on a low level (e.g. 2A). Do I understand correct?
    If so, does this also work when I use a ‘third party charger’ (e.g. Zaptec, Alfen, etc.), that normally ‘manage’ the charging level? And can the ‘load balancing’ function, provided as a ‘add on’ by many brands be replaced by Homey flows?
    Thanks in advance for your response!

    1. Hello, if I read your question correctly, you don’t have a Homey yet?
      For general questions, I recommend the community: https://community.homey.app/
      Feel free to ask further questions in this thread: https://community.homey.app/t/app-pro-tesla/100824
      You need a HomeyPro for the app – and that only makes sense if you also plan to use HomeyPro for your SmartHome. That would be a bit too exaggerated just for one app 😉

      Now to your questions…
      1) Yes, you can control the car’s charging power via the app and specify ampere values (like in the Tesla app).
      2) You can start and stop charging.

      It’s the same as controlling it in the Tesla app. This works independently of the wallbox. For example, the wallbox supplies 3x16A and you set the car to 6A, then the car charges with 3x6A.
      But if you have a controllable wallbox that is linked to the PV system, then that would be the simplest solution. The inverter then controls the power of the wallbox.
      For simple non-controllable wallboxes, controlling them via the car would be an alternative.

      I’m not sure what is meant by “load balancing”. If you mean controlling the charging power, then yes.
      With Homey it is also possible to control the charging of the car based on dynamic electricity tariffs, e.g. starting at the cheapest tariff. This would then have to be controlled via other Homey apps (e.g. Tibber) or individually via AdvancedFlows.

      Small addition: You can also react to events, e.g.:
      – When the charging cable is connected
      – Then set to xx amps
      – And start charging

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert