Modern electricity/gas meters in the Netherlands support the so-called DSMR standard(is it even a standard?), also known as Slimme meter, or P1 poort. One can easily find a FTDI-based “P1 cable” in many on-line Dutch shops (will not link to a particular one but a quick internet search on “P1 cable” or “P1 slimme meter kabel” will return more than enough results).
Since my home lab is nowhere close to the “meterkast”, I would have needed a really long USB cable… Instead, we can fix this with science! A quick search through my modest hardware pile produced a Raspberry Pi 1 (the original!), a short network cable, an SD card and a pl2303-based USB to TTL adapter (see Serial console on a Raspberry Pi), and the idea to use ser2net emerged, as the dsmr reader integration supports it.
Raspbian or anything as heavy as that would be overweight for this old board, so I went for OpenWRT, really lightweight (the final install uses around 14MB), and easy to configure.
I followed the official OpenWRT on Raspberry Pi docs for the installation, and performed the initial configuration (network, root password, etc) via the serial console. After making sure that the system can be reached via ssh, I moved it next to the smart meter.
To use the FTDI adapter, and ser2net, we need to install some prerequisites first:
opkg update opkg install ser2net opkg install kmod-usb-serial-ftdi
There’s already a (disabled)
ser2net config for
# uci show ser2net ... ser2net.@proxy=proxy ser2net.@proxy.enabled='0' ser2net.@proxy.port='5001' ser2net.@proxy.protocol='telnet' ser2net.@proxy.timeout='0' ser2net.@proxy.device='/dev/ttyUSB0' ser2net.@proxy.baudrate='115200' ser2net.@proxy.databits='8' ser2net.@proxy.parity='none' ser2net.@proxy.stopbits='1' ...
The ser2net proxy has been enabled, and some serial parameters had to be changed as my meter is an Iskra which uses the 2.2 version of DSMR::
root@OpenWrt:~# uci set ser2net.@proxy.enabled=1 root@OpenWrt:~# uci set ser2net.@proxy.protocol='raw' root@OpenWrt:~# uci set ser2net.@proxy.baudrate=9600 root@OpenWrt:~# uci set ser2net.@proxy.parity=even root@OpenWrt:~# uci set ser2net.@proxy.databits=7 root@OpenWrt:~# service ser2net enable root@OpenWrt:~# service ser2net start
telnet can be used to validate that this actually works (a “
telnet <ip> 5001” would return several lines of data every 10 seconds).
At this point, I could follow the DSMR integration docs to add the meter to HomeAssistant.
HomeAssistant has a Prometheus integration. Short config excerpt for exporting only the DSMR metrics to prometheus:
# configuration.yaml prometheus: namespace: hass filter: include_entity_globs: - sensor.energy_* - sensor.gas_* - sensor.power_consumption - sensor.power_production - sensor.power_tariff
It looks like there’s even a prometheus-node-exporter clone in OpenWRT, that can provide a bunch of system metrics (if you’re running Prometheus for your network monitoring of course):
opkg install prometheus-node-exporter-lua uci set prometheus-node-exporter-lua.main.listen_interface=lan service prometheus-node-exporter-lua enable