The options for automating the control of your Tesla including the timing of Tesla charging are relatively limited. There are a number of reasons why owners may want to control their charging beyond simply setting the charge limit and wanting to wake the following morning to find the car at the required charge level. These include, but aren't limited to:
The Tesla API provides the ability to stop and start charging manually however owners typicaly want to automate these features rather than wake up at 2am to manually start a charge. What Tesla do not allow via the API is the ability to change the charge rate, this can only be set in the car.
The Tesla API has been reasonably well documented for a number of years, however the use is not totally straight forward. The basic steps to use the API are:
While the steps above look like they need a lot of technical skill, in practice there are a lot of 3rd party apps and utiltiies that can make this easier for you. We would hoever express a note of caution when giving out your Tesla account id and password as this gives the recipient access to your account. Most are trustworthy, but your security is only as good as their security and as a consequence we personally don't feel it appropriate to hold any personal information. In Europe, this could also be a GDPR breach unless declared as the vehicle information includes location details and like mobile phones is classed as personal information.
Our way around this problem is to provide simple tools to generate a token and vehicle IDs, and a simple API which wil wake the car before executing a command. You hold your details and only provide them to us for the purposes of the request. We only keep a record that the request was made to spot abuse or hacking attempts, but none of your account details.
We have created a utility to generate a Tesla token. This utility does require your Tesla user name and password, and will return the Tesla token and the vehicle ID for each car on your account. We also supply the bearer and refresh tokens for those that want to use the tokens on a 3rd party application but wish to use an independant website to generate the token.
The token will expire, either after the account password has been changed on Tesla, or after approximately 45 days. Some websites offer to refresh the tokens for you, however we don't as our security mantra is not to hold your details. If you follow our approach, you will need to update the token, something we suggest you do as a monthly reminder.
We have created a fairly simple API which in practice just looks like a web page URL. The format for the API is as follows, although the 'id' can be omitted and we will identify the first car on your Tesla account (for most people this will be their only car). The 'value' is also only required for some commands such as setting the temperature (in Celsius) or the charge level (in %).
https://tesla-info.com/api/control.php?token=[your token qts-lots of characters]&id=[id]&request=[command]&value=[value]
An example of a command to start charging on the first car on your account is:
A second example to set the charge level of the car with the id 123456789 to 70% is:
These types of commands can be relatively easily integrated into IFTTT type programming for those that like to do more sophisticated automation. The response from the API is in JSON format which is fairly easy to understand without any technical skills, but can also be used in a programming context to capture the success or otherwise of the request for those wanting to embed them in a more sophisticated set up. IFTTT is likely to be required as part of controlling charging if it is linked to solar power availability.
The links can also be saved as web pages in a web browser and you can simply select the web page and the command will execute.
The command choices are
door_lock, lock, door_unlock, unlock, charge_port_door_open, chargeopen, charge_port_door_close, chargeclose, charge_start, charge, charge_stop, stopcharge, flash_lights, flash, honk_horn, honk, auto_conditioning_start, hvac, auto_conditioning_stop, hvacoff
Because the request may need to wake the car first, they can take up to 30 seconds to run.
The commands above can be simply copied into an apple shortcut and all the features of apple shortcuts are available such as timed execution for a fairly basic form of automation, or inclusion on an apple watch. The results can be also be captured and more complex flows can be setup depending on your wishes.
To control charging times, you could simply schedule the start and stop charging shortcuts at the times you require and over ride them as and when required.
Some simple examples where this might be useful is to add an 'unlock' shortcut to your childrens phones so they can gain easy access to the car while you are out shopping without them having the ability to drive the car. You might also want to add a 'lock' shortcut too.
Because the token expires, it may be more convenient to hold the important data in a file in your personal icloud and let the apple short cuts read this data. This may sound complicated so we have built the most common shortcuts for you.
To do this, you need to follow the following steps:
To create a data.txt file from your apple device. select the text including the opening and closing curly bracket, then select Share, scroll down until you see "Save to files". From here, edit the word "text" to say "data" (no capital letter), select Shortcuts folder and then tesla using the create folder option in the top right hand corner if necessary.
Tesla tokens do expire and we have chosen not to be able to automatically renew it for you for your own security. We recommend updating the token every month.
If at any time you feel your phone or security has been compromised, visit tesla.com and change your Tesla password.