Insert DSMR P1 readings in a PostgreSQL database with TimescaleDB.
See the Docker Compose example for possible environment variables. NOTE: the image is only for amd64, not for Raspberry Pi (arm). Build the image yourself for these platforms.
name: p1postgres
services:
app:
image: mhvis/p1postgres
environment:
# See https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
P1_POSTGRES_DSN: postgresql://user:secret@localhost
# DSMR version. Possible values: V2_2, V4, V5.
P1_SERIAL_SETTINGS: V5
# Usually the same as serial settings.
P1_TELEGRAM_SPECIFICATION: V5
P1_DEVICE: /dev/ttyUSB0
# The meter ID in the database. The meter row should exist.
P1_METER_ID: 1
# Uncomment to see what's happening
#P1_DEBUG: 1
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
restart: unless-stopped
The required schema can be found in schema/create.sql
.
Use these SQL scripts to create the tables and insert rows for your meters and
energy contracts (to calculate cost information).
TODO: add interesting queries or views.