Skip to main content

Unix daemon and supporting models for publishing data from Diematic DeDietrich boiler

Project description

diematic

A Unix service written in Python to monitor De Dietrich boiler equiped with Diematic system using Modbus RS-845 protocol. The service reads data from the boiler and makes it available to be consumed in four ways:

  • Optionally, the values fetched from the boiler are sent to an InfluxDB database.
  • Optionally, the values fetched from the boiler are sent to an MQTT broker.
  • Optionally, a RESTful web server is installed and values can be obtained using GET and modified using POST requests.
  • Optionally, boiler parameters can be changed from the mqtt topics

Screenshot Screenshot

Hardware requirements

  • A De Dietrich boiler with Diematic regulation and a mini-din socket
  • A mini-din cable
  • A RS-845 to USB adapter
  • A nano-computer with a USB port and Python3 installed (Raspberry pi or similar)

Check tutorials in the "references" section below on how to do the hardware setup.

Changes from version 2.X

  • Added support to integrate with mqtt broker
  • Added command line parameters with priority over provided values in the configuration file

Http server

Satrting from version 3.0 the web server can be configured from the diematic.yaml configuration file by adding an http key as follows:

http:
    address: 0.0.0.0
    port: 8080

Once the service is running head to:

http://{HOSTNAME}:{PORT}/diematic/parameters

you can have access to all parameters indicated in the configuration file. Read the webserver.py documentation to know more about it.

MQTT

Starting from version 3.0 the service can be configured to send data to an MQTT broker. The broker configuration goes in the diematic.yaml configuration file as follows:

mqtt:
  broker: your broker server
  port: 1883
  user: your mqtt user, optional
  password: your mqtt user credentials
  retain: false
  tls: false
  topic: diematic2mqtt/boiler
  discovery:
    prefix: homeassistant

If there is no mqtt key, mqtt will not be considered at all. Under the mqtt key only broker key is required. The value is the broker ip address or host name that can be resolved using dns. The port default value is 1883 or 8883 if tls key is set to true. If provided, the user and password keys are used to open connection to the broker. retain can be used to inform the broker to retain the values. topic key can be used to configure the topic under wich all information will be set. if discovery key is set, the server will publish MQTT Discovery information to the broker. The prefix key indicates the topic under wich home assistant is subscribed to receive MQTT Discovery information.

Installation

git clone https://github.com/IgnacioHR/diematicd.git
cd diematicd
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
mkdir /etc/diematic
cp diematic.yaml /etc/diematic
cp diematicd.service /etc/systemd/system
systemctl enable diematicd
systemctl start diematicd

Test

Run python3 diematicd.py --help

usage: diematicd.py [-h] [-b {none,configured,influxdb,mqtt}] [-d DEVICE] [-f]
                    [-l {critical,error,warning,info,debug}] [-c CONFIG]
                    [-w HOSTNAME] [-p PORT] [-s {loop,web,both}] [-a ADDRESS]
                    [-t {Raw,DiematicOneDecimal,DiematicModeFlag,ErrorCode,DiematicCircType,DiematicProgram,bit0,bit1,bit2,bit3,bit4,bit5,bit6,bit7,bit8,bit9,bitA,bitB,bitC,bitD,bitE,bitF}]
                    {status,start,stop,restart,reload,runonce,readregister}

positional arguments:
  {status,start,stop,restart,reload,runonce,readregister}
                        action to take

optional arguments:
  -h, --help            show this help message and exit
  -b {none,influxdb}, --backend {none,influxdb}
                        select data backend (default is influxdb)
  -d DEVICE, --device DEVICE
                        define modbus device
  -f, --foreground      Run in the foreground do not detach process
  -l {critical,error,warning,info,debug}, --logging {critical,error,warning,info,debug}
                        define logging level (default is critical)
  -c CONFIG, --config CONFIG
                        alternate configuration file
  -w HOSTNAME, --hostname HOSTNAME
                        web server host name, defaults to 0.0.0.0
  -p PORT, --port PORT  web server port, defaults to 8080
  -s {loop,web,both}, --server {loop,web,both}
                        servers to start
  -a ADDRESS, --address ADDRESS
                        register address to read whe action is readregister
  -t {Raw,DiematicOneDecimal,DiematicModeFlag,ErrorCode,DiematicCircType,DiematicProgram,bit0,bit1,bit2,bit3,bit4,bit5,bit6,bit7,bit8,bit9,bitA,bitB,bitC,bitD,bitE,bitF}, --format {Raw,DiematicOneDecimal,DiematicModeFlag,ErrorCode,DiematicCircType,DiematicProgram,bit0,bit1,bit2,bit3,bit4,bit5,bit6,bit7,bit8,bit9,bitA,bitB,bitC,bitD,bitE,bitF}
                        value format to apply for register read, default is
                        Raw

InfluxDB preparation

Minimal

CREATE DATABASE "diematic"
CREATE USER "diematic" WITH PASSWORD 'mySecurePas$w0rd'
GRANT ALL ON "diematic" TO "diematic"
CREATE RETENTION POLICY "one_week" ON "diematic" DURATION 1w REPLICATION 1 DEFAULT

Additionnal steps for down-sampling

CREATE RETENTION POLICY "five_weeks" ON "diematic" DURATION 5w REPLICATION 1
CREATE RETENTION POLICY "five_years" ON "diematic" DURATION 260w REPLICATION 1

CREATE CONTINUOUS QUERY "cq_month" ON "diematic" BEGIN
  SELECT mean(/temperature/) AS "mean_1h", mean(/pressure/) AS "mean_1h", max(/temperature/) AS "max_1h", max(/pressure/) AS "max_1h"
  INTO "five_weeks".:MEASUREMENT
  FROM "one_week"."diematic"
  GROUP BY time(1h),*
END

CREATE CONTINUOUS QUERY "cq_year" ON "diematic" BEGIN
  SELECT mean(/^mean_.*temperature/) AS "mean_24h", mean(/^mean_.*pressure/) AS "mean_24h", max(/^max_.*temperature/) AS "max_24h", max(/^max_.*pressure/) AS "max_24h"
  INTO "five_years".:MEASUREMENT
  FROM "five_weeks"."diematic"
  GROUP BY time(24h),*
END

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diematic_server-3.6.0.tar.gz (27.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diematic_server-3.6.0-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file diematic_server-3.6.0.tar.gz.

File metadata

  • Download URL: diematic_server-3.6.0.tar.gz
  • Upload date:
  • Size: 27.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for diematic_server-3.6.0.tar.gz
Algorithm Hash digest
SHA256 535af987d84e14336eb756afd8f86d19f26884ab5e0792f5cc81909f4570dc74
MD5 9e3b1d4e5406477f9984c3ba150556e9
BLAKE2b-256 b6e470023ab833c47809fa43b637cf135d51844d44b24d37a5805b393456f3fe

See more details on using hashes here.

File details

Details for the file diematic_server-3.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for diematic_server-3.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 78b76ca3b5d9dde05abe6ed8ad5d16ac43441153b85e11f8e637276ff09f56f8
MD5 952df6b9e01daf071dc41a5f377fcc66
BLAKE2b-256 3674798400aa8ed7460f28fed44520c3c74c456723d75c15defe16dc3eeda0e3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page