Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register
  • The final cut of the 9th episode of the Tesla Motors Club Podcast, featuring Balazs Biro, of the prominent Hungarian EV channel Villanyautósok, is now available. You can watch it now on YouTube or listen to it on all major podcast networks.

Tesla API access via iOS Shortcuts App

So I’ve setup a workflow in the Shortcuts app in iOS that will allow me to set the charge limit to a user defined number. I haven’t previously worked with JSON, accessed an API, etc. So while the shortcut works perfectly, I would like some feedback to make sure I set things up correctly. My ultimate goal is to have location based charge limits (for example to set charge limit to 50% at home, and set it to 80% at work, etc), by incorporating this shortcut into another that will be triggered by my arrival at work, home, etc. I also dislike the slider controls for setting the charge limit both in car and on the Tesla app, as it’s pretty hard to actually set the limit to a round number, which this shortcut allows me to do.

I obtained most of my information from the following TMC posts:

Tesla Owner API Tutorial (All you need is your browser)
Automating your Tesla from your phone using Automate

and also sites that describe the various aspects of the Tesla API, such as

Tesla API and Introduction

Because this is all new to me, the item I'm most unsure about is if I handled the desired percent in a correct manner. The first action is an "ask for input" which queries the user for the desired percent charge limit, which is then handed off to the dictionary and then incorporated into the request body of the "get contents of URL" action.
full


full
 

jmaddr

Active Member
Mar 29, 2019
1,146
1,138
Florida
@golfleep, this is awesome and a good show of what is possible. I really like the use of the API.
Not to burst your bubble, but I it's my understanding this functionality was already built into the car. IE, you can set a limit on the inside screen while at work and then again at home and it will remember that charge limit for each location. I have not tested it personally so would appreciate confirmation from someone who has used/tested this.

BTW, have you gotten the IOS automation shortcut to execute without user input? I have one setup where assistive touch is enabled when connected to my car's bluetooth (so I can invoke Siri easier as "Hey Siri" is unreliable with all the background). It works fine, but it pops a notification which I must choose "run" before it will actually do what I want it to do so it's basically useless IMHO.
 
@golfleep, this is awesome and a good show of what is possible. I really like the use of the API.
Not to burst your bubble, but I it's my understanding this functionality was already built into the car. IE, you can set a limit on the inside screen while at work and then again at home and it will remember that charge limit for each location. I have not tested it personally so would appreciate confirmation from someone who has used/tested this.

BTW, have you gotten the IOS automation shortcut to execute without user input? I have one setup where assistive touch is enabled when connected to my car's bluetooth (so I can invoke Siri easier as "Hey Siri" is unreliable with all the background). It works fine, but it pops a notification which I must choose "run" before it will actually do what I want it to do so it's basically useless IMHO.

I've only had the car a few weeks, but as far as I can tell, the car does not seem to remember charge limit settings when I switch locations. However, it does seem to remember charge amperage limit settings for each location. It would be great it this functionality was already built in where charge preferences for different location could be stored and utilized automatically. In terms of the automation shortcut, I have not actually tried it, but that would be unfortunate if it did indeed require confirmation prior to executing the assigned action.

I feel that you are way over complicating battery charging, which is pretty easy and doesn't gain hardly anything from your gyrations

I'm not doing this for battery preservation, etc. Charging at work is currently free for me but availability is first come first served, so I'd like to always be able to automatically charge maximally at work, and only charge to a more minimal level at home if needed, hence the different charge limit settings.

I am a little OCD about setting the charge limit to round numbers though, so there's always that gyration ;)
 

jmaddr

Active Member
Mar 29, 2019
1,146
1,138
Florida
as far as I can tell, the car does not seem to remember charge limit settings when I switch locations. However, it does seem to remember charge
amperage limit settings for each location

Ah! Now that is a distinction I haven't heard. This would be a good idea for your situation then. Thanks for pointing out the distinction.

With the new v10 vent and close, I thought about writing an app that
executes a "window_control" command. Then I can add a "close windows" and "vent windows" to my Lock Screen Widgets. I just wish the Tesla public API allowed us to "subscribe" to events. Then I could execute the code on every lock event. That's something I think should there from the factory.
 

Products we're discussing on TMC...

About Us

Formed in 2006, Tesla Motors Club (TMC) was the first independent online Tesla community. Today it remains the largest and most dynamic community of Tesla enthusiasts. Learn more.

Do you value your experience at TMC? Consider becoming a Supporting Member of Tesla Motors Club. As a thank you for your contribution, you'll get nearly no ads in the Community and Groups sections. Additional perks are available depending on the level of contribution. Please visit the Account Upgrades page for more details.


SUPPORT TMC
Top