Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

iOS Widget for TeslaFi/Teslamate/TeslaLogger via Scriptable

This site may earn commission on affiliate links.
Got it working with Teslamate! I've pushed the Docker image but haven't pushed the code and documentation yet, will do that later today.

For those who want to try it before then, you can use this image Docker Hub. It requires an environment variable which should be the same as the one for teslamate; MQTT_HOST.

The endpoints this exposes is /cars for finding the car id you want to use for the widget, and /car/1 for the data for that car.

Example for docker-composer.yaml:

teslamate_mqtt_api:
image: thomaslandro/teslamate-mqtt-api:latest
container_name: teslamate_mqtt_api
restart: always
environment:
- MQTT_HOST=mosquitto
ports:
- 3040:3000

You should then be able to follow the instructions in TeslaData-Widget, and set the APIurl to YOUR_HOST:3040/car/1.
 
  • Informative
Reactions: CMc1
@Landro, I would suggest you limit the data being exposed via your API and look to implement authentication. The full MQTT data will include the vehicle GPS position, door lock status and sentry mode status.

Anyone looking to use this with an installation exposed to the internet (for use of this widget while off of a home network) would be publishing that data for anyone to see - and this is not the sort of thing you'd want to find in a casual Shodan.io search.

This isn't an issue specific to your API however - you can see from the Shodan.io results below that there are a number of people hosting Teslamate on VM's that are directly exposing their unauthenticated MQTT server!
teslamate - Shodan Search
 
Last edited:
  • Informative
  • Love
Reactions: CMc1 and Stach
@Landro, I would suggest you limit the data being exposed via your API and look to implement authentication. The full MQTT data will include the vehicle GPS position, door lock status and sentry mode status.

I've added an optional API_KEY environment variable now. If this is not set you will get a limited set of data which shouldn't be dangerous to expose. By setting the variable a key will be required, and you will get more information in the endpoint - like longitude, latitude, lock status.
 
Still can’t get past the ‘Error Unauthorised’ in the widget. How are people entering the API key from TeslaFi, are you just copying the code that starts qts. ???
Mine starts differently. It’s the one at the top of this page: TeslaFi.com Tesla Model S 3 X Y Data Logger

widget setting is as follows

0C16312B-4394-4CC9-9F08-D29CC267D7C2.jpeg
 
  • Helpful
Reactions: KennethS
Got it working with Teslamate! I've pushed the Docker image but haven't pushed the code and documentation yet, will do that later today.

For those who want to try it before then, you can use this image Docker Hub. It requires an environment variable which should be the same as the one for teslamate; MQTT_HOST.

The endpoints this exposes is /cars for finding the car id you want to use for the widget, and /car/1 for the data for that car.

Example for docker-composer.yaml:

teslamate_mqtt_api:
image: thomaslandro/teslamate-mqtt-api:latest
container_name: teslamate_mqtt_api
restart: always
environment:
- MQTT_HOST=mosquitto
ports:
- 3040:3000

You should then be able to follow the instructions in TeslaData-Widget, and set the APIurl to YOUR_HOST:3040/car/1.

Thanks Landro

I got this working and am now using it. Most useful
 
  • Like
Reactions: Landro
I’ve got dark mode running if anyone wants to copy the colours.
402103A6-D801-4869-8BAA-957217E32FA2.jpeg


Set the following to “true”
Code:
    var is_dark_mode_working = true; // Scriptable widgets don't currently support dark mode.

here’s the colours I’m using

Code:
if (Device.isUsingDarkAppearance() && is_dark_mode_working){
    // Dark mode is not supported (this always returns true).
    // This is in here in the hope that Scriptable will support dark mode at some point in the future.
    
    // override colors for darkmode
    
    colors.background = "#000000";

    colors.text.primary = "#fffffffa";
    colors.text.disabled = "#fffffffa";

    colors.battery.background = "#cccccc22";
    colors.battery.max_charge = "#ffffff11";
    colors.battery.border = "#cccccc55";
    colors.battery.usable_charge = "#2B972D";
    //colors.battery.cold_charge = "#557BB4";
    colors.battery.highlight = "#ffffff44";

    colors.icons.default = "#ffffff99";
    colors.icons.disabled = "#ffffff44";
    
    colors.map.type = "dark";
    colors.map.position = "CB4335";
}
 
Can't get this to work for me, installed via docker, it's in the docker-compose.yml and it installed on running up.

I've tried both the dashboard and the tm URL in the parameters, but still get "Error on line 845:10: TypeError: null is not an object (evaluating 'json.response')