Plugin-Daten
AutorMarius H.
Logo
StatusSTABLE
Version1.2.2
Min. LB Version2.0.0
Release Downloadhttps://github.com/marius-hh/LoxBerry-Plugin-TeslaConnect/archive/refs/tags/1.2.2.zip
BeschreibungDieses Plugin stellt eine Verbindung zur Tesla-API her. Über das Plugin können Informationen zu den verwendeten Tesla Produkten abgerufen oder Befehle an die Tesla Produkte gesendet werden. Alle Produkte, welche in der Tesla App (Android oder iPhone) angezeigt werden können abgefragt werden.
SprachenEN
Diskussionhttps://www.loxforum.com/forum/projektforen/loxberry/plugins/339382-neues-plugin-teslaconnect

TeslaConnect

Version History...


Warnung

Dieses Plugin speichert ein Token, um auf die Tesla API zuzugreifen. Ich empfehle das Plugin nur zu installieren, wenn der Loxberry gut geschützt und nicht direkt aus dem Internet erreichbar ist.

Gelingt es jemand dieses Token auszulesen, kann dieser alle Informationen über das Fahrzeug abrufen und Befehle an das Fahrzeug senden.

Download

Direkter Download-Link: Siehe Tabelle oben

Letzter Entwicklungsstand im Repo: https://github.com/marius-hh/LoxBerry-Plugin-TeslaConnect

Funktion des Plugins

Beim ersten Öffnen des Plugins muss die Anmeldung bei Tesla durchgeführt werden. Dazu wird bei Tesla ein Token generiert. Das Token wird anschliessend automatisch verlängert. Nach erfolgreicher Anmeldung werden möglichen Abfragen aufgelistet, welche am Miniserver als Virtuelle Ausgänge definiert werden können.

Alle Daten werden per MQTT übertragen. Die Subscription dafür lautet teslaconnect/# und wird im MQTT Gateway Plugin automatisch eingetragen.

Aktuell sind folgende Abfragen und Befehle möglich:

Allgemein

Befehl Beschreibung
STATUS Status of the Tesla API.
PRODUCT_LIST Returns all products including vehicles, powerwalls, and energy sites.
VEHICLES Returns a list of all vehicle registered for the authenticated user.

Abfragen für Fahrzeug

Befehl Beschreibung
VEHICLE_SUMMARY Summary information of the vehicle.
VEHICLE_DATA All information and states of the vehicle.
CHARGE_STATE Charge state information including battery limit, charge miles, charge voltage, charge phases, current, charge management, and battery heater status.
CLIMATE_STATE Climate settings including seats, vents battery, steering wheel, and preconditioning state.
CLOSURES_STATE
DRIVE_STATE Drive state including latitude, longitude, and heading of the vehicle.
GUI_SETTINGS GUI settings of the car, such as unit format and range display
LOCATION_DATA
VEHICLE_CONFIG Vehicle configuration information including model, color, badging and wheels
VEHICLE_STATE Vehicle state, such as which doors are open, tpms pressure

Befehle für Fahrzeug

Befehl Beschreibung
WAKE_UP Wakes up the vehicle from a sleeping state.
REMOTE_START_DRIVE Enables keyless driving. There is a two minute window after issuing the command to start driving the car.
DOOR_UNLOCK Unlocks the doors to the vehicle.
DOOR_LOCK Locks the doors to the vehicle.
SUN_ROOF_CONTROL Controls the panoramic sunroof on the Model S.
WINDOW_CONTROL Controls the windows. Will vent or close all windows simultaneously.
ACTUATE_TRUNK Opens or close either the front or rear trunk.
HONK_HORN Honks the horn of the vehicle once.
FLASH_LIGHTS Flashes the headlights once.
AUTO_CONDITIONING_START Start the climate control (HVAC) system. Will cool or heat automatically, depending on set temperature.
AUTO_CONDITIONING_STOP Stop the climate control (HVAC) system.
SET_PRECONDITIONING_MAX Toggles the climate controls between Max Defrost and the previous setting.
REMOTE_SEAT_HEATER_REQUEST Sets the specified seat's heater level.
REMOTE_STEERING_WHEEL_HEATER_REQUEST Turn steering wheel heater on or off.
SET_TEMPS Sets the target temperature for the climate control (HVAC) system. (e.g. value 20)
CHARGE_PORT_DOOR_OPEN Opens the charge port or unlocks the cable.
CHARGE_PORT_DOOR_CLOSE Closes the charge port.
CHARGE_START If the car is plugged in but not currently charging, this will start it charging.
CHARGE_STOP If the car is currently charging, this will stop it.
CHARGE_STANDARD Set vehicle to standard charge limit or ~90%.
CHARGE_MAX_RANGE Set the vehicle to max charge limit.
SET_CHARGE_LIMIT Set the vehicle to defined charge limit. (e.g. value 80)
SET_CHARGING_AMPS Sets the charge amps limit to a custom value. (e.g. value 16)
SET_SCHEDULED_DEPARTURE Set the scheduled departure.
SET_SCHEDULED_CHARGING Set the scheduled charge.
SET_VALET_MODE Activates or deactivates Valet Mode.
RESET_VALET_PIN Clears the currently set PIN for Valet Mode when deactivated. A new PIN will be required when activating from the car screen.
SET_SENTRY_MODE Turns sentry mode on or off.

Abfragen für Powerwall

Befehl Beschreibung
LIVE_STATUS Retrieves current system information (e.g. solar production, grid export/import, home consumption, etc.).
SITE_INFO Retrieves general system information.
SITE_STATUS Retrieves general system information.
SITE_PROGRAMS Retrieves energy site program information.
SITE_TARIFF_RATE Retrieves the user defined Utility Rate Plan used for Time-Based Control mode. It looks like this endpoint is updated every 30 minutes.

Installation

  1. Installation des Plugin MQTT Gateway. Sollte dieses bereits auf dem Loxberry installiert sein, kann dieser Punkt übersprungen werden.
  2. Installation des Plugins über die Plugin Verwaltung.

Konfigurationsoptionen

Aktuell gibt es keine Konfigurationsoptionen im Plugin.

Einrichtung in der Loxone Config Software

Unter den Queries werden die zu verwendenden URLs dargestellt. Sämtliche Funktionen müssen von Loxone aus getriggert werden. Als Vorbereitung für alle weiteren Anleitungen wird ein Virtueller Ausgang benötigt. Die Antwort des Abrufs wird immer per MQTT übertragen. Öffne zum Prüfen der Daten die Incoming Overview im MQTT Gateway Plugin. Bitte folge der Anleitung des MQTT Gateway Plugins, wie du diese Daten in den Loxone Miniserver bekommst.

Diese müssen in der Loxone Config als Virtuelle Ausgänge definiert werden. Wenn diese Ausgänge getriggert werden, führt das Plugin die gewünschte Funktion aus. Der Aufruf der virtuellen Ausgänge kann über die Standard Bausteine von Loxone erfolgen.

Erstelle zuerst einen Virtuellen Ausgang:

http://<user>:<pass>@192.168.20.21

Als nächstes erstelle pro Befehl ein Virtueller Ausgang Befehl:

/admin/plugins/teslaconnect/tesla_command.php?action=wake_up&vid=<vehicle-id>

Zum Abrufen der gesamten Fahrzeugdaten kann folgender Befehl erstellt werden.

/admin/plugins/teslaconnect/tesla_command.php?action=vehicle_data&vid=<vehicle-id>

Die Daten werden nur abgerufen, wenn das Fahrzeug online ist. Soll das Fahrzeug auch abgefragt werden, wenn das Fahrzeug nicht online ist, kann der Parameter force=true hinzugefügt werden. Dann wird das Fahrzeug geweckt und anschliessend die Abfrage gestartet.

/admin/plugins/teslaconnect/tesla_command.php?action=vehicle_data&vid=<vehicle-id>&force=true

In der folgenden Tabelle werden Parameter aufgeführt, welche bei jeder Abfrage übertragen werden.

Parameter Beschreibung Beispieldaten
teslaconnect_mqtt_timestamp Zeitstempel der letzten Übertragung über MQTT in Loxonezeit 422377202
teslaconnect_token_expires Zeitstempel, wann das Token abläuft in Loxonezeit 422398802
teslaconnect_token_valid Ausgabe, ob das aktuelle Teslatoken noch gültig ist

1=gültig, 0=ungültig
1

Roadmap

Dieses Plugin ist im frühen Entwicklungsstand. Ich verwende das Plugin nur zum Befehle an das Auto zusenden, wie z.B. Ladeklappe öffnen, Vorklimatisierung, usw. Ich freue mich, falls jemand Ideen hat und das Projekt weiter mit entwickeln möchte.

Weitere Entwicklungsschritte könnten beispielsweise folgende sein: 

  • Nur die Befehle anzeigen, welche für den Fahrzeugtyp (Model 3, Model S, Model X) zulässig sind
  • Automatische XML Erstellung für Loxone
  • Powerwall aufnehmen

Fragen stellen und Fehler melden