Skip to content

DSMR integration

Jan Bouwhuis edited this page Jun 3, 2021 · 3 revisions

Omnik data logger now supports connection a energy meter conform the Dutch Smart Meter Requirements. The python library of Niger Dokter is used to parse the telegrams received over the P1 connector of the Smart Meter.

Connecting you Smart Meter

To be able to read out the P1 port you need a suitable serial adapter like this one at the store of SOS-solutions or if you have some patience you can get one at AliExpress, like this article I ordered my self.

This adapter type connects easy to a raspberry pi. On Linux usually this adapter can be opened as /dev/ttyUSB0, on Windows you will need te know the COM-port that has been assigned.

Omnik data logger supports multiple DSMR adapters to start you need to add the [dsmr] section to your config and add the terminals key. This key holds the list of configured DSMR terminals. E.g. terminals=term1, term2 Let state you have only one smart meter to connect, your config could be:

[term]
terminals=term1

[term.term1]
# further configuration

For each terminal you add a config section is added like in the example above `[term.{terminalname}]'. Add a key for your plant to enable the calculation of consumption data for your plant.

Read out a directly connected adapter

If Omnik data logger runs at the same device the adapter is connected to, then you use the DSRM device mode. This will work out of the box if your adapter was recognized as /dev/ttyUSB0. To configure another usb device configure it like:

[term]
terminals=term1

[term.term1]
device=/dev/ttyUSB1

Read out a remote connected adapter

Using the tcp mode it is possible to readout a remote connected P1 adapter. The default dsmr mode is device, you need to change that to tcp and further you can configure the host key (default=localhost) and port key (default=3333).

[term]
terminals=term1

[term.term1]
mode=tcp
host=192.168.1.10
port=3333

To create a remote connectable P1 adapter you could use ser2net.

Ser2net is a simple program that extents your serial connection over tcp. I have used the Docker edition of jsurf, since this can be added easily to the existing Docker based Home Assistant Setup using Portainer.

The 3.5 version of Ser2net allows an option for multiple connections. This makes it possible to monitor and debug using one adapter. The last line of my ser2net.conf file look like:

3333:raw:600:/dev/ttyUSB0:115200 NONE 1STOPBIT 8DATABITS XONXOFF LOCAL -RTSCTS max-connections=3

This enables ser2net at port 3333. Note that you might need to change bitrate or parity (=NONE in config). This setup should work for DSMR 4.2 / 5 / 5B compliant meters. If you own and older model that supports DSMR 2.2 the following setup might work.

3333:raw:600:/dev/ttyUSB0:9600 EVEN 1STOPBIT 7DATABITS XONXOFF LOCAL -RTSCTS max-connections=3

This sets the baudrate at 9600 bps and enables even parity.

If you run an older version of Ser2Net of if you only want a single connection, then omit the max-connections parameter at the and, since this might result in a syntax error for Ser2Net versions before 3.5.

Gasmeter data

The gasmeter data (if available) will be processed by default. To disable set the gas_meter key at the terminal section to false.

DSMR data published

When you DSMR adapter is setup correctly, this will publish additional data for electricity and gas meter to MQTT and/or InfluxDB plugins. You can customize the data beging published by editing the data_field.json but are strongly advised to make a copy and configure the new path using the persistant_cache_file key in the the dafault section. Renaming the fields (MQTT only) can be done by in the configuration. The gas meter data will be published as a separate device in MQTT.

Combining your Omnik solar and DSMR data and publishing to pvoutput.org

Omnik data logger will check for the latest DSMR data when a solar update is processed. The last 9 DSMR measurements will be kept in memory to be able to find the best fitting match with the solar data. The DSMR data contains netto consumption data. You solar system gives the bruto generation data. The energy that is used directly is calculated and added to the energy delivered to the net to calculate the total consumption. The pvoutput plugin will publish the bruto power consumption and bruto energy consumption. The total consumption calculated is the cumulative net consumption (all tariffs) and direct consumption. It is possible to calibrate the total cumulative consumption to start at the installation date of your smart meter. Configure the total_energy_offset key to set the total_energy generated during install. The value (float) of this key will be substracted from the the total_energy value read form your Omnik system. Finally the calculated data will also be published to MQTT and InfluxDB (in MQTT auto discovery as a separate device) if you have configured these output plugins.