My approach to M-Bus and Home Assistant

Hi,

As I struggled to find an easy m-bus implementation, I created marcofl / mbus2mqtt Home Assistant · GitLab today. It uses libmbus (GitHub - rscada/libmbus: Meter-bus library and utility programs) commands that you can freely define, you get a docker image with libmbus tools compiled to scan and play around - see README. Once you have a working command that gives you the xml for the meter you query, you simply use that command. then it sends all data records to mqtt including home assistant auto discovery.

It’s a proof-of-concept working for my use case, but it might be useful already, I don’t know.

What I do next here is either figure out how to map the units and scaling that are in the xml from libmbus into HA units (currently all sensors have no units) automatically or implement a config/mapping file / env vars to map sensors to units and scaling.

Ideas and questions welcome.
Or if there is a project that does already the same, please let me know. I know about GitHub - wmbusmeters/wmbusmeters: Read the wired or wireless mbus protocol to acquire utility meter readings., which does a bit of the same, but seems to only work with serial m-bus master devices (yes, I could use socat or similar to make a virtual serial port) and has the MQTT part not directly implemented and not for HA auto discovery - also the config file approach make it a bit harder to use in a more cloud native / kubernets setup (which I use).

btw. I considered writing this as an integration or App Daemon app using the HA API, but with libmbus being unmaintained for years (still working very well!) I don’t think it’s a good idea to compile and install that locally on a linux machine where HA runs.

Good evening
I would like to try out your solution.
Unfortunately I can’t get it to work on home assistant OS. I do not know the necessary terminal commands and unfortunately I have no experience with Linux.

Would it be possible for you to explain to me how I can install the whole thing?

I have installed home assistant on an Intel nuc.

Many thanks for your help.

What hardware are you using for wireless m-bus connection? I have a water meter and an energy meter from Zenner and want to get the data since several month but never found a guide how to put the things together to read the messages from the wireless m-bus.