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'm trying to play around with the API using python.
Now I am running into a little barrier trying to send a command to the car.

I'm using the teslajson python class to connect to the Tesla API.
Sending a command to sound the horn work. Now what I can't figure out is how I can send the post data when e.g. trying to set the charge limit.

If I look into the teslajson code, I can see I need to send the data as JSON. This is where I get blocked.

I tried this:

Code:
payload = json.dumps({"percent": "85"})
response = vehicle.post('set_charge_limit',payload)

Now this formats the set_charge_limit percentage as JSON (if I'm correct).
However this throws errors my way when executing.

Someone that can point me in the right direction here.
 
I'm trying to play around with the API using python.
Now I am running into a little barrier trying to send a command to the car.

I'm using the teslajson python class to connect to the Tesla API.
Sending a command to sound the horn work. Now what I can't figure out is how I can send the post data when e.g. trying to set the charge limit.

If I look into the teslajson code, I can see I need to send the data as JSON. This is where I get blocked.

I tried this:

Code:
payload = json.dumps({"percent": "85"})
response = vehicle.post('set_charge_limit',payload)

Now this formats the set_charge_limit percentage as JSON (if I'm correct).
However this throws errors my way when executing.

Someone that can point me in the right direction here.
I think most of us developers here have run into this same problem.You need to send the data to move the charge limit, sun roof, valet mode etc in the body of the HTTP POST request, not in the URL. Go back a few dozen pages and read though this thread...
 
The past few days, anyone else experiencing could_not_wake_buses error messages when sending a command to a sleeping vehicle? Pulling vehicle data (endpoint: /data) works fine, telemetry reports correctly, but not sending a command, and summon is unreliable. Even sending a wake_up command fails immediately with a false result with no impact, leaving no way to wake the car up remotely besides playing with the key fob when you're close by. Car firmware is 17.14.23 with always-on/connected setting enabled in the car.

If I wake the vehicle, things work fine. I'll see if I can wake the vehicle up some other way, but doesn't look promising.
I think moving sun roof/turning on AC will wake up car...
 
I'm trying to play around with the API using python.
Now I am running into a little barrier trying to send a command to the car.

I'm using the teslajson python class to connect to the Tesla API.
Sending a command to sound the horn work. Now what I can't figure out is how I can send the post data when e.g. trying to set the charge limit.

If I look into the teslajson code, I can see I need to send the data as JSON. This is where I get blocked.

I tried this:

Code:
payload = json.dumps({"percent": "85"})
response = vehicle.post('set_charge_limit',payload)

Now this formats the set_charge_limit percentage as JSON (if I'm correct).
However this throws errors my way when executing.

Someone that can point me in the right direction here.

If you're just getting started check this out:
evtools/tesla.py at master · the-mace/evtools · GitHub

Its open source and uses teslajson but has some real examples. I use it for all sorts of auto-tweets etc.
 
The BTX7 code is a new one that's appeared several times. I've posted about it in the CPO Program thread. I believe (but have no proof) that the BTX7 code is a 85kWh battery firmware limited to 75kWh. Tesla very briefly listed two new Inventory cars as 85kWh cars, both had the BTX7 code, but that was long after the last real 85kWh battery car was offered or produced. They were later changed to 75kWh listings. BTX7 also started showing up in March.

I got a peek at the car configuration screen in diagnostic mode and saw "Pack Config: 87". Does this shed any light on interpreting the BTX7 code?

I also saw "Charger Type: Single Limited" (option code is CH05). I'm also interested in interpreting this.

Thanks,
John
 
  • Like
Reactions: apacheguy
Did anyone ever find out about CH05? I placed an order on 6/18 for a model s, being delivered August/early September and has not gone into production. I'm seeing other members posting they are all receiving CH04. I have not seen anyone mention CH05. I don't know if this is bad or good for me?
 
IMG_0603.PNG

Did they change the readback on charging current so it no longer works on the old version?
 
All the BR0x are firmware limited batteries. BR05 started showing up in March on Inventory cars.

The BTX7 code is a new one that's appeared several times. I've posted about it in the CPO Program thread. I believe (but have no proof) that the BTX7 code is a 85kWh battery firmware limited to 75kWh. Tesla very briefly listed two new Inventory cars as 85kWh cars, both had the BTX7 code, but that was long after the last real 85kWh battery car was offered or produced. They were later changed to 75kWh listings. BTX7 also started showing up in March.

So take that with a grain of salt, but that would be my guess.

Here in Norway we are starting to see a new code, BTX8.
The car is listed as both a 85D and a 75D. Can it be a 85-battery capped at 75 kWh?

Check out this car as an example, you might have to switch the location on the Tesla-pages to "Norway" to see it:
Model S 75D 5YJSA7E27HF201612 | Tesla Norge

These are the option codes:
https://www.tesla.com/configurator/...,AF00,APF0,APH2,APPA,AU00,BCMB,BP00,BR05,BS00,BTX8,CDM0,CF01,CH04,CW00,DCF0,DRLH,DSH5,DV4W,FG00,FR04,HP00,IDCF,INWLB,IX00,LP00,MDLS,ME02,MI01,PF00,PI00,PK00,PMSS,PS01,PSPX5,PX00,QTSB,REEU,RFP2,SC04,SP01,SR01,SU00,TM00,TP00,TR00,UTAW,WTAS,WXW1,WXW2,WXW3,X001,X003,X008,X011,X014,X021,X025,X026,X028,X031,X037,X039,X044,YFFC
 

Attachments

  • 75eller85.png
    75eller85.png
    863.9 KB · Views: 101
  • Informative
Reactions: apacheguy
Here in Norway we are starting to see a new code, BTX8.
The car is listed as both a 85D and a 75D. Can it be a 85-battery capped at 75 kWh?

Check out this car as an example, you might have to switch the location on the Tesla-pages to "Norway" to see it:
Model S 75D 5YJSA7E27HF201612 | Tesla Norge

Yeah, that's the exact same thing. Shows up as 85kWh on the Listings page, but 75kWh on the car detail page. Strange!

The data stream from Tesla has this data, too:

AutoPilot: "APF0"
Badge:"85D"
Battery:"BTX8"

DriveTrain:"DV4W"
Range:"BR05"
Year:2017

So they're definitely leaking this info out.