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. nasatech

    nasatech Vendor

    Joined:
    May 19, 2016
    Messages:
    235
    Location:
    Oslo
    Does the actuate_trunk work on Model S / Model X? Always get invalid_value when trying.
     
  2. dpskipper

    dpskipper Developer

    Joined:
    Aug 4, 2016
    Messages:
    169
    Location:
    Australia
    Yep they work.
    How are you sending the API request? More often than not your implementation is wrong.
     
  3. nasatech

    nasatech Vendor

    Joined:
    May 19, 2016
    Messages:
    235
    Location:
    Oslo
    Thank you for replying :)

    I use this: https://owner-api.teslamotors.com/api/1/vehicles/<vehicleid>/command/actuate_trunk?which_trunk=rear

    All other commands work.
     
  4. mianesva

    mianesva New Member

    Joined:
    Oct 2, 2018
    Messages:
    3
    Location:
    NH

    Your request likely looks like:

    POST /api/1/vehicles/zzzzzzz/command/actuate_trunk?which_trunk=rear HTTP/1.1
    User-Agent: yyyyy
    Authorization: Bearer xxxxx
    Host: owner-api.teslamotors.com
    Connection: close
    Content-Length: 0


    with your values for x,y,z....

    I duplicated your current result of:

    {"response":{"reason":"invalid_value","result":false}}


    Instead of passing the commend as parameter on the url just pass them as value in the body. Note the additional Content-Type header and its value to indicate the type of data you are passing in the body for the POST request

    POST /api/1/vehicles/zzzzzz/command/actuate_trunk HTTP/1.1
    User-Agent: yyyyy
    Authorization: Bearer xxxxxx
    Content-Type: application/json
    Host: owner-api.teslamotors.com
    Connection: close
    Content-Length: 22

    {"which_trunk":"rear"}


    Which yields a valid response:

    {"response":{"reason":"","result":true}}
     
    • Helpful x 1
  5. nasatech

    nasatech Vendor

    Joined:
    May 19, 2016
    Messages:
    235
    Location:
    Oslo
    Perfect! Got it working. Thanks :)
     
  6. hans

    hans P631

    Joined:
    Sep 27, 2012
    Messages:
    1,132
    Location:
    Menlo Park
    I have done an `npm publish` of the latest teslams.js (version 1.3.0) so it should work from either source on github or via `npm install`.

    Special thanks to cbrandlehner for the fix.
     
  7. ACDriveMotor

    ACDriveMotor Member

    Joined:
    Aug 11, 2013
    Messages:
    859
    Location:
    Seattle, WA
    Tesla Control lets you schedule start and stop times. It’s done with background tasks.
     
  8. lonertic

    lonertic Member

    Joined:
    Feb 2, 2017
    Messages:
    15
    Location:
    Sydney
    I can find the start/stop charging commands (no details about what the httpbody payload should be though?)... however, is there such a command that could set the charging current remotely? I haven't seen one in the official app but I'm wondering if an API for it exists (or if someone managed to sniff one out)?
     
  9. Dazboj

    Dazboj Member

    Joined:
    May 9, 2017
    Messages:
    67
    Location:
    UK
    Unfortunately not. This is a holy grail I have been waiting for (And tweeting Elon).
    If the API allowed us to set the charge rate, I could utilise much more of my solar export by keeping the charge rate the same as solar excess.
     
    • Love x 1
  10. lonertic

    lonertic Member

    Joined:
    Feb 2, 2017
    Messages:
    15
    Location:
    Sydney
    EXACTLY the reason why I asked for it too :) Tweet him again, I'd imagine we're not the only ones thinking about this... Since my solar inverter can't work in island mode, and I can't send any predetermined amount of power towards the car first before exporting excess, having the car "pull" a corresponding amperage out of the inverter in line with solar output seems to make a lot of sense!

    I'm guessing you already tried obvious stuff like command/set_charge_current (as opposed to set_charge_limit) just to see if the API actually exists right? (i just tested it now, got a 400 bad request).. that makes me think, i wonder what other hidden APIs there are.. possible able to just guess a bunch i think
     
  11. dpskipper

    dpskipper Developer

    Joined:
    Aug 4, 2016
    Messages:
    169
    Location:
    Australia
    Mate it doesn't exist
     
  12. markb1

    markb1 Active Member

    Joined:
    Feb 17, 2012
    Messages:
    2,688
    Location:
    San Diego, CA
    There's a different way to achieve this, by using the load sharing protocol of the Tesla Wall Connector. (This requires wiring something to the wall connector.) There's a thread here:

    New Wall Connector load sharing protocol

    And source code here:

    cdragon/TWCManager
     
  13. lonertic

    lonertic Member

    Joined:
    Feb 2, 2017
    Messages:
    15
    Location:
    Sydney
    Nice! But unfortunately my car is 2015, so is my HPWC... so I can only assume it's the "older" model with older firmware/hardware that can't run that... and it wouldn't be as precise as the car controlling draw either, because HPWC selector is still in stepped amps, whereas car is single digit amp changes... really wish an API was available! :( What about canbus message within the car? anyone?
     
  14. markb1

    markb1 Active Member

    Joined:
    Feb 17, 2012
    Messages:
    2,688
    Location:
    San Diego, CA
    It requires a second generation wall connector, but I believe it will work with any Model S/X/3.
     
  15. dpskipper

    dpskipper Developer

    Joined:
    Aug 4, 2016
    Messages:
    169
    Location:
    Australia
    That's doable, as the car is the one that talks to EVSE and requests the current
     
  16. insaneoctane

    insaneoctane Active Member

    Joined:
    Apr 6, 2016
    Messages:
    2,323
    Location:
    Southern California
    Don't know if anyone here cares, but the newest firmware 46.x changed the timestamp format for charging start time again. It's back to long-UNIX style UTC, no longer readable with the "T" in the middle. Re-broke some of my scripts after the update. Just had to go back to before Nov. 2 to see what I had changed so that I could undo it.
     
    • Informative x 1
  17. ACDriveMotor

    ACDriveMotor Member

    Joined:
    Aug 11, 2013
    Messages:
    859
    Location:
    Seattle, WA
    I had coded Tesla Control to handle both formats guessing they would switch back at some point.
     

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