Files
dsmr2mqtt/README.md
2025-03-22 17:20:52 +01:00

2.0 KiB

DSMR 2 MQTT bridge

Introduction

This bridigng component reads Dutch Smart Meter Requirements (DSMR) telegrams and sends them to a MQTT broker using the Homie convention. The component is written in Python and is based on the execelent work of others:

Configuring the bridge

Create some environment variables (e.g. with a .env file) to specify the required settings:

PYTHONPATH="."
MQTT_HOST=<mqtt-broker-hostname>
DSMR_PORT=/dev/ttyUSB0
DSMR_PROTOCOL=V5

If you have forwared the raw serial signal through ser2net, you should use DSMR_PORT=tcp://<hostname>:<port>, e.g.:

DSMR_PORT=tcp://forwarding-pi.local:3334

If you use credentials to access the MQTT broker, then alsp specify:

MQTT_USERNAME=<mqtt-user>
MQTT_PASSWORD=<mqtt-password>

Inspect the source settings.py to find out about the other less frequently used settings.

Configuring ser2net

On the forwarding computer (e.g a Raspberry Pi) you need to install ser2net:

sudo apt upgrade && sudo apt install ser2net

Then edit the configurion file /etc/ser2net.yaml and add

connection: &Dsmr
    accepter: tcp,3334
    connector: serialdev,
      /dev/ttyUSB0,
      115200n81, local

Works with Homie

Build

You can run the app directly from Python, after installing the modules with poetry:

pip install poetry
poetry install --without dev --no-root
python -m dsmr2mqtt

Alternatatively, you can use the supplied Dockerfile to build a Docker container to run app.

Building for docker hub can be done with:

VERSION=0.5.1
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag git.etxean.net/ardkuijpers/dsmr2mqtt:$VERSION --tag git.etxean.net/ardkuijpers/dsmr2mqtt:latest .