Home

Awesome

<font size="-1">

Docker Pulls Docker Stars GitHub Build Status GitHub Stars Donate <br><br> "Buy Me A Coffee"

DSMR-reader - Docker

DSMR-protocol reader, telegram data storage and energy consumption visualizer. Can be used for reading the smart meter DSMR (Dutch Smart Meter Requirements) P1 port yourself at your home. You will need a cable and hardware that can run Docker. Free for non-commercial use.


Table of contents


General info

The purpose of this project is to provide a simplified installation of DSMR-reader using all the benefits of Docker.

Contribution

Special thanks to the following persons for their great contribution(s) @dennissiemensma @bjw-s @Caroga mchangsp


Screenshots

Example screenshot


Technologies

* Docker >= 20.x
* Python 3.x
* Postgres >= 13.x, max 16.x
* MySQL ??.?? (untested by me)

Releases

This is a multi-arch image and will also run on a Raspberry Pi or other Docker-enabled ARMv6/7/8 devices.

Image TagArchitecturesImage OS
latestamd64, arm32v6, arm32v7, arm64v8Alpine Linux 3.19
developmentamd64, arm32v6, arm32v7, arm64v8Alpine Linux 3.19

Docker tags/releases can be found here: https://hub.docker.com/r/xirixiz/dsmr-reader-docker/tags?page=1&ordering=last_updated


Setup / parameters

  # Default inside the container nginx is running on port 80.
  # In some cases (host network f.e.), some people requested to be able to change the default listen port.
  # However, in most cases this setting isn't being used.
  NGINX_LISTEN_PORT=80
  # Default nginx generated access logs.
  # In some cases you want to disable this, because f.e. you use a reverse proxy which also generated access logs
  DISABLE_NGINX_ACCESS_LOGS=true
# Enables port 443 for nginx
# /etc/ssl/private/fullchain.pem and /etc/ssl/private/privkey.pem are required to be mounted!
ENABLE_NGINX_SSL=false
  # ENABLE HSTS on SSL: https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security
  ENABLE_NGINX_ENABLE_HSTS=false
# Redirect HTTP traffic to HTTPS
ENABLE_NGINX_SSL_REDIRECT=false

Nginx .httpassword:

ENABLE_HTTP_AUTH=false
HTTP_AUTH_USERNAME=
HTTP_AUTH_PASSWORD=

It's not possible to combine those settings!!!:

ENABLE_NGINX_SSL
NGINX_LISTEN_PORT

The --no-healthcheck argument should only be used when the containers function NOT presenting the DSMR Reader webinterface, for example the datalogger sender mode. By default this argument should not be used!

You can set any environment variable from a file by using a special prepend FILE__.

As an example:

services:
    some_service:
    image: some_image
    environment:
        FILE__SECRET: /run/secrets/a_secret_file
    secrets:
        - a_secret_file

secrets:
    a_secret_file:
        file : somedir/my_secret.txt

Basiccally, the bottom secrets section mounts my_secrets.txt as /run/secrets/a_secret_file. The secrets section under the service authorize the service to use the a_secret_file secret. The environment variable FILE__SECRET tells the service what file to read to set/get the value of the environment variable SECRET.


DSMR-Reader - Docker and Homewizard P1 Meter Integration

This guide explains how to install and configure a DSMR Reader plugin to read Homewizard P1 telegrams and inject them into DSMR Reader.

Prerequisites

Plugin Preparation

Assumption(s):

On your Docker host:

  1. Create a folder /home/pi/dsmr/plugins

  2. Inside the folder /home/pi/dsmr/plugins, create a file homewizard_p1.py with the following contents (replace 1.2.3.4 with the Homewizard P1 meter IP address):

    import requests
    from django.dispatch import receiver
    from dsmr_backend.signals import backend_called
    import dsmr_datalogger.services.datalogger
    
    HOMEWIZARD_ENDPOINT = 'http://1.2.3.4:80/api/v1/telegram'
    HOMEWIZARD_TIMEOUT = 5
    
    @receiver(backend_called)
    def handle_backend_called(**kwargs):
        response = requests.get(HOMEWIZARD_ENDPOINT, timeout=HOMEWIZARD_TIMEOUT)
    
        if response.status_code != 200:
            print(' [!] HomeWizard plugin: v1 telegram endpoint failed (HTTP {}): {}'.format(response.status_code, response.text))
            return
    
        dsmr_datalogger.services.datalogger.telegram_to_reading(data=response.text)
    

Docker Setup

  1. Go to folder /home/pi/dsmr

  2. Edit your docker-compose.yaml file

  3. Add the following definition to the volumes: section:

    - ./plugins/homewizard_p1.py:/app/dsmr_plugins/modules/homewizard_p1.py
    
  4. Add the following definitions to the environment: section:

    - DSMRREADER_OPERATION_MODE=api_server
    - DSMRREADER_PLUGINS=dsmr_plugins.modules.homewizard_p1
    
  5. Save the docker-compose.yaml file

  6. To stop DSMR Reader, run:

    docker-compose down
    
  7. To start DSMR Reader, run:

    docker-compose up -d
    

Original Post

The original instructions are (partly in Dutch) on GitHub. The Python source code in the original post was missing an import statement. The instructions have been grouped together and translated into English.

For an alternative solution using Home Assistant automations, see this guide.


Features


Issues


Inspiration

Project inspired by the hard work and effort of @dennissiemensma


Contact

Created by @xirixiz - feel free to contact me!