Water Consumption Monitoring with Multical21 and Home Assistant
My water meter is located quite far from the house, which made this project particularly interesting. Here's how I got it working.
The Hardware Setup
- Water Meter: Multical21 with wireless M-Bus capability
- Receiver: iM871A-USB dongle from IMST GmbH
- Computer: Raspberry Pi Zero
- Location: Standalone setup near the water meter
The Multical21 water meter transmits data using the Wireless M-Bus protocol. Since my meter is far from the house, I needed to place the receiver (iM871A-USB dongle) closer to the meter. The Raspberry Pi Zero was perfect for this setup due to its small size and low power consumption.
Detailed Installation Guide
1. Prepare the Raspberry Pi
- Flash Raspberry Pi OS Lite to your SD card
- Enable SSH and configure WiFi before first boot
- Connect to the Pi via SSH
2. Install Required Dependencies
# Update system packages
sudo apt update
sudo apt upgrade -y
# Install required dependencies
sudo apt install -y git
sudo apt install -y librtlsdr-dev libusb-dev
sudo apt install -y libxml2-dev
sudo apt install -y mosquitto-clients
### 3. Install wmbusmeters
```bash
# Download and extract wmbusmeters
wget https://api.github.com/repos/wmbusmeters/wmbusmeters/tarball/master
tar -xvzf master
cd wmbusmeters-wmbusmeters-*
# Compile and install
./configure
make
sudo make install
# If make fails, ensure all dependencies are installed and try again
4. Configure wmbusmeters
- Create the main configuration file:
sudo nano /etc/wmbusmeters.conf
- Add the following configuration:
loglevel=normal
device=auto:c1
donotprobe=/dev/ttyAMA0
logtelegrams=false
format=json
meterfiles=/var/log/wmbusmeters/meter_readings
meterfilesaction=overwrite
meterfilesnaming=name-id
logfile=/var/log/wmbusmeters/wmbusmeters.log
shell=HOME=/home/wmbusmeters/ mosquitto_pub -h YOUR_HOME_ASSISTANT_IP -u water_meter -P YOUR_PASSWORD -t wmbusmeters/$METER_ID -m "$METER_JSON"
- Create meter configuration directory and file:
sudo mkdir -p /etc/wmbusmeters.d
sudo nano /etc/wmbusmeters.d/vodomer
- Add meter configuration:
name=tapwater
id=YOUR_METER_ID
key=YOUR_METER_KEY
driver=multical21
5. Set up logging directory
# Create logging directories
sudo mkdir -p /var/log/wmbusmeters/meter_readings
6. Start and Enable Service
# Reload systemd to recognize the service
sudo systemctl daemon-reload
# Start wmbusmeters service
sudo systemctl start wmbusmeters
# Enable service to start on boot
sudo systemctl enable wmbusmeters
# Check service status
sudo systemctl status wmbusmeters
7. Monitor Logs and Troubleshooting
# View live logs
tail -f /var/log/wmbusmeters/wmbusmeters.log
# Check meter readings
tail -f /var/log/wmbusmeters/meter_readings/tapwater-YOUR_METER_ID
# Restart service after config changes
sudo systemctl restart wmbusmeters
8. Home Assistant Configuration
Add the following to your Home Assistant's configuration.yaml
:
mqtt:
sensor:
- name: "Tapwater total"
state_topic: "wmbusmeters/YOUR_METER_ID"
device_class: water
state_class: total
value_template: "{{ (value_json.total_m3 * 1000) }}"
unit_of_measurement: L
- name: "Tapwater target"
state_topic: "wmbusmeters/YOUR_METER_ID"
unit_of_measurement: "m³"
device_class: water
state_class: total
value_template: "{{ value_json.target_m3 }}"
- name: "Tapwater temperature"
state_topic: "wmbusmeters/YOUR_METER_ID"
unit_of_measurement: "°C"
device_class: temperature
state_class: measurement
value_template: "{{ value_json.flow_temperature_c }}"
- name: "Tapwater external temperature"
state_topic: "wmbusmeters/YOUR_METER_ID"
unit_of_measurement: "°C"
device_class: temperature
state_class: measurement
value_template: "{{ value_json.external_temperature_c }}"
- name: "Tapwater rssi"
state_topic: "wmbusmeters/YOUR_METER_ID"
unit_of_measurement: "dBm"
device_class: signal_strength
state_class: measurement
value_template: "{{ value_json.rssi_dbm }}"
binary_sensor:
- name: "Tapwater status dry"
state_topic: "wmbusmeters/YOUR_METER_ID"
device_class: problem
payload_on: "True"
payload_off: "False"
value_template: "{{ 'DRY' in value_json.current_status }}"
- name: "Tapwater status reversed"
state_topic: "wmbusmeters/YOUR_METER_ID"
device_class: problem
payload_on: "True"
payload_off: "False"
value_template: "{{ 'REVERSED' in value_json.current_status }}"
- name: "Tapwater status leak"
state_topic: "wmbusmeters/YOUR_METER_ID"
device_class: problem
payload_on: "True"
payload_off: "False"
value_template: "{{ 'LEAK' in value_json.current_status }}"
- name: "Tapwater status burst"
state_topic: "wmbusmeters/YOUR_METER_ID"
device_class: problem
payload_on: "True"
payload_off: "False"
value_template: "{{ 'BURST' in value_json.current_status }}"
Troubleshooting Tips
-
If the dongle isn't detected:
- Check
dmesg
output after plugging in the USB dongle - Try different USB ports
- Verify USB permissions
- Check
-
If no readings appear:
- Verify the meter ID and key are correct
- Check if you're within range of the meter
- Confirm the correct radio mode (c1 for Multical21)
-
If MQTT publishing fails:
- Test MQTT connection manually:
mosquitto_pub -h YOUR_HOME_ASSISTANT_IP -u water_meter -P YOUR_PASSWORD -t test -m "test"
- Verify network connectivity
- Check MQTT credentials
- Test MQTT connection manually:
-
Common log messages:
- "No meters configured" - Check /etc/wmbusmeters.d/ directory
- "Cannot open device" - USB permission issues or wrong device
- "No telegrams received" - Range or radio mode issues