Wrote a fun little script. - Chevy Bolt EV Forum
User Tag List

 1Likes
  • 1 Post By WhoaItsAFactorial
 
Thread Tools
post #1 of 8 (permalink) Old 05-12-2019, 03:00 PM Thread Starter
Junior Member
 
WhoaItsAFactorial's Avatar
 
Join Date: Apr 2019
Posts: 12
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 3 Post(s)
Garage
(Thread Starter)
Wrote a fun little script.

I found how to get the raw data of the car, including current battery percentage, estimated remaining range, and average efficiency. I wrote a script that will check this data every day at 3:30pm and send a text to myself and my wife if the estimated range is less than 100 miles. This way she knows that I’d like to charge and won’t park in the driveway.
Bolt Action likes this.

!
WhoaItsAFactorial is offline  
Sponsored Links
Advertisement
 
post #2 of 8 (permalink) Old 05-12-2019, 03:04 PM
Senior Member
 
Join Date: Feb 2018
Posts: 1,147
Mentioned: 16 Post(s)
Tagged: 1 Thread(s)
Quoted: 814 Post(s)
Quote:
Originally Posted by WhoaItsAFactorial View Post
I found how to get the raw data of the car, including current battery percentage, estimated remaining range, and average efficiency. I wrote a script that will check this data every day at 3:30pm and send a text to myself and my wife if the estimated range is less than 100 miles. This way she knows that Id like to charge and wont park in the driveway.
Going to share it?
Vertiformed is online now  
post #3 of 8 (permalink) Old 05-12-2019, 03:23 PM Thread Starter
Junior Member
 
WhoaItsAFactorial's Avatar
 
Join Date: Apr 2019
Posts: 12
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 3 Post(s)
Garage
(Thread Starter)
I won't share the whole script, because it uses some API keys to send the text messages. The URL of the charging data is https://my.chevrolet.com/api/vehicleProfile/<YOUR VIN>/<YOUR MYCHEVY ACCOUNT NUMBER>/evstats/false.

The output of that URL is:

Quote:
Originally Posted by Chevy API
{
"messages":[

],
"serverErrorMsgs":[

],
"data":{
"dataAsOfDate":1557688881000,
"batteryLevel":87,
"chargeState":"not_charging",
"plugState":"unplugged",
"rateType":"PEAK",
"voltage":0,
"electricRange":239,
"totalRange":0,
"chargeMode":"IMMEDIATE",
"electricMiles":18288,
"gasMiles":0,
"totalMiles":18288,
"percentageOnElectric":1,
"fuelEconomy":1000,
"electricEconomy":34,
"combinedEconomy":98,
"fuelUsed":0,
"electricityUsed":0,
"estimatedGallonsFuelSaved":704.0,
"estimatedCO2Avoided":13675.0,
"estimatedFullChargeBy":"",
"gasFuelLevelPercentage":null,
"electricRangeUOM":"mi",
"totalRangeUOM":"",
"gasMilesUOM":"mi",
"electricMilesUOM":"mi",
"totalMilesUOM":"mi",
"fuelEconomyUOM":"mpg",
"electricEconomyUOM":"kwh",
"combinedEconomyUOM":"mpge",
"fuelUsedUOM":"",
"electricityUsedUOM":"",
"estimatedGallonsFuelSavedUOM":"gal",
"estimatedCO2AvoidedUOM":"lbs",
"gasRangeUOM":"",
"gasRange":0
}
}
It's kind of funny that they show a bunch of gas information, you'd think they'd be better about filtering out extraneous information.

To send the text messages I'm using www.CallTrackingMetrics.com (which is a paid service starting at $20/mo + monthly number fee + per message fee). The messages come from the number +1(Area Code)226-5838, which is actually +1(Area Code)2-BOLTEV, just a fun little Easter egg.
WhoaItsAFactorial is offline  
Sponsored Links
Advertisement
 
post #4 of 8 (permalink) Old 05-12-2019, 03:50 PM Thread Starter
Junior Member
 
WhoaItsAFactorial's Avatar
 
Join Date: Apr 2019
Posts: 12
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 3 Post(s)
Garage
(Thread Starter)
Special note: don’t hit that URL too much, if you do, you’ll DoS your car and won’t be able to get charge stats for about 12 hours.

!
WhoaItsAFactorial is offline  
post #5 of 8 (permalink) Old 05-13-2019, 12:49 AM
Senior Member
 
Join Date: Feb 2018
Posts: 1,147
Mentioned: 16 Post(s)
Tagged: 1 Thread(s)
Quoted: 814 Post(s)
I tried the URL with curl (a command-line tool to fetch URLs) and it ended up stuck in a redirect loop.

After a bit of debugging, I found the issue. It turns out you need to enable cookies for it to work.

Cool beans.
Vertiformed is online now  
post #6 of 8 (permalink) Old 05-13-2019, 08:31 PM Thread Starter
Junior Member
 
WhoaItsAFactorial's Avatar
 
Join Date: Apr 2019
Posts: 12
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 3 Post(s)
Garage
(Thread Starter)
Quote:
Originally Posted by Vertiformed View Post
I tried the URL with curl (a command-line tool to fetch URLs) and it ended up stuck in a redirect loop.

After a bit of debugging, I found the issue. It turns out you need to enable cookies for it to work.

Cool beans.
There are also endpoints to get Chevy Smart Driver data and diagnostics data (like tire pressure, brakes, coolant). Those I haven't come up with a use for yet though. I'm trying to figure out how to send key fob commands, but am having some issues. I know the endpoints are at https://api.gm.com/account/vehicles/{vin}/commands/{unlockDoor/lockDoor/start/cancelStart}, but you need to provide an oAuth token which I think you get from https://api.gm.com/oauth/token. Unfortunately I can't figure out what params you have to pass to it to get a token.
WhoaItsAFactorial is offline  
post #7 of 8 (permalink) Old 05-13-2019, 09:01 PM
Senior Member
 
Join Date: Feb 2018
Posts: 1,147
Mentioned: 16 Post(s)
Tagged: 1 Thread(s)
Quoted: 814 Post(s)
Quote:
Originally Posted by WhoaItsAFactorial View Post
There are also endpoints to get Chevy Smart Driver data and diagnostics data (like tire pressure, brakes, coolant). Those I haven't come up with a use for yet though.
Still worth sharing though!

Quote:
Originally Posted by WhoaItsAFactorial View Post
I'm trying to figure out how to send key fob commands, but am having some issues. I know the endpoints are at https://api.gm.com/account/vehicles/{vin}/commands/{unlockDoor/lockDoor/start/cancelStart}, but you need to provide an oAuth token which I think you get from https://api.gm.com/oauth/token. Unfortunately I can't figure out what params you have to pass to it to get a token.
Good luck! You might be able to either eavesdrop on the chatter between the app and GM (but it's tricky with SSL) or reverse engineer the app (probably also tricky).
Vertiformed is online now  
post #8 of 8 (permalink) Old 05-13-2019, 09:09 PM Thread Starter
Junior Member
 
WhoaItsAFactorial's Avatar
 
Join Date: Apr 2019
Posts: 12
Mentioned: 0 Post(s)
Tagged: 0 Thread(s)
Quoted: 3 Post(s)
Garage
(Thread Starter)
Quote:
Originally Posted by Vertiformed View Post
Still worth sharing though!
Diagnostics -> https://my.chevrolet.com/api/N11001467/14293771/onStarAccount/{OnStarAccount}/{vin}/ovd/maintenanceDetails

Smart Driver -> https://my.chevrolet.com/api/api/onStar/data/services/{vin}/SMRT_DVR_UBI?periodType=YEARLY&year=2019

Quote:
Originally Posted by Vertiformed View Post
Good luck! You might be able to either eavesdrop on the chatter between the app and GM (but it's tricky with SSL) or reverse engineer the app (probably also tricky).
Unfortunately the app is smart enough to notice when you're routing through a proxy. So it won't send the request. I was able to get the end-points with a combination of snooping the requests and by looking through the decompiled APK (one thing Android is useful for).

!
WhoaItsAFactorial is offline  
Reply

Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page



Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

 
For the best viewing experience please update your browser to Google Chrome