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

Model S REST API

This site may earn commission on affiliate links.
I don't have access to a Tesla with firmware 5.0 or greater so I'm having some difficulty figuring out the most reliable way to wake a car from sleep mode. From what I've heard, even Tesla's official apps sometimes can't wake a vehicle; or it can take many minutes to do so.

Has anyone found a reliable method for waking a car from sleep mode? What's the best process to use and how many retries are prudent?

Any and all advice is appreciated.

I'm curious about this too -- what response do you get when the car is asleep, and whats a good way to wake it up?
My car was updated to 5.6 yesterday, last night after charging for a few hours, it had gone to sleep and when I tried to connect, I got errors from the mobile enabled check and the wake up request, then one of the state requests seemed to time out. I don't have logs of what happened there, but restarting the app everything was fine so some request I made did wake it up.

9 hrs later this morning I set everything up to capture what happens, but my car wasn't asleep this morning when I tried to connect.... any data on how long before the car will sleep? or a way to make it sleep?
 
I'm curious about this too -- what response do you get when the car is asleep, and whats a good way to wake it up?
My car was updated to 5.6 yesterday, last night after charging for a few hours, it had gone to sleep and when I tried to connect, I got errors from the mobile enabled check and the wake up request, then one of the state requests seemed to time out. I don't have logs of what happened there, but restarting the app everything was fine so some request I made did wake it up.

9 hrs later this morning I set everything up to capture what happens, but my car wasn't asleep this morning when I tried to connect.... any data on how long before the car will sleep? or a way to make it sleep?


When you call the REST command for /vehicles like so

Code:
[COLOR=#333333]curl -b cookies.txt https://portal.vn.teslamotors.com/vehicles[/COLOR]

the response will contain a field called "state" with the value "asleep" rather than "online". I believe "waking" or perhaps some other states are possible (I forget the exact value list).

This is one call that I believe will NOT wake up the car, nor will it prevent the car from going asleep. I have to test this personally by setting up an infinite loop that calls this REST command every minute until I see the car go asleep.

To wake up the car I believe you need to call /vehicles/ID/command/wake_up (where ID is the value of the '"id" field returned in a previous call to /vehicles).
I have yet to test this but I expect the call to return "true" right away as a return code, but it will still take a few more seconds to actually wake the car. Application will have to wait for a period of time (to be determined) or explicitly check that the car is 'online' before issuing more commands.
 
I have existing stuff in place to wake_up, if the response had been immediate true, I wouldn't have errors popping up in my app...

I was able to get some of the info I was looking for, but the car had already woken up by the time it made the wake_up request when I was in the debugger getting the responses for everything.

(1) when querying vehicles -- "state":"asleep" is seen
(2) when making requests of mobile enabled, gui settings - the response was {"error":"vehicle unavailable (408)"}
-- having made those requests, the next ones started returning actual data (drive status, vehicle state, charging status, climate status, wake up)
 
What a great topic :love:

My model just entered into production, thus I just made a small script to have an alert when the car will be alive :biggrin:



The script will be automatically launched the morning at office when I will start my computer :smile:

I hate to disappoint you... But this won't work.
Mobile access is turned off until you take possession and manually turn it on...
 
I have existing stuff in place to wake_up, if the response had been immediate true, I wouldn't have errors popping up in my app...

I was able to get some of the info I was looking for, but the car had already woken up by the time it made the wake_up request when I was in the debugger getting the responses for everything.

(1) when querying vehicles -- "state":"asleep" is seen
(2) when making requests of mobile enabled, gui settings - the response was {"error":"vehicle unavailable (408)"}
-- having made those requests, the next ones started returning actual data (drive status, vehicle state, charging status, climate status, wake up)

More --
I also saw "state":"unknown" for awhile today, wake_up would fairly immediately return vehicle unavailable (408). took a few minutes for it to wake up this time... maybe 'unknown' is in transition
 
I have existing stuff in place to wake_up, if the response had been immediate true, I wouldn't have errors popping up in my app...

I was able to get some of the info I was looking for, but the car had already woken up by the time it made the wake_up request when I was in the debugger getting the responses for everything.

(1) when querying vehicles -- "state":"asleep" is seen
(2) when making requests of mobile enabled, gui settings - the response was {"error":"vehicle unavailable (408)"}
-- having made those requests, the next ones started returning actual data (drive status, vehicle state, charging status, climate status, wake up)

see my experience in quote 154 on this page
TeslaMS tools for telemetry data visualization - Page 16

looks like version 5.x changed the way the car reacts (or not) to a wakeup command...
 
Bad new, I hoped even if mobile access was turned off the portal.vn.teslamotors.com/vehicles API will return the list of the car linked to my account :frown:

Is someone can try to disable remote connexion on its model S, and call the portal.vn.teslamotors.com/vehicles API to see if the Tesla server answers [], or answers the list of vehicles associated to the email account ?
Thank by advance !!
 
Is someone can try to disable remote connexion on its model S, and call the portal.vn.teslamotors.com/vehicles API to see if the Tesla server answers [], or answers the list of vehicles associated to the email account ?
Thank by advance !!


I just tried it.

Calls to /vehicles did continue to return my vehicle information
Calls to any /command returned { result: false, reason: 'mobile_access_disabled' }
 
Great ! And did you seen the car before Tesla tells you it was ready ?

I also done another script to load periodically the Model S Options et Prix | Tesla Motors and automatically detect when the power folding mirrors will be available in France, and quickly ask Tesla to add them to my config !!

Well, no not really. My DS was in touch with me and I had a good idea of delivery long before I could see the car in the API.
 
Hey folks,

I was wondering how others that poll with frequency are dealing with sleep mode? My understanding is that if you query anything other than /login and /vehicles that counts as activity and will keep the car awake.

I poll every minute. My poller will back off if the car is already asleep by checking that vehicle state is "online" before getting more detail. That should prevent the poller from waking up a car that is already asleep, but since I normally poll detail every minute it never goes to sleep. I was considering backing off to a 20 minute poll if I see the car is parked and not charging, waiting for sleep mode, then resume one minute polls, but then I could miss something if I park somewhere for less than 20 minutes.

Just curious of other peoples approach?
 
Sorry I've been so silent lately, but I'm working to update the API docs with new and hidden endpoints that have been found (such as set_charge_limit). I updated the Blueprint format to the new version Apiary's developed, so the docs are a little clearer now, especially given the non-standard nature of some of Tesla's API practices.

I've also developed a helpful Ruby class based on HTTParty, that I'll include in the Github repo shortly. Hope that helps some folks!

Incidentally, there were some Tesla reps at a job fair at Georgia Tech that I attended (my company is hiring, by the way!), one of which was on the web and mobile dev team. He mentioned they have plans for updating and improving the API, including supporting some sort of official program for 3rd-party apps to access the API. That would include proper authentication (hopefully oAuth), documentation, and possibly even some support from Tesla. No timeframe on that, given that he wasn't at the level that makes those kinds of decisions. But it's definitely something Tesla wants to pursue.

Edit: The aforementioned API class: model-s-api/tesla_api.rb at master · timdorr/model-s-api · GitHub
 
Last edited:
Just curious of other peoples approach?
I haven't updated my app. It's been running since before I got 4.5 (same process, VM, in the cloud). Looking through my log files I don't see "asleep" in the "state" field at all.

Yet, when I go out to my car after work I see it waking up from sleep. And I see it at superchargers. And I see it in the morning if I "move quickly" to unplug and open the door.

So there's something "curious" about that "asleep" state vs. sleep mode itself. They don't seem to be 1-1 mapped.
 
I haven't updated my app. It's been running since before I got 4.5 (same process, VM, in the cloud). Looking through my log files I don't see "asleep" in the "state" field at all.

Yet, when I go out to my car after work I see it waking up from sleep. And I see it at superchargers. And I see it in the morning if I "move quickly" to unplug and open the door.

So there's something "curious" about that "asleep" state vs. sleep mode itself. They don't seem to be 1-1 mapped.

That's going to make things even harder ;-)

What state value do you see? Is it "online" all the time or do you see "null" or other values in the state field?

P.S. I wish I would get 5.6 so I could test all this myself.