Recently I got a new water meter installed due to the German “Eichrecht”. While I never finished hooking up the old Cyble sensor I took this event to do so for the new Sensus HRI. I’ve found this sensor (Sensus HRI-B4/8L), matching my water meter, online and for local pick-up. Since both sensors are using M-Bus I could use the existing USB interface (USB - MBUS available at e.g. aliexpress).
Sensus HRI supports impulse reading as well NM-Bus protocol. Since I had the M-Bus interface I figured it is more reliable to use a proper protocol and the real data. Quick research revealed the following library: rSCADA - Raditex control systems / GitHub - rscada/libmbus: Meter-bus library and utility programs , which immediately worked! First you scan for devices and next up you can read the data of the specific device using its address-:
mbus-serial-request-data -b 2400 /dev/ttyUSB0 <deviceid>
<?xml version="1.0" encoding="ISO-8859-1"?>
<MBusData>
<SlaveInformation>
<Id>xxx</Id>
<Manufacturer>INV</Manufacturer>
<Version>64</Version>
<ProductName></ProductName>
<Medium>Water</Medium>
<AccessNumber>222</AccessNumber>
<Status>00</Status>
<Signature>0000</Signature>
</SlaveInformation>
<DataRecord id="0">
<Function>Instantaneous value</Function>
<StorageNumber>0</StorageNumber>
<Unit>Fabrication number</Unit>
<Value>xxx</Value>
<Timestamp>2021-11-01T21:58:31Z</Timestamp>
</DataRecord>
<DataRecord id="1">
<Function>Instantaneous value</Function>
<StorageNumber>0</StorageNumber>
<Unit>Volume (m m^3)</Unit>
<Value>877</Value>
<Timestamp>2021-11-01T21:58:31Z</Timestamp>
</DataRecord>
</MBusData>
I’ve explored a few more options around the library and possible usage, at the end I put it into a Docker container together with a Python based MQTT daemon. This process runs every minute reading the data from the sensor to put it as message onto my MQTT broker. I’m also using MQTT auto-discovery to not have to configure the sensor within Home Assistant. As a foundation for my own daemon I used miflora-mqtt-daemon Thanks to Thomas Dietrich!
Wtihin Home Assistant I know have a sensor which is using the device_class gas as water is not available. Unit of measurement is in liters, matching what I get from the physical sensor.
As you can see above, I’m always getting the total instead of impulses. This allows easy processing using the Utility Meter - Home Assistant integration:
# SensusHRI
water_hourly_sensushri:
source: sensor.sensushri
name: "Wasserverbrauch stündlich"
cycle: hourly
water_daily_sensushri:
source: sensor.sensushri
name: "Wasserverbrauch täglich"
cycle: daily
water_weekly_sensushri:
source: sensor.sensushri
name: "Wasserverbrauch wöchentlich"
cycle: weekly
water_monthly_sensushri:
source: sensor.sensushri
name: "Wasserverbrauch monatlich"
cycle: monthly
water_yearly_sensushri:
source: sensor.sensushri
name: "Wasserverbrauch jährlich"
cycle: yearly
I’ve configured all cycles, which allows some interesting dashboards/graphs, e.g.
Based on the values of the utility meters I also added a markdown card with some calculations about costs per week, month, year:
With the ability to render Jinja templates in a markdown card I was able to put in all needed calculation for this summary.
type: markdown
content: >-
Die Wasserkosten für:
- die **aktuelle Woche** betragen **{{
((states('sensor.wasserverbrauch_wochentlich') | float / 1000) * 4.06) |
round(2) }}** €
- den **aktuellen Monat** betragen **{{
((states('sensor.wasserverbrauch_monatlich') | float / 1000) * 4.06) |
round(2) }}** €
- das **aktuelle Jahr** betragen **{{
((states('sensor.wasserverbrauch_jahrlich') | float / 1000) * 4.06) | round(2)
}}** €
*Diese Berechnungen basieren auf dem Wasserpreis von 1,92€ je Kubikmeter und
der Schmutzwassergebühr von 2,14€ je Kubikmeter. Details auf [Hamburg
Wasser](https://www.hamburgwasser.de/privatkunden/service/gebuehren-abgaben-preise).*
title: Kosten
I might be able to use another sensor/value to store the price, but since I’m not using it anywhere else I took the easy route.
My final dashboard looks like this:
I hope that gives some inspiration about how you use Home Assistant for water (or gas) metering and potential use-cases.
If you have ideas about what else to do with this data, let me know!