diff --git a/templates/definition/vehicle/teslafi.yaml b/templates/definition/vehicle/teslafi.yaml new file mode 100644 index 000000000..04dd9a8c6 --- /dev/null +++ b/templates/definition/vehicle/teslafi.yaml @@ -0,0 +1,46 @@ +template: teslafi +products: + - description: + generic: TeslaFi +group: generic +requirements: + description: + en: Connect your Tesla using the TeslaFi API. TeslaFi is a Tesla data logging service that provides HTTP API access to vehicle data. Get your API key from your TeslaFi account settings. + de: Verbinden Sie Ihr Tesla-Fahrzeug über die TeslaFi-API. TeslaFi ist ein Tesla-Datenlogger-Service, der HTTP-API-Zugriff auf Fahrzeugdaten bietet. Holen Sie sich Ihren API-Schlüssel aus den TeslaFi-Kontoeinstellungen. +params: + - preset: vehicle-common + - name: apikey + required: true + - name: vin + advanced: true +render: | + type: custom + {{- include "vehicle-common" . }} + {{- define "teslafi_source" }} + source: http + uri: https://www.teslafi.com/feed.php?command=lastGood{{ if .vin }}&vin={{ .vin }}{{ end }} + headers: + Authorization: Bearer {{ .apikey }} + cache: 10s + {{- end }} + soc: + {{- include "teslafi_source" . | indent 2 }} + jq: .battery_level + status: + source: combined + plugged: + {{- include "teslafi_source" . | indent 4 }} + jq: (.charger_phases != null and (.charger_phases | tonumber) >= 1) + charging: + {{- include "teslafi_source" . | indent 4 }} + jq: .charging_state == "Charging" + range: + {{- include "teslafi_source" . | indent 2 }} + jq: (.battery_range | tonumber) * 1.60934 + odometer: + {{- include "teslafi_source" . | indent 2 }} + jq: (.odometer | tonumber) * 1.60934 + limitsoc: + {{- include "teslafi_source" . | indent 2 }} + jq: .charge_limit_soc + features: ["coarsecurrent"]