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.
So there is no way to get all the vehicle data other than using the REST API and POLL the car all the time?

I am sure there is, but Tesla is not making it public. I bet if you put a properly formated USB stick in, the logs will get written out, but nobody knows the magic to make this happen....yet.

I'm sure you can tap into the canbus somehow via USB or ODB2 port but again, nobody had figured that path out either....yet.
 
So there is no way to get all the vehicle data other than using the REST API and POLL the car all the time? That sounds kind of crazy!
Does anyone have a chrome extension or something like that to control the car from a browser instead of using the Android App?

I have a web app to do it, and I believe someone else has a javascript app, both posted to this thread.
 
superraz375 I was going to build my own C# library until I found yours. FANTASTIC library. I ended up forking it to Github and I've made some changes.

1. For the Fork, I migrated it cleanly from SVN, so all the changesets are preserved.
2. The SimpleMvvmToolkit was missing from the NUGET package manifest so I added it.
3. Added github "good practice" README.MD.
4. I ran ReSharper on every file and took 90% of the recommended updates using pretty strict guidelines.
5. I created helper methods for RequireLogin() and RequireVehicle(), eliminating a few duplicate lines of code at the beginning of a lot of the methods.

Great job with the library. I really like having strongly typed structs and properties the way you did it. And you were very thorough in covering what the API is offering.

LMK what you think of the updates.

https://github.com/morrisonbrett/teslalib
 
I posted this is another thread but it's more usefully shared here.

It took some time for me to figure out how to get my Mac to wakeup from sleep mode and run a REST API script at certain times of the day and night. Thought I would save others the trouble of figuring this out from scratch.

You need to use launchd for scheduling, not cron. Cron is being deprecated by Apple and replaced with
launchd which is more feature rich, and also more complicated.

The following is my start_charger.plist file (needed to configure launchd). Edit it to have the right UserName, Program, Minute, and Hour for your intended use.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" \
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>start_charger</string>
  <key>UserName</key>
  <string>hans</string>
  <key>Program</key>
  <string>/Users/hans/bin/start_charging.sh</string>
  <key>StartCalendarInterval</key>
  <dict>
    <key>Minute</key>
    <integer>00</integer>
    <key>Hour</key>
    <integer>21</integer>
  </dict>
  <key>Debug</key>
  <false/>
  <key>AbandonProcessGroup</key>
  <true/>
</dict>
</plist>

It calls my start_charging.sh script at 2100 hours (9pm). Edit this to have your script to start the charger (or whatever). My example uses the teslacmd.js program from the teslams tools only because I eat my own cooking but this could use curl and anything else you can start from a command line script.

Code:
[COLOR=#333333]
#!/bin/bash
/usr/local/bin/node /Users/hans/teslams/examples/teslacmd.js -u [EMAIL="[email protected]"][email protected][/EMAIL] -p password -C start[/COLOR]

Configure launchd using the launchctl command, which goes something like the following:

Code:
[COLOR=#333333]
$ launchctl load start_charger.plist[/COLOR]

And one more thing....

A wakeup time has to be configured. Go to System Preferences -> Energy. Click the "Schedule" button in the lower right corner. Check "Start up or wake" and configure the wake time to coincide with the time the script will be run. The system will wake, run the script, and go back to sleep in a few minutes. Don't worry about making sure the system is awake before the script runs. When the system awakes, launchd will run any outstanding programs it missed starting when it was asleep (unlike cron which will just miss the scheduled event altogether).

You should be good to go. Wait until the appointed Hour and Minute and see if it works!

If you want a GUI tool for managing launchd checkout Lingon. I haven't used it but it gets good reviews. Also wins my vote for the World's most boring Mac icon ;-)
 
Can't seem to login except via the mobile phone app. Have I been cut off?

When I try and login using curl (7.24.0) I get...

Code:
<!DOCTYPE html>
<html>
<head>
<title>Portal</title>
[...]


<link href='/images/favicon.ico' rel='shortcut icon'>


</head>
<body>
<header>
<li><a href="/login">Login</a></li>
</header>


<div class='flash error'>You do not have access.</div>


</body>
</html>

Is this what other people were getting before when your access was restricted? Who did you contact to regain access?
 
Can't seem to login except via the mobile phone app. Have I been cut off?
My logs suggest the service (and maybe the server) have been down since around 10pm PT (so ~36 minutes so far). If there was a betting line, I'd bet it's up again at 11pm PT.

It was also down around 8:15pm PT. The error in my logs for the wake_up command was:
System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
after the streaming API reported its normal token timeout:
System.Net.WebException: The remote server returned an error: (401) Unauthorized.
 
Does this explain the exception in the Streaming.js code? Any way to gracefully handle this fault?

TypeError: Cannot read property '0' of undefined
at /usr/local/lib/node_modules/teslams/examples/streaming.js:123:23
at /usr/local/lib/node_modules/teslams/teslams.js:37:58
at report (/usr/local/lib/node_modules/teslams/teslams.js:8:13)
at Request._callback (/usr/local/lib/node_modules/teslams/teslams.js:25:95)
at Request.self.callback (/usr/local/lib/node_modules/teslams/node_modules/request/main.js:127:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request.<anonymous> (/usr/local/lib/node_modules/teslams/node_modules/request/main.js:767:16)
at Request.EventEmitter.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/teslams/node_modules/request/main.js:729:14)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
 
Does this explain the exception in the Streaming.js code? Any way to gracefully handle this fault?

TypeError: Cannot read property '0' of undefined
at /usr/local/lib/node_modules/teslams/examples/streaming.js:123:23
at /usr/local/lib/node_modules/teslams/teslams.js:37:58
at report (/usr/local/lib/node_modules/teslams/teslams.js:8:13)
at Request._callback (/usr/local/lib/node_modules/teslams/teslams.js:25:95)
at Request.self.callback (/usr/local/lib/node_modules/teslams/node_modules/request/main.js:127:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request.<anonymous> (/usr/local/lib/node_modules/teslams/node_modules/request/main.js:767:16)
at Request.EventEmitter.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/teslams/node_modules/request/main.js:729:14)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
Treating null as an array perhaps?
 
Does this explain the exception in the Streaming.js code? Any way to gracefully handle this fault?

TypeError: Cannot read property '0' of undefined
at /usr/local/lib/node_modules/teslams/examples/streaming.js:123:23
at /usr/local/lib/node_modules/teslams/teslams.js:37:58
at report (/usr/local/lib/node_modules/teslams/teslams.js:8:13)
at Request._callback (/usr/local/lib/node_modules/teslams/teslams.js:25:95)
at Request.self.callback (/usr/local/lib/node_modules/teslams/node_modules/request/main.js:127:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request.<anonymous> (/usr/local/lib/node_modules/teslams/node_modules/request/main.js:767:16)
at Request.EventEmitter.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/teslams/node_modules/request/main.js:729:14)
at IncomingMessage.EventEmitter.emit (events.js:117:20)

I have a fix for this as part of a much bigger set of changes that I just sent to Hans
 
Questions and notes about charge state

In my app I show whether the charging cable is connected to the car. I determine the presence of the cable by looking at the charger_pilot_current field of the charge_state. What's odd is that some times when I query the charge_state I will get mostly up-to-date values, but the pilot current will be 0. A subsequent call will show it as non-zero. The requests happen within 20 seconds of one another and the car is not charging in either case.

Has anyone else noticed this behavior? Might there be another, more reliable, way to determine whether the cable is connected? I can tell that the charge port door is open, but that's different.

BTW, I noticed a new (to me anyway) field in the charge_state response: "battery_heater_on": null
 
Is the service down again, or is it just me?

I had the same issue during that time frame, but a completely different behavior. The server simply didn't answer queries related to my car, as if the car was out of 3G range. I did not receive any authentication errors or anything. The mobile app showed "Contacting car..." yet the car was happily playing Slacker, CC on, etc.