Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register
  • We just completed a significant update, but we still have some fixes and adjustments to make, so please bear with us for the time being. Cheers!

Model S REST API

jayman

Member
Aug 31, 2013
329
118
Illinois
This is pretty much what I'm getting, over and over:

Code:
9 Mar 11:03:09 - timestamp,speed,odometer,soc,elevation,est_heading,est_lat,est_lng,power,shift_state,range,est_range,heading
9 Mar 11:03:10 - Bad timestamp (<html>)
9 Mar 11:03:10 - Unexpected problem with request:
    Response status code = 502  Error code = null
 Polling again in 10 seconds...
.
.
.
.
9 Mar 11:23:22 - 4 of 6 Stream requests since 1552159362263
9 Mar 11:23:22 - Bad timestamp (<html>)
9 Mar 11:23:22 - Unexpected problem with request:
    Response status code = 502  Error code = null
 Polling again in 10 seconds...

I am getting the same error for streaming api. Looks like for me since 3/6
 

markb1

Active Member
Feb 17, 2012
3,031
638
San Diego, CA
Streaming API is working fine for me this morning at 10:00 GMT

Huh.. I wonder what the difference is?

Here's my curl equivalent:

Code:
curl --user <email address>:<token> https://streaming.vn.teslamotors.com/stream/<vehicle_id>/?values=speed,odometer,soc,elevation,est_heading,est_lat,est_lng,power,shift_state,range,est_range,heading
 

Dazboj

Member
May 9, 2017
86
25
UK
Huh.. I wonder what the difference is?

Here's my curl equivalent:

Code:
curl --user <email address>:<token> https://streaming.vn.teslamotors.com/stream/<vehicle_id>/?values=speed,odometer,soc,elevation,est_heading,est_lat,est_lng,power,shift_state,range,est_range,heading

I’ll check again next time I’m out in the car. I used my iOS app Teslemetry and it connects fine. As car wasn’t moving the data doesn’t come very quick.
 

dirkvm

Supporting Member
Apr 4, 2018
11
3
Flanders, Belgium
Streaming API Broken after Model 3 updated to 2018.18.3 04dfd3c · Issue #68 · timdorr/tesla-api suggests that there's also a websocket based streaming api. I experimented a bit with this and it seems to work much better than the long-polling api (using a european MS75D 2019.5.14 53ca475).

See websocket based streaming for Tesla for some code.

The token rotates every 15 minutes but once a connection is open, it seems to stay open for a much longer time.

Currently running with a replacement tsla_poll in hjespers/teslams
 

jayman

Member
Aug 31, 2013
329
118
Illinois
Streaming API Broken after Model 3 updated to 2018.18.3 04dfd3c · Issue #68 · timdorr/tesla-api suggests that there's also a websocket based streaming api. I experimented a bit with this and it seems to work much better than the long-polling api (using a european MS75D 2019.5.14 53ca475).

See websocket based streaming for Tesla for some code.

The token rotates every 15 minutes but once a connection is open, it seems to stay open for a much longer time.

Currently running with a replacement tsla_poll in hjespers/teslams

For those of us not exactly gifted in the art of code could you give me a file or a line of code that I could substitute for in my previously functioning teslams? Thanks.
 

twall-e

Roaming
Feb 2, 2016
449
142
Netherlands
For those of us not exactly gifted in the art of code could you give me a file or a line of code that I could substitute for in my previously functioning teslams? Thanks.
Looking at the code I'd be interested as well which parts you've replaced @dirkvm - and if/how this plays out in the long run.

Currently running into the below, although I still get some data through. I do note that the APP also isn't responding well last couple of days.
Code:
11 Mar 20:17:08 - Unexpected problem with request:
    Response status code = 502  Error code = null
 Polling again in 10 seconds...
11 Mar 20:17:18 - Bad timestamp (<html>)
11 Mar 20:17:18 - Unexpected problem with request:
    Response status code = 502  Error code = null
 Polling again in 10 seconds...
 

dirkvm

Supporting Member
Apr 4, 2018
11
3
Flanders, Belgium
For those of us not exactly gifted in the art of code could you give me a file or a line of code that I could substitute for in my previously functioning teslams? Thanks.

The problem is that I removed all "nap" code from streaming.js because I synchronize my local state with TeslaFi. If TeslaFi says the car is sleeping or is trying to sleep, then I close the websocket and stop asking for new tokens.

To me, TeslaFi is perfect as an archive solution but I wanted realtime tracking via MQTT and MongoDB without handing out any account info ;)

@twall-e I replaced tesla_poll with this: Handle Tesla realtime streaming data

So far so good, longest drive I made was +100km and it didn't disconnect during that time. If I can get the streaming token from TeslaFi then I don't need any teslams api call.
 
Last edited:

Mr.D

Member
Mar 16, 2018
105
48
Norway
Hi,

I am having problems getting these commands to work.

/command/remote_steering_wheel_heater_request?on=true')
/command/remote_seat_heater_request?heater=0&level=1')

When running these commands on my Model S, nothing happens unless one of these are already turned on, if so, the respective command turns the steering wheel or seat heater off.... not no matter what I do, it does not turn the heaters on.

Can anyone confirm that they are working as the should for your setup?
 

markb1

Active Member
Feb 17, 2012
3,031
638
San Diego, CA
Hi,

I am having problems getting these commands to work.

/command/remote_steering_wheel_heater_request?on=true')
/command/remote_seat_heater_request?heater=0&level=1')

When running these commands on my Model S, nothing happens unless one of these are already turned on, if so, the respective command turns the steering wheel or seat heater off.... not no matter what I do, it does not turn the heaters on.

Can anyone confirm that they are working as the should for your setup?

I think you might have to pass the parameters as JSON in the body, rather as URL parameters. But I'm not using those commands, so I can't say for sure.
 

PCRover

Member
May 26, 2018
24
9
NorCal, USA
Hi,

I am having problems getting these commands to work.

/command/remote_steering_wheel_heater_request?on=true')
/command/remote_seat_heater_request?heater=0&level=1')

When running these commands on my Model S, nothing happens unless one of these are already turned on, if so, the respective command turns the steering wheel or seat heater off.... not no matter what I do, it does not turn the heaters on.

Can anyone confirm that they are working as the should for your setup?

Same type of issue I am having. I tried json format in body and that didn't work either.
 

SeBsZ

Former Vendor
Aug 1, 2017
1,052
1,052
The Netherlands
Anyone know why for Model 3s the option codes are all the same for all cars when retrieved through the API? How do I get the right option codes? For Model S and X they are set correctly.
 

jayman

Member
Aug 31, 2013
329
118
Illinois
The problem is that I removed all "nap" code from streaming.js because I synchronize my local state with TeslaFi. If TeslaFi says the car is sleeping or is trying to sleep, then I close the websocket and stop asking for new tokens.

To me, TeslaFi is perfect as an archive solution but I wanted realtime tracking via MQTT and MongoDB without handing out any account info ;)

@twall-e I replaced tesla_poll with this: Handle Tesla realtime streaming data

So far so good, longest drive I made was +100km and it didn't disconnect during that time. If I can get the streaming token from TeslaFi then I don't need any teslams api call.
I'm able to use your streamws.js but how do I put that info into my mongo database as before. Sorry for being so dense with this.
 

jayman

Member
Aug 31, 2013
329
118
Illinois
Are you using sleep/nap checking? If not, or you don't mind turning that off, then I can adapt the original streaming.js to use the websocket streaming.
I don’t use the sleep/nap checking. I just have my home automation system turn off streaming at nighttime. That would be great. Thanks.
 

schmug

New Member
Dec 23, 2018
3
0
nc
Is anyone getting {"response":{"reason":"","result":true}} even though Sentry mode isn't turning on?

I've tried postman, powershell, and curl on my Zabbix server.

My request:

Code:
curl -X POST \
  https://owner-api.teslamotors.com/api/1/vehicles/{ID}/command/set_sentry_mode \
  -H 'accept-encoding: gzip,deflate' \
  -H 'authorization: bearer {TOKEN}' \
  -d '{"on":true}'

or

$HEADERS = @{
"accept-encoding" = "gzip"
"authorization" = "bearer $token"
"content-type" = "application\json"
}

$BODY = '{"on":true}'

invoke-webrequest -method POST -uri 'https://owner-api.teslamotors.com/api/1/vehicles/$ID/command/set_sentry_mode' -headers $HEADERS -body $BODY

Sentry mode works fine using the app, in the car, and Fiddler shows exactly what I am doing here on my rooted pixel (and works)
 

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