TMC is an independent, primarily volunteer organization that relies on ad revenue to cover its operating costs. Please consider whitelisting TMC on your ad blocker and becoming a Supporting Member. For more info: Support TMC

Model S REST API

Discussion in 'Model S: User Interface' started by timdorr, Feb 2, 2013.

  1. twinlifenh

    twinlifenh Member

    Joined:
    Jan 17, 2017
    Messages:
    78
    Location:
    NL
    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.
     
  2. dpskipper

    dpskipper Developer

    Joined:
    Aug 4, 2016
    Messages:
    186
    Location:
    Australia
    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...
     
  3. dpskipper

    dpskipper Developer

    Joined:
    Aug 4, 2016
    Messages:
    186
    Location:
    Australia
    I think moving sun roof/turning on AC will wake up car...
     
  4. tliving

    tliving Member

    Joined:
    Mar 8, 2014
    Messages:
    751
    Location:
    New England, USA
    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.
     
  5. twinlifenh

    twinlifenh Member

    Joined:
    Jan 17, 2017
    Messages:
    78
    Location:
    NL
    Thanks @tliving I had found that piece of code in my search today and see there's a nice example.
     
  6. tliving

    tliving Member

    Joined:
    Mar 8, 2014
    Messages:
    751
    Location:
    New England, USA
    Ok great, that's my library (I've also contributed to teslajson). EVTripping is mine too and built on Python/Django. Let me know if you have any other questions. I've also got experience on the Rails and Mobile side (React Native) too.
     
    • Like x 1
  7. john pane

    john pane Member

    Joined:
    Apr 6, 2017
    Messages:
    74
    Location:
    PA, USA
    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 x 1
  8. HankLloydRight

    HankLloydRight No Roads

    Joined:
    Jan 18, 2014
    Messages:
    11,557
    Location:
    Connecticut
    I wish I could help, but I have no knowledge of the diag screens or codes. Perhaps Ingineer or wk057 or green1 might know more about that config code.
     
  9. ACDriveMotor

    ACDriveMotor Member

    Joined:
    Aug 11, 2013
    Messages:
    865
    Location:
    Seattle, WA
    Is there a new code for pano roof? I've heard that with newer models there is a different code returned.
     
  10. BGuz

    BGuz Member

    Joined:
    Jun 3, 2017
    Messages:
    18
    Location:
    91752
    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?
     
  11. HankLloydRight

    HankLloydRight No Roads

    Joined:
    Jan 18, 2014
    Messages:
    11,557
    Location:
    Connecticut
    CH05 is a 48amp charger
     
    • Like x 1
  12. BGuz

    BGuz Member

    Joined:
    Jun 3, 2017
    Messages:
    18
    Location:
    91752
    Thanks! Do you know what CH04 is?
     
  13. sparkypete

    sparkypete Member

    Joined:
    Feb 7, 2017
    Messages:
    114
    Location:
    England
    CH04 is reported as the new High Amperage Charger code on the July 1 performance thread.
     
  14. BGuz

    BGuz Member

    Joined:
    Jun 3, 2017
    Messages:
    18
    Location:
    91752
    This probably means only dual motor Teslas (e.g. 75D) are getting the High Amperage Charge (CH04). I'm getting a 75S RWD, thus CH05?

    Edit: I just realized I'm thread jacking, I'll take this discussion over to that thread. Thanks.
     
  15. apacheguy

    apacheguy S Sig #255

    Joined:
    Oct 21, 2012
    Messages:
    5,002
    Location:
    So Cal
    IMG_0603.PNG

    Did they change the readback on charging current so it no longer works on the old version?
     
  16. MrBacardi

    MrBacardi Member

    Joined:
    Aug 1, 2015
    Messages:
    18
    Location:
    Norway
    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/compositor/?model=ms&view=STUD_SIDE&size=1920&bkba_opt=2&file_type=jpg&options=ADPX2,ADX5,ADX6,ADX7,ADX8,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
     

    Attached Files:

    • Informative x 1
  17. apacheguy

    apacheguy S Sig #255

    Joined:
    Oct 21, 2012
    Messages:
    5,002
    Location:
    So Cal
    That's interesting. We have evidence of a June 2017 manufacture 85 kWh battery from another thread. I'm going to start a new thread on this topic.
     
    • Informative x 1
  18. HankLloydRight

    HankLloydRight No Roads

    Joined:
    Jan 18, 2014
    Messages:
    11,557
    Location:
    Connecticut
    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.
     
  19. HankLloydRight

    HankLloydRight No Roads

    Joined:
    Jan 18, 2014
    Messages:
    11,557
    Location:
    Connecticut
    More interesting, the BTX8 code has been showing up since April.

    But only in Europe: UK, Germany,Norway, Sweden, Netherlands,

    Four cars coming across with an 85kWh badge:

    5YJSA7E27HF201612 Norway
    5YJSA7E27HF193043 Sweden
    5YJSA7E26HF193003 Sweden
    5YJSA7E12HF196956 Netherlands

    The rest are badged as 75Ds.
     
  20. NicB72

    NicB72 Supporting Member

    Joined:
    Jun 25, 2016
    Messages:
    99
    Location:
    Concord, MA
    Anyone seen...
    "battery_level" = "<null>"

    Was getting a good value yesterday and today getting that?
    Car has been parked at airport for 10days though.

    Thoughts
     

Share This Page

  • 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