Raspberry Pi based home monitoring dashboard
docker compose up --build
Run scripts direclty:
cd ./databot
LOGLEVEL=DEBUG INFLUX_URL=http://localhost:8086 PIPENV_DOTENV_LOCATION=../.env pipenv run python3 render.py
cd ./databot
INFLUX_URL=http://localhost:8086 ts-node index.ts -c ../.env -d
For some reason the pipenv
in the Docker environment won't work. Thus a requirements.txt
file is used. To update it run pipenv run pip freeze > requirements.txt
.
Although a migration is performed when smartmeter data is fetched the first time, you can trigger a manual migration with following command:
docker compose run --rm databot databot --migrate
This task is performed automatically via a cron job
docker compose run --rm databot python3 render.py --archive
Query all data:
from(bucket: "smartmeter")
|> range(start: v.timeRangeStart, stop:v.timeRangeStop)
|> filter(fn: (r) =>
r._measurement == "meteredValues" and
r._field == "value"
)
Split in 6h time windows:
from(bucket: "smartmeter")
|> range(start: v.timeRangeStart, stop:v.timeRangeStop)
|> filter(fn: (r) =>
r._measurement == "meteredValues" and
r._field == "value"
)
|> aggregateWindow(every: 6h, offset: -12h, fn: mean)
from(bucket: "smartmeter")
|> range(start: time(v: "2022-07-10T23:45:00Z"), stop: time(v: "2022-07-18T00:00:00Z"))
|> filter(fn: (r) =>
r._measurement == "meteredValues" and
r._field == "value"
)
//|> aggregateWindow(every: 6h, createEmpty: false, offset: -12h, fn: mean)
//|> count()
-
Install
Raspberry Pi OS Lite (64-Bit)
-
Install
Docker
(see Install Docker Engine on Debian for latest instructions, at this time the Install using the convenience script section must be used for Raspberry Pi):curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh # Let the logged-in user use `docker` without `sudo` sudo usermod -aG docker ${USER}
-
(Optional) Make Raspian OS auto-update itself (confirm with
Yes
in the configuration)sudo apt-get install unattended-upgrades keychain # keychain for password protected ssh keys sudo dpkg-reconfigure -plow unattended-upgrades
-
Prepare Kindle (see below)
-
Setup USB network with Kindle (must be attached and prepared with
USBNetwork
)TODO: Make
ifconfig usb0 ...
better since it's always set in the cron job, maybe https://www.mobileread.com/forums/showthread.php?t=342904 helps.On the raspberry add the following with
sudo nano /etc/dhcpcd.conf
:# Kindle via USBNetwork interface usb0 static ip_address=192.168.15.244/24 static routers=192.168.15.1
Then
sudo reboot
.Generate a ssh keypair with
ssh-keygen -t ed25519
If you're using a password you can add it to
ssh-agent
:ssh-add ~/.ssh/id_ed25519
This key must be added to the Kindle (see below).
Start the interface with (actually only needed if you want to manually ssh into the Kindle. It's handled by the cron job)
sudo ifconfig usb0 192.168.15.201
Make the the kindle cron script executable with
chmod u+x <absolute path to clone git repot>/kindle_cron.sh
add following cronjob withcrontab -e
:*/15 * * * * <absolute path to clone git repot>/kindle_cron.sh
Clone this repo and create a ./.env
in the app folder with following content:
USERNAME=...
PASSWORD=...
METER_ID=...
INFLUX_ORG=ulrichlehner
INFLUX_BUCKET=smartmeter
INFLUX_TOKEN=<genereate a secure token string>
TZ=Europe/Vienna
DOCKER_INFLUXDB_INIT_USERNAME=admin
DOCKER_INFLUXDB_INIT_PASSWORD=<generate a secure password>
DOCKER_INFLUXDB_INIT_ORG=ulrichlehner
DOCKER_INFLUXDB_INIT_BUCKET=smartmeter
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=<genereate a secure token string>
The variables INFLUX_BUCKET
and DOCKER_INFLUXDB_INIT_BUCKET
must have the same value, as well as INFLUX_TOKEN
= DOCKER_INFLUXDB_INIT_ADMIN_TOKEN
and INFLUX_ORG
= DOCKER_INFLUXDB_INIT_ORG
.
These instructions are only tested with the software and hardware version as above! If you have a different hardware / software setup you'll have to find instructions for your case.
-
The firmware 5.6.1.1 has to be downgraded following these instructions How to Downgrade PW 1 ca from 5.6.1.1 to 5.3.3 and maybe PW2.
- Keep WiFi off / enable airplane mode
- Download the firmare 5.3.3 https://s3.amazonaws.com/G7G_FirmwareUpdates_WebDownloads/update_kindle_5.3.3.bin and upload it via USB to the Kindle's root folder (if it doesn't work you might try version 5.3.1 via http://kindle.s3.amazonaws.com/update_kindle_5.3.1.bin)
- Push and hold power button the device restarts (you can release the button when the power LED turned off) and wait for the update (keep the device connected to the computer until the update is done!)
-
Install the jailbreak as described in Kindle Touch/PW1/PW2 5.0.x - 5.4.4.2 JailBreak. Plus FW 5.x USBNetwork.
- Download https://storage.gra.cloud.ovh.net/v1/AUTH_2ac4bfee353948ec8ea7fd1710574097/mr-public/Touch/kindle-jailbreak-1.16.N-r18869.tar.xz
- Unpack
kindle-5.4-jailbreak.zip
and upload the files of the extracted folder to the Kindle's root directory - Disconnect the USB and Update Kindle from the settings
- If it worked you should see the message
**** JAILBREAK ****
appear :)
-
Install KUAL (maybe also KUAL+)
- Download https://storage.gra.cloud.ovh.net/v1/AUTH_2ac4bfee353948ec8ea7fd1710574097/mr-public/KUAL/KUAL-v2.7.26-g32b2e39-20220213.tar.xz
- Extract and put
KUAL-KDK-2.0.azw2
into Kindlesdocuments
folder - Open the new "book"
-
Install MR Package Installer
- Download https://storage.gra.cloud.ovh.net/v1/AUTH_2ac4bfee353948ec8ea7fd1710574097/mr-public/KUAL/kual-mrinstaller-1.7.N-r18896.tar.xz
- Extract and put
extensions
(withMRInstaller
) into Kindle's root folder (or replace / merge theextensions
folder if it exists)
-
Install the USB Network hack
- Download https://storage.gra.cloud.ovh.net/v1/AUTH_2ac4bfee353948ec8ea7fd1710574097/mr-public/Touch/kindle-usbnet-0.22.N-r18897.tar.xz
- Upload the file
Update_usbnet_0.22.N_install_touch_pw.bin
to the Kindle's rootmrpackages
folder (create it if it doesn't exist) - Open
KUAL
app and use theHelper / Install MR Packagages
action - There should be
USBNetwork
listed inKUAL
-
Apply following settings in
KUAL / USBNetwork
:Enable SSH at boot Make dropbear quiet Toggle USB Network
-
Add the Rasperry Pi's public SSH key to
/mnt/us/etc/authorized_keys
(the file must be created manually if it doesn't exist)