/MijnKia

Python MijnKia E-Niro model 2019 get statistics from MijnKia App and send them to InfluxDB and/or ABRP (including weather)

Primary LanguagePython

Python MijnKia E-Niro model 2019 get statistics from MijnKia App
Send stats to InfluxDB (for graphing with Grafana) and/or ABRP (including weather info) and/or a MQTT broker

Install the script and ini file in path "/MijnKia/" or change the "filepath" parameter in the script and the path in below example service file. Otherwise it cannot find the ini file with your settings for MijnKia/InfluxDB/ABRP/Openweathermap and the service wont start.

Programmed and tested with Python2, running it on a VM with Ubuntu (also tested on Rasperry PI 3).
To use the MQTT option, you will need to install Paho MQTT by using the following command: pip install paho-mqtt (https://pypi.org/project/paho-mqtt/)

The settings to be specified in the inifile:
[MijnKia]
loginEmail=[email address to login to MijnKia] [required]
LoginPassword=[password for MijnKia] [required]

[Influx]
InfluxDBServer=[FQDN or ip address] [optional]
InfluxDB=[DB name to put the data in] [optional]

[ABetterRoutePlanner]
abrp_token=[Login to ABRP website, setup live data, choose Torque Pro and find the field with the email ID, looks like: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx] [optional]
car_model=kia:niro:19:64:other
ProvideLocationToABRP=NO [To provide the location of the car to ABRP specify YES. Better to override it in the app and use your phone's location which updates far more frequently] [optional]
OpenWeatherMapAPIKey=[Register an account on OpenWeatherMap and get API Key] [optional]

[MQTT]
host=[broker hostname or IP]
port=[prot used to connect to broker. the default is 1883]
username=[username to connect to broker] [optional]
password=[password to connect to broker] [optional]
mainTopic=[Name for the main topic to hold returned data] [optional]

I have created a service for it with the following:
####################### MijnKia.py starten ###########################
sudo tee -a /lib/systemd/system/MijnKia.service <<EOF
[Unit]
Description = MijnKia service
After = network-online.target
Wants = network-online.target

[Service]
User = root
Group = root
Type = simple
ExecStart = /usr/bin/python /MijnKia/MijnKia.py
Restart = on-failure
RestartSec = 30

[Install]
WantedBy = multi-user.target
EOF

systemctl enable MijnKia.service
systemctl daemon-reload
service MijnKia status

Have fun with it :-) -Bas

PS: this script is written for the Netherlands part of Kia https://www.kia.com/nl/mijnkia/dashboard/. Don't know if it works for other countries