I’d like to share how I managed integrate an M-Bus connected water meter into HA. M-Bus or Meter-Bus is a specification for a serial bus and communication protocol that is popular for smart meters. These meters usually have long-lasting batteries (10 years+) that will last even longer when the meter can draw power from the bus. In this way the meter has a persistent counter value, and one doesn’t miss any counts, even if the meter is not read for a while.
Unfortunately most M-Bus interfaces are quite expensive, but a cost-effective solution is available for the Raspberry Pi as a so-called Hat from packom.net. They also provide a RESTful server mbus-httpd) that runs on the Raspi, which in turn can be integrated into HA via the rest platform. The RESTful server returns XML formatted meter data (in my case counted water volume, timestamp, etc.), without requiring any instructions. Apparently the M-Bus interface provides the server with all of this information.
I am running HA OS on a different Raspi than the one that runs the RESTful server. The respective part of my configuration.yaml looks roughly as follows:
# water meter
- platform: rest
resource: http://raspberrypi.home:8080/mbus/get/ttyAMA0/2400/0
method: POST
name: "water meter"
value_template: "{{ value_json.MBusData.DataRecord[0].Value | int }}"
unit_of_measurement: "l"
scan_interval: 60
The resource URL is straight from the mbus-httpd. I had to play around a bit with the proper value_template to extract the one value I am interested in from the JSON-converted XML. HA’s template test page was quite helpful in this respect.
not really, that would be quite a few steps, depending on what you already have in terms of hardware and software. Do you already have an M-bus interface? If yes, which kind?
Thanks for your reply. Actually I’ve realized that my water meter supports wireless M-Bus. I don’t have an interface yet, therefore I’m trying to understand what’s the best approach for my use case.
unfortunately I have no experience with wireless M-bus. I suppose once you have a device to read the wirless M-bus, it will be possible to hook that into HA.
I am looking to achieve the same to read my instant/daily/montly water consumption through Home Assistant.
I have this [1] Pulse meter on my counter (which is therefore covered) installed by my water provider, and I wanted to know if I can do something with it, or if there are other effective/working solutions to do so.