Skip to main content

Python interface to My Chevy online data

Project description

https://img.shields.io/pypi/v/mychevy.svg https://img.shields.io/travis/sdague/mychevy.svg Documentation Status Updates

Python interface to My Chevy website

Unlike Tesla, GM does not provide a consumer level API to their vehicles. I tried to sign up for their developer program after purchasing my Chevy Bolt, but so far it’s all been black holed. They do provide a useful My Chevy website, where you can log in with your OnStar credentials and see things like how charged your battery is. This is all built with a javascript framework, and the data loads off the OnStar network with a 60 - 120 second delay (OnStar is a rather slow proprietary cellular network)

This library logs into the mychevy website, and uses the API that the javascript on the site uses to load the onstar data.

Installation

Installation for this library is just a pip install.

  1. pip install mychevy

Usage

Usage is very basic.

from mychevy.mychevy import MyChevy

page = MyChevy("<username>", "<password>")
# This takes up to 2 minutes to return, be patient

# build credentials and starts a session on the mychevy site
page.login()

# gets a list of cars associated with your account
page.get_cars()

# update stats for all cars, and returns the list of cars. This will take
# 60+ seconds per car
cars = page.update_cars()

# Percent battery charge
print(cars[0].percent)

Every invocation of login() creates a whole new session to avoid credential timeouts.

It is not recommended that you run this very frequently. Something like once an hour will give you basic data, and shouldn’t overload anyone’s systems.

Testing

Because there are so many ways this can go wrong, a basic cli tool has been provided.

> mychevy -c config.ini
Loading data, this takes up to 2 minutes...
<EVCar vin="...", range=185 miles, bat=100%, plugged_in=True, mileage=903 miles, charging=Your battery is fully charged., charge_mode=Departure Based, eta=None, state="">

config.ini must include your user and password for the mychevy site in the following format:

[default]
user = my@email.address
passwd = my@wes0mepa55w0rd

Caveats

There are so many caveats…. This software aspires to be the gloriously robust bubble gum and duct tape of which it has heard makes the internet go round.

  • JSON formats are guessed at

    The use of the sessions capture and transfer, and inspecting json returned still creates slightly different parameters than are used by the website. The set of keys and values are guessed at. It’s all kind of fragile and heuristic.

  • The MyChevy website OnStar link is not robust

    In the first month with the Bolt I’ve seen two multi hour outages of the mychevy website being able to connect to their OnStar backend gateway. One lasted a whole day. The OnStar link from the Android App worked fine during these windows of time. So it’s not an OnStar failure, but it’s a lack of robustness somewhere on the Web side, or the gateway dedicated for serving OnStar requests.

As such, this software will always be classified Alpha on Pypi. It can and will break. For that I’m sorry. But it’s the best I’ve got.

Features

  • TODO

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mychevy-2.1.0.tar.gz (17.9 kB view details)

Uploaded Source

File details

Details for the file mychevy-2.1.0.tar.gz.

File metadata

  • Download URL: mychevy-2.1.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.6.7

File hashes

Hashes for mychevy-2.1.0.tar.gz
Algorithm Hash digest
SHA256 38b1db622b57f67d9a576e2c48b33aae1604abd89f8f3c7ae99d88a05466d07d
MD5 5e9774b802404938f91b087e45789b1c
BLAKE2b-256 eed5abd55090f835bd9edd300c2d9d0b07476451e278c2e79f3bdeebf2fca1d1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page