Scriptable Widgets for Tesla

A set of four scripts to use as widgets that provide at-a-glance information about your Tesla’s battery, security, climate, and trunk/frunk.

Setup and usage

These scripts use Tesla’s (unofficial) API to get information about your car. An access token is required for authentication when making these API requests.

You must install the Auth app for Tesla iOS app to generate this token. This app handles authentication using your Tesla credentials and provides it to these shortcuts. Your credentials are not stored anywhere. This access token does expire and the app will handle updating it. However, you will need to update the access token in your widgets when this happens (usually 45 days).

Scriptable updates widgets automatically in the background. The frequency of updates is handled by iOS and there’s no control over when this occurs. Every time a widget updates it has to wake the car from sleep. While this won’t significantly impact the battery, keep this in mind if you have concerns about vampire drain.

Getting an access token and car ID

The following shortcuts for the Shortcuts iOS app are used to get the necessary access token using your login credentials. They also retrieve the car ID of your Tesla.

All shortcuts must be installed but you only need to run the Scriptable Widgets for Tesla shortcut (the others are run within the shortcut). I created these shortcuts as part of my Shortcuts for Tesla collection: a set of shortcuts to control and get information about your Tesla.

Setting up the scripts

The shortcut formats the token and car ID as variables and copies them to the clipboard. For example:

const accessToken = 'token123'
const carId = '123id'

Paste this into each script so it can retrieve information about your Tesla.

Each script gets specific information about your Tesla from Tesla’s API and creates a widget for you to use on the home screen. You can also add these scripts to Siri and display them when making a Siri request.

The scripts automatically retrieves the name of your car and the unit of measurement it uses for temperature and distance. Tesla’s API returns celsius and miles units so the scripts automatically convert these for you.


Tesla battery status

Displays the battery level and estimated range of your Tesla in either miles or kilometers. Also displays the estimated charge time if the car is currently charging.

Tesla climate status

Displays the interior and exterior temperatures in either celsius or fahrenheit. Also displays the specified climate control temperature if the car is preconditioning.

Tesla security status

Displays the locked or unlocked status of the doors and whether Sentry Mode is on or off.

Tesla trunk and frunk status

Displays the open or closed status of the trunk and frunk.

Credits

My thanks to Tim Dorr for the unofficial Tesla API documentation and to Kim Hansen for Auth app for Tesla.

Changelog

  • 2021-03-28
    • Updated required shortcuts to use Auth app for Tesla iOS app to handle Tesla authentication. These shortcuts no longer handle token generation.
  • 2020-10-17
    • Added missing shortcut for configuration

4 Comments

  1. How do I “paste” the contents (e.g. accessToken and carId) from the clipboard which the “Tesla Settings” shortcut generated? I located the file “Shortcuts/Tesla Shortcuts/token_response.json” with the generated “access_token”. However, I have no idea how to obtain the “carId”. I explored all the existing “Clipboard” related Shortcuts and tried them all. But I am still unable to “paste” the required contents as generated by the “Tesla Settings” shortcut. I must be missing some very fundamental steps.
    I tried all of your Tesla Shortcuts and they worked.

    Like

    1. For the Scriptable widgets, you’ll paste that generated information into the Scriptable script file. You do this in Scriptable: edit the script and add the information (you’ll want to add it at the top).

      Like

  2. I’m getting this message when I run the “scriptable shortcut”

    “ Something went wrong. Please check your Tesla credentials and start again. A log of the response has been saved to iCloud Drive.”

    My credentials are correct. I even changed my password to see if that fixed it. Any thoughts?

    Like

    1. It looks like Tesla have deprecated their authentication endpoint so these shortcuts won’t work for new users. I’m working to update the shortcuts to support Tesla’s new authentication flow but it’ll take a bit of time.

      Like

Leave a Reply to Bobby Pham Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s