Giter Site home page Giter Site logo

wywywywy / bmw_cd_exporter Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 2.0 23 KB

BMW Connected Drive exporter for Prometheus

License: Apache License 2.0

Dockerfile 6.77% Python 93.23%
prometheus prometheus-exporter python bmw bmw-connecteddrive bimmer-connected

bmw_cd_exporter's Introduction

BMW Connected Drive exporter for Prometheus.io, written in Python 3.

This exporter uses M1n3rva's bimmer_connected library.

Usage

Arguments

usage: bmw_cd_exporter.py [-h] [--user [email protected]] [--password abc123]
                    [--port 9488] [--region rest_of_world]

BMW Connected Drive exporter for Prometheus available arguments:

optional arguments:
-h, --help            show this help message and exit
--user [email protected]  Username (email address) for logging on to BMW
                      Connected Drive
--password abc123     Password for logging on to BMW Connected Drive
--port 9488           Exporter listens on this port
--interval 5          Polling interval in minutes
--region rest_of_world
                      BMW Connected Drive region
                      (north_america/china/rest_of_world)
--attributes attributes.json
                      Override path to the JSON file containing all 
                      attributes (optional)

Environment Variables

The arguments can also be set as env variables instead. Useful if you're using it in a Docker container.

  1. BMWCD_USER
  2. BMWCD_PASSWORD
  3. BMWCD_REGION
  4. BMWCD_PORT
  5. BMWCD_INTERVAL

Notes on Region

Note that the region must be one of the 3.

  1. north_amercia
  2. china
  3. rest_of_world

The default is rest_of_world.

Installation

From Source

git clone [email protected]:wywywywy/bmw_cd_exporter.git
cd bmw_cd_exporter
pip install -r requirements.txt

Use pip3 if your pip is for Python 2.

With Docker

docker run -d --restart=always -p 9488:9488 -e "[email protected]" -e "BMWCD_PASSWORD=abc123" -e "BMWCD_REGION=rest_of_world" wywywywy/bmw_cd_exporter:latest

Change the environment variables to what you need.

Prometheus Config

Add this to prometheus.yml and change the IP/port if needed.

- job_name: 'bmw_cd_exporter'
    metrics_path: /
    static_configs:
    - targets:
        - '127.0.0.1:9488'

Notes

It supports multiple vehicles in the same BMW Connected Drive account.

Please make sure the pooling rate to set to maybe once every couple of minutes, to avoid overloading BMW's servers. Default is 5.

Currently supported metrics are -

  1. mileage
  2. remaining_range_total
  3. remaining_range_electric
  4. remaining_range_fuel
  5. remaining_fuel
  6. charging_level_hv

If there's anything you want to add, let me know by submitting an issue, or just edit the JSON file directly.

The units seem to be in metric rather than imperial no matter where the vehicle is.

This obviously isn't endorsed by BMW, and they don't have a public API. So they could make breaking changes any time. Remember to not rely on this exporter for anything critical.

TODO

  1. Docker
  2. More metrics

Contributing

Yes, contributions are always welcome.
Fork it & submit a pull request.

License

This is licensed under the Apache License 2.0.

Disclaimer

This project is not affiliated with or endorsed by BMW Group.

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.