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 or making a Paypal contribution here: paypal.me/SupportTMC

Beta of a Hosted Data Logger via the Tesla API

Discussion in 'Model S: User Interface' started by mochouinard, Mar 18, 2015.

  1. mochouinard

    mochouinard Member

    Joined:
    Aug 3, 2014
    Messages:
    339
    Location:
    Montréal, Quebec, Canada
    #1 mochouinard, Mar 18, 2015
    Last edited: Mar 18, 2015
    I've made a data recorder that is hosted, which mean you do not have to run any application on your computer.

    I have 6 Tesla Model S being monitored and it seem to be working well so far (1 in USA right now and 5 in Canada).

    I've just finished adding imperial unit for the result being display (was metric only before), so It time to get a few more tester on board.

    Just send me a private message on the forum and I'll send you a link so you can register.

    Currently it will store every minute your climate information and charging (It will group charging by session). It also log your real time GPS data grouped by trip.

    You can see your Wh/miles for every trip you made.

    I've added the head wind estimator also which give much better gps coordinate than the one from the browser only. So if Tesla tomorrow announcement doesn't include a better way to estimate Wh/mile usage by checking weather information, then with more data on different route, I'll be able to do it :)

    You can set geo location where your car climate remain on even when you get out of the car. Great for when you are leaving or picking up the kid at the kindergarder and you don't want your car to get cold (or warm) on short stop.

    There is a bunch of other feature that will be added, and I'm open to suggestions. I'm hoping to have enough user at some point to do some 'competition' of who have the lowest Wh/miles for example... But for the moment I'm focusing more getting interesting data for the car owner to monitor.

    The UI is not pretty but does the job... Lot of things to improve, but what is important is the logged data, everything else can be done latter on.

    So like I said, just PM me that your interested and I'll msg you the link.

    PS... It useless if you don't have a Tesla Model S of course !
     
  2. FlasherZ

    FlasherZ Sig Model S + Sig Model X + Model 3 Resv

    Joined:
    Jun 21, 2012
    Messages:
    7,019
    Just checking... you're using the new OAUTH based tokens, and not storing user/PW, correct?
     
  3. mochouinard

    mochouinard Member

    Joined:
    Aug 3, 2014
    Messages:
    339
    Location:
    Montréal, Quebec, Canada
    Yes ! Sadly Tesla API server doesn't allow direct query from the web browser, so I made it so you enter your Tesla login/password into a form that query a simple proxy web service on my server that doesn't store anything locally and forward it to Tesla. But if that still worry you, you can generate your own key and send it to me and I'll save it to your account.
     
  4. dirkhh

    dirkhh Middle-aged Member

    Joined:
    Jul 7, 2013
    Messages:
    3,645
    Location:
    Portland, OR, USA
    It's my understanding that Tesla is much more aggressive throttling data for accounts using OAUTH. What's your experience with that? Will using the service impact availability / responsiveness of the phone apps?
     
  5. mochouinard

    mochouinard Member

    Joined:
    Aug 3, 2014
    Messages:
    339
    Location:
    Montréal, Quebec, Canada
    #5 mochouinard, Mar 18, 2015
    Last edited: Mar 18, 2015
    I'm monitoring 6 car from the SAME IP and haven't seen any issues so far, though, I've already added support for multiple server and put car monitoring on different IP. I also only do about 2 or 3 query to the API per minute per car.

    Your phone app can do more than 1 query per second sometime when your switching between tab. Even during normal operation, it does query much often than I do so you can see thing like door being open or closed

    So I haven't seen any conflict with my phone app so far even when I was looking at a restaurant while supercharging.
     
  6. AnOutsider

    AnOutsider S532 # XS27

    Joined:
    Apr 3, 2009
    Messages:
    11,923
    I'll test it out, with my own provided OAUTH
     
  7. Torpedo Ted

    Torpedo Ted Member

    Joined:
    Oct 14, 2013
    Messages:
    71
    Location:
    Norway
    Are you going to release this so people can host it on their own servers? I'm not 100% comfortable sharing my car login details...
     
  8. mochouinard

    mochouinard Member

    Joined:
    Aug 3, 2014
    Messages:
    339
    Location:
    Montréal, Quebec, Canada
    I don't think I will... I started with 1 other Model S owner running the code on his side and as changes occur on my end, thing doesn't sync up on his end and require lot more work to allow transition. The reason I've made this hosted version is because we were just so out of sync, that it was simpler for me to migrate his data on my end that go forward with keeping multiple different version... And that with just 1 other user ! People want to run thing on Mac, Windows, Linux... In a cloud, on a local computer with different version of the software installed locally... I just don't want to deal with all that crap.

    It why I want to work with the tesla token only and not with your actual login/password (except for the initial token generation, but I do not store it).

    This mean that when your key expire or get revoked, you will have to generate a new one and no login will occur during that time.

    The day Tesla allow direct Browser API call to their web service, I won't even receive on my server your initial credential. But in the mean time, all I can do is say that I will not store your tesla password in anyway ! (I need to store the email though so I can login to the streaming data)
     
  9. lphe

    lphe Member

    Joined:
    Mar 18, 2015
    Messages:
    108
    Location:
    Eagan, MN
    I am curious about your data logger. I don't have a Tesla so I can't try it out. What is the Tesla API? Is there some link to more information? Where is the Data Logger run? An app in the car? An app on your computer? If it runs on a computer, how does it acquire the data from the car?
     
  10. mochouinard

    mochouinard Member

    Joined:
    Aug 3, 2014
    Messages:
    339
    Location:
    Montréal, Quebec, Canada
    You can check this site (it describe the old API but it easy to understand) : Tesla Model S JSON API—by apiary.io
     
  11. lphe

    lphe Member

    Joined:
    Mar 18, 2015
    Messages:
    108
    Location:
    Eagan, MN
    Thank you for the link. This appears to be an API for creating Android and iOS applications for you tablet PC or smart phone. The API allows you log in and talk to Tesla's server. Tesla's server then communicates with your car to acquire the requested information or perform the requested action.

    Does Tesla have a web site that you can log into to access information on the car, i.e. a log of trips that you have made including times, distance, origin, destination, kWh of energy used, etc.?
     
  12. mochouinard

    mochouinard Member

    Joined:
    Aug 3, 2014
    Messages:
    339
    Location:
    Montréal, Quebec, Canada
    No, that why I made one.
     
  13. lphe

    lphe Member

    Joined:
    Mar 18, 2015
    Messages:
    108
    Location:
    Eagan, MN
    Do you know of any way to log real-time info from the car to an Android or iOS device? With conventional cars, you can use a Bluetooth OBD II scanner connected to the car's OBD II port and run an application such as Torque Pro that will query the various PIDs. That allows me to record the speed, power output of battery, battery temperature, power output of motor, and hundreds of other measurements several times a second.
     
  14. mochouinard

    mochouinard Member

    Joined:
    Aug 3, 2014
    Messages:
    339
    Location:
    Montréal, Quebec, Canada
    Not all ODBII are compatible with the car, and info is limited. My ODBII didn't work. Some people hook directly to the CANBUS which might also be another source of data to my interface in the future. But those are better as a standalone post so people that know more about them see it.
     
  15. mochouinard

    mochouinard Member

    Joined:
    Aug 3, 2014
    Messages:
    339
    Location:
    Montréal, Quebec, Canada
    I've made a quick video to show what the UI look like... I haven't focus on look at all so far... Lot to be done there... But it will give you an idea :

    Tesla Logger - YouTube
     
  16. 1NJ85D

    1NJ85D Member

    Joined:
    Feb 26, 2015
    Messages:
    83
    Location:
    Scotch Plains, NJ
    That is, naturally, the old API. Is the new API documented anywhere? I would like to be able to make calls from my home automation system. Thanks.
     
  17. mochouinard

    mochouinard Member

    Joined:
    Aug 3, 2014
    Messages:
    339
    Location:
    Montréal, Quebec, Canada
    Not per say documented, but there is some post on this forum about it. But the old api is still working for now I think, so you might want to tinker with it first.
     
  18. 1NJ85D

    1NJ85D Member

    Joined:
    Feb 26, 2015
    Messages:
    83
    Location:
    Scotch Plains, NJ
    Mine is a recent Model S and, therefore, it doesn't work with the old API. I have tried (using CURL) and had no luck. In my application, I would like to be able to invoke select commands from the new API using CURL. Any pointers you can provide would be much appreciated.
     
  19. mochouinard

    mochouinard Member

    Joined:
    Aug 3, 2014
    Messages:
    339
    Location:
    Montréal, Quebec, Canada
    This is not the thread to talk about this, you should look for other thread which contain the information you need... But here a few curl command that work with the new API :

    To Generate your key :
    curl -H "Content-Type: application/json" -d '{"grant_type" : "password", "client_id" : "YOU MUST FIND THIS ON YOUR OWN", "client_secret" : "YOU MUST FIND THIS ON YOUR OWN", "email" : "YOUR TESLA EMAIL", "password" : "YOUR TESLA PASSWORD"}' https://owner-api.teslamotors.com/oauth/token

    you will get an output witch contain your key... Do not ask for a key on every request... you might get blocked.

    To get car information :
    curl -H "Authorization: Bearer YOURKEYHERE " \
    -H "Content-Type: application/json" \
    -i https://owner-api.teslamotors.com/api/1/vehicles
    You will get your car id from this command used for other commands

    Get Car GUI info
    curl -H "Authorization: Bearer YOURKEYHERE " \
    -H "Content-Type: application/json" \
    -i https://owner-api.teslamotors.com/api/1/vehicles/YOURVEHICLEID_PROVIDED_BY_THE_CAR_LIST/data_request/gui_settings

    You must find the client_id and client_secret on your own ! (This is what people said in the other thread post, so I'll say it too).
     
  20. PatD

    PatD Member

    Joined:
    Dec 21, 2014
    Messages:
    363
    Location:
    Broomall, PA
    Just looked at your video - that's insane! I can't get over the amount of data you're collecting and what you're doing with it. Nicely done!
     

Share This Page