GithubHelp home page GithubHelp logo

bmwcdapi's Introduction

bmwcdapi.py

https://github.com/jupe76/bmwcdapi

Bmwcdapi.py is a python script to query various informations about your car from the BMW ConnectedDrive portal in conjunction with obenhab.

I'm using it for a BMW i3, but should work with other types as well.

The techniques to access the ConnectedDrive portal were taken from https://github.com/sergejmueller/battery.ebiene.de

Prerequisites

You'll need the credentials (username / password) for a ConnectedDrive login and the 17 chars long vehicle ident number (VIN) of your car. Furthermore you need a running openhab installation and python 3.x . The script has been tested with openhab2.

Installation

Copy bmw.rules and bmw.items in the according openhab dirs.

Edit Bmw_Username, Bmw_Password and Bmw_Vin placed in bmw.items to hold your credentials and the VIN of your car.

If your script dir is not /etc/openhab2/scripts than you need to edit bmw.rules.

Copy bmwcdapi.py to the openhab script dir. If the script is running on another computer than your openhab installation, than you need to adjust OPENHABIP.

Edit your sitemap to visualize the items.

Usage

The script is called every 30 min to update the values. You can adjust the timespan in bmw.rules (be nice to the ConnectedDrive portal and don't hammer the server) With the switch Bmw_ForceUpdate you could initiate an immediate update.

To execute services like to climate the car, call the bmwcd api.py with the commandline parameter --execservice and the appropriate service, i.e. bmwcdapi.py --execservice climate

Supported Items

OH-Item Type Description
Bmw_Username String BMW ConnectedDrive username
Bmw_Password String BMW ConnectedDrive password
Bmw_Vin String 17 chars long VIN of the car
Bmw_Climate Switch Switch to call the service to climate the car
Bmw_LockDoors Switch Switch to lock the car
Bmw_UnlockDoors Switch Switch to unlock the car
Bmw_ForceUpdate Switch switch to update the values immediately
Bmw_accessToken String access token
Bmw_tokenExpires String Timestamp at which the accesstoken becomes invalid
Bmw_doorLockState String state of the door locks
Bmw_socMax Number maximum "state of charge" in kWh
Bmw_chargingLevelHv Number charging level in percent
Bmw_beRemainingRangeElectric Number remaining electric range in km
Bmw_beRemainingRangeFuel Number remaining fuel range in km
Bmw_mileage Number mileage
Bmw_chargingSystemStatus String charging state
Bmw_updateTimeConverted String last status update from the car
Bmw_remainingFuel Number remaining fuel in l
Bmw_lastTripAvgConsum Number average consum of last trip in kWh
Bmw_lastTripAvgRecup Number average recuperation of last trip in kWh

Commandline parameters

If bmwcdapi.py is called without parameters, the current values will be queried from ConnectedDrive and propagated to openHAB.

parameter long parameter short Description
--help -h show commandline help
--printall -p print all values, usefull for debuging or just for exploring
--execservice <service> -e execute service service may be one of
  • climate,
  • lock,
  • unlock,
  • light,
  • horn
--sendmesg <subject> <message> -s send a message to the car

Return codes

return code Description
0 OK
13 EACCES Permission denied
62 ETIME, Timeout
70 ECOMM, Communication error

Screenshot

screenshot of the OH basic gui

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.