MQTT client for Belgian and Dutch Smart Meter (DSMR) - "Slimme Meter". Written in Python 3.x
Connect Smart Meter via a P1 USB cable to e.g. Raspberry Pi.
Application will continuously read DSMR meter and parse telegrams. Parsed telegrams are send to MQTT broker.
Includes Home Assistant MQTT Auto Discovery.
In dsmr50.py
, specify:
A typical MQTT message broadcast looks like:
{
"V1":226.0,
"V2":232.0,
"V3":229.0,
"database":"dsmr",
"el_consumed":24488767.0,
"el_returned":21190375.0,
"p_consumed":1130.0,
"p_generated":0.0,
"serial":"33363137",
"timestamp":1642275125
}
A virtual DSMR parameter is implemented (el_consumed and el_returned, which is sum of tarif1 and tarif2 (night/low en day/normal tariff)) - as some have a dual tarif meter, while energy company administratively considers this as a mono tarif meter.
Install following python3 libraries
Test if P1 adapter is functional and is providing dsmr data by running in a bash shell:
tail -f /dev/ttyUSB0
sudo chmod o+rw /dev/ttyUSB0
Results should be similar to:
tail -f /dev/ttyUSB0
/Ene5\T210-D ESMR5.0
1-3:0.2.8(50)
0-0:1.0.0(240204171638W)
0-0:96.1.1(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
1-0:1.8.1(024790.294*kWh)
1-0:1.8.2(011140.310*kWh)
1-0:2.8.1(010474.138*kWh)
1-0:2.8.2(025578.620*kWh)
.....
.....
Install Python3 packages per recommendation for your distro
Install from github and configure:
In systemd/dsmr-mqtt.service
:
/opt/iot/dsmr
)sudo cp -p systemd/dsmr-mqtt.service /etc/systemd/system
Copy config.rename.py
to config.py
and adapt for your configuration (minimal: mqtt ip, username, password)
sudo systemctl enable dsmr-mqtt
sudo systemctl start dsmr-mqtt
And check if it is running properly
user@server:/opt/dsmr2mqtt $ sudo systemctl status dsmr-mqtt
dsmr-mqtt.service - P1 dsmr smartmeter
Loaded: loaded (/etc/systemd/system/dsmr-mqtt.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2023-09-26 22:21:06 CEST; 18h ago
Main PID: 1026 (dsmr-mqtt.py)
Tasks: 6 (limit: 1595)
CPU: 56.349s
CGroup: /system.slice/dsmr-mqtt.service
└─1026 /usr/bin/python3 /opt/dsmr2mqtt/dsmr-mqtt.py
Use
http://mqtt-explorer.com/ to test & inspect MQTT messages
A test/dsmr.raw
simulation file is provided.
Set PRODUCTION = False
in config.py
to use the simulation file. No P1/serial connection is required.
Tested under Debian/Raspbian.
Tested with DSMR v5.0 meter in Netherlands and Belgium. For other DSMR versions, dsmr50.py
needs to be adapted.
For all SMR specs, see netbeheer
For Belgium/Fluvius, open your P1 port through Fluvius portal:
For encrypted P1/dsmr, there is a fork available.
GPL v3
4.0.2
4.0.1
4.0.0
3.0.0
2.0.0 - 2.0.1
1.0.13
1.0.12
1.0.2 - 1.0.4:
1.0.0: