Konsumo is a little home energy consumption chart OpenSource project
This project is based on Python, Flask, ApexCharts (apexcharts.com), SQLAlchemy, Pandas
A demo site is available at https://konsumo.virer.net/
First time, your have to create the SSL certificate, and initialize database
So here is a quick self-signed SSL certificate command example :
mkdir -p /opt/konsumo/ssl && openssl req -x509 -newkey rsa:4096 -keyout /opt/konsumo/ssl/key.pem -nodes -out /opt/konsumo/ssl/cert.pem -sha256 -days 3650 -subj='/CN=konsumo/'
Then start a mariadb container
podman pull docker.io/mariadb:10.11
podman run --rm -d --name mariadb -v /data/mariadb/:/var/lib/mysql/ --network host \
-e MARIADB_ROOT_PASSWORD="MyVerySecretPassword" \
-e MARIADB_DATABASE="konsumo" \
-e MARIADB_USER="konsumo" \
-e MARIADB_PASSWORD="MySecretPassword." \
mariadb:10.11
also initialize the DB using the following commands:
$ podman run -it docker.io/scaps/konsumo:<tag> /usr/local/bin/flask init-db
Listen connection on
-
HOST=0.0.0.0
-
PORT=8080
Google credentials settings for OAuth
-
GOOGLE_CLIENT_ID=
-
GOOGLE_CLIENT_SECRET=
Persistent database settings
-
DBHOST=127.0.0.1
-
DBUSER=root
-
DBPASS=password
-
DBNAME=konsumo
SSL Certificate settings
-
SSL_CRT=/ssl/cert.pem
-
SSL_KEY=/ssl/key.pem
Possible usage :
podman run --rm -v /opt/konsumo/ssl:/ssl \
--name konsumo \
-e HOST=0.0.0.0 \
-e PORT=8080 \
-e GOOGLE_CLIENT_ID="$GOOGLE_CLIENT_ID" \
-e GOOGLE_CLIENT_SECRET="$GOOGLE_CLIENT_SECRET" \
-e SECRET_KEY="$SECRET_KEY" \
-e DBHOST="mariadb" \
-e DBPORT="3306" \
-e DBUSER="konsumo" \
-e DBPASS="Konsum0Secre7P4s5woRd" \
-e DBNAME="konsumo" \
-e SSL_CRT="/ssl/cert.pem" \
-e SSL_KEY="/ssl/key.pem" \
docker.io/scaps/konsumo:latest $1 $2
-
Add support for various OAuth providers
-
Hash the emails stored in database to avoid any possible leak
Source of inspiration for the login part:
Google Login tutorial https://realpython.com/flask-google-login/