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.
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
 
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.
 
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
 
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.
 
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...
 
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:
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?
 
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.
 
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.
 
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.
 
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)