PyVisionIQ is a Python tool designed to fetch data from the Hyundai/Kia Connect API, log it, and visualize key metrics of your electric vehicle. It also exposes data for Prometheus monitoring.
- Data collection regularly fetches:
- Charging level
- Mileage
- Battery health
- Driving range
- Location
- Data Logging: Stores fetched data in vehicle_data.csv (CSV).
- Prometheus Metrics: Exposes data via /metrics endpoint.
- Visualization:
- Interactive map (Folium) at /map
- Charging level plot at
/charge.png
- Mileage plot at
/mileage.png
- EV Driving Range plot at
/range.png
- Rate Limiting: Respects API limits to avoid blocks.
- Environment Variables: Secure configuration using .env file.
- Systemd Service: Easy deployment on Linux (pyvisioniq.service).
-
Python 3.x
-
Libraries: Install from requirements.txt:
pip install -r requirements.txt
-
Hyundai/Kia Connect Account
- Environment Variables: Create .env file:
Region & Brand: Find codes in hyundai_kia_connect_api docs.
BLUELINKUSER=your_username BLUELINKPASS=your_password BLUELINKPIN=your_pin BLUELINKREGION=your_region_code BLUELINKBRAND=your_brand_code BLUELINKVID=your_vehicle_id
- (Optional) Other Variables:
BLUELINKUPDATE: "True" to fetch data, "False" for dry run (default). BLUELINKLIMIT: API requests/day (default 30). BLUELINKPORT: Flask app port (default 8001). BLUELINKHOST: Flask app host (default '0.0.0.0'). BLUELINKCSV: CSV file path (default './vehicle_data.csv').
- Clone the repository:
git clone https://github.com/mhuot/pyvisoniq.git cd pyvisioniq
- Create and activate a virtual environment:
python -m venv venv source venv/bin/activate
- Dependencies:
pip install -r requirements.txt
- Systemd (Linux):
Copy pyvisioniq.service to /etc/systemd/system/
sudo systemctl enable pyvisioniq.service sudo systemctl start pyvisioniq.service
- Accessing Data Prometheus: http://your_host:8001/metrics Map: http://your_host:8001/map Plots: Charging: http://your_host:8001/range.png Mileage: http://your_host:8001/mileage.png
Ensure you have activated the virtual environment before running pylint
.
If you encounter import errors with pylint
, ensure that your environment is correctly set up and that the .pylintrc
file is present in the project root.
You can add the following to the .pylintrc
file to include the virtual environment's site-packages:
- Data updates run automatically respecting rate limits.
- Log file must be writable.
- Consider Gunicorn/uWSGI for production Flask.
- Customize map in code for advanced visuals.