Giter Site home page Giter Site logo

keba_importer's Introduction

KEBA Wallbox Charge Importer for MySQL/MariaDB

These scripts are used to download a charge session report via Keba Wallbox's WebUI and import into a database. Optional you can import rfid cards and wallbox stations. Existing entries will not be overwritten.

Feel inspired to adapt them to your needs. I made it so simple as i can.

Prerequisites / Requirements

  • MariaDB/MySQL Database Server
  • Python3 with Modules from requirements.txt (BeautifulSoup, Requests, SQLAlchemy, Dotenv)
  • For an OS independent installation a Python virtual environment or python docker container
  • Tested with Keba P30 wallbox and rfid authentication

Script processing and workflow

  1. Open Wallbox WebUI
  2. Get CSRF Token and Login with Username/Password
  3. Charges: Request a csv export for the last 45 days and import new charges.
  4. RFID Cards: Call web api (json) and import rfid cards.
  5. Stations: Call web api (json) and import wallbox stations.

Credentials are stored in .env environment file. See installation example.

Installation Example

  1. Install OS Packages (MariaDB)
  2. Create database with custom user. You don't need to create tables by your self.
mysql -u root -p
CREATE DATABASE keba;
CREATE USER 'keba'@'localhost' IDENTIFIED BY 'secret-password';
GRANT ALL PRIVILEGES ON database.* TO 'keba'@'localhost';
FLUSH PRIVILEGES;
  1. Install Python3 Venv with Modules.
python3 -m venv .venv
source venv .venv/bin/activate
pip install -r requirements.txt
  1. Create configuration environment file .env.
# Wallbox Settings
KEBA_USER="admin"
KEBA_PASS="secret-password"
KEBA_HOST="192.168.1.1"

# Database Settings
DB_USERNAME="keba"
DB_PASSWORD="secret-password"
DB_DATABASE="keba"
DB_HOSTNAME="localhost"
DB_PORT=3306
  1. Modify shebang (first line) on get_report.py for your python venv (Example: #!/opt/keba/.venv/bin/python3)
  2. Optional: Modify your import time range from lib/keba.py def gen_unix_date(days: int = 45).
  3. Tables structures automatically created on first use.

Execution

./get_report.py -h
usage: get_report.py [-h] [-c] [-r] [-s] [-w] [-v]

Keba Importer v20240101

options:
  -h, --help     show this help message and exit
  -c, --charge   import charge sessions from last 45 days
  -r, --rfid     import rfid cards
  -s, --station  import wallbox stations
  -w, --write    write reports to json files
  -a, --all      full import charges, stations, rfid cards
  -v, --version  show program version
# Import Charge Sessions
./get_report.py -c

# Import RFID Cards
./get_report.py -r

# Import Wallbox Stations
./get_report.py -r

Cron Task Example

Daily Session Import, Cronjob 10.30

30 10 * * * /opt/keba/get_report.py -c

keba_importer's People

Contributors

itupdev avatar

Watchers

 avatar

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.