Water meter in Home-Assistant


Update 15/04/24:

The folks at SmartGateways.nl have official instructions on how to configure the device and integrate it in HomeAssistant which I initially didn't find.

MQTT Setup: https://haprofs.com/setting-up-mqtt-mosquitto-broker-home-assistant/

Home-Assistant configuration: https://haprofs.com/water-meter-dashboard-home-assistant/ (you will need to request a password to gain access to the configuration files, proving that you are a customer).

The instructions below in the blogpost will stay for posterity, or if you just want to do your own thing and take inspiration.


Similar to my previous project for measuring my power usage at home in Belgium (https://blog.carroarmato0.be/2024/01/18/saj-solar-inverter-and-home-assistant/) I wanted to measure the water consumption.

Different water meters are in use in Belgium, and while the country is slowly progressing toward digitization, I still have an analog one.

Specifically, an Elster Kent V100 "grenade".

Elster Kent V100. Illustration.

While a solution that uses OCR might be the first thing to pop into mind, fortunately, some clever people at https://smartgateways.nl/ offer an out-of-the-box product that uses a pulse reed to measure the flow of water and publishes that on an MQTT bus wirelessly, or, through a REST Api (https://smartgateways.nl/product/slimme-watermeter-gateway/).

While it's technically true that it works in Home-Assistant (and some other home automation systems), it does need some extra manual steps to get it integrated.

In this blog post, I will use the MQTT integration. For this purpose, I've setup a simple MQTT broker. You can follow some examples online on how to run it: https://hub.docker.com/_/eclipse-mosquitto

Note that due to the Smart Gateways implementation, interaction with the MQTT broker needs to use an account:

listener 1883
listener 8080
protocol websockets

persistence true
persistence_location /mosquitto/data/
allow_anonymous false
password_file /mosquitto/config/passwords
connection_messages true
use_username_as_clientid true

You can test if your MQTT broker is successfully receiving the messages from the meter by using a client tool such as MQTT-Explorer.

MQTT Explorer

Example of the REST API output:

REST API

In Home-Assistant, you need to add the MQTT Integration and configure it so that it can be accessed:

Unfortunately, the water meter does not make use (yet) of Home-Assistant's autodiscovery topic, which means we need to describe the topics and values manually.

Follow you can find the configuration for adding all the entities from the topics, grouped into a device.

I've added an extra entity called "Current Value m³" to have the sensor recognized by the Energy Dashboard.

mqtt:
  sensor:
    - name: Current Value m³
      state_topic: "watermeter/reading/current_value"
      unique_id: watermeter_current_value_m3
      device_class: water
      state_class: total_increasing
      value_template: "{{ states('sensor.slimme_watermeter_gateway_current_value') | float * 0.001 | round(3) }}"
      unit_of_measurement: "m³"
      device:
        identifiers: "SG-WGB"
        manufacturer: "SmartGateways.nl"
        name: "Slimme Watermeter Gateway"
        model: "Versie B"
    - name: Current Value
      state_topic: "watermeter/reading/current_value"
      unique_id: watermeter_current_value
      device_class: water
      state_class: total_increasing
      unit_of_measurement: "L"
      device:
        identifiers: "SG-WGB"
        manufacturer: "SmartGateways.nl"
        name: "Slimme Watermeter Gateway"
        model: "Versie B"
    - name: Pulse Factor 
      state_topic: "watermeter/reading/pulse_factor"
      unique_id: watermeter_pulse_factor
      device:
        identifiers: "SG-WGB"
        manufacturer: "SmartGateways.nl"
        name: "Slimme Watermeter Gateway"
        model: "Versie B"
    - name: Pulse Count
      state_topic: "watermeter/reading/pulse_count"
      unique_id: watermeter_pulse_count
      device:
        identifiers: "SG-WGB"
        manufacturer: "SmartGateways.nl"
        name: "Slimme Watermeter Gateway"
        model: "Versie B"
    - name: Water used last minute
      state_topic: "watermeter/reading/water_used_last_minute"
      unique_id: watermeter_last_used
      device_class: water
      unit_of_measurement: "L"
      device:
        identifiers: "SG-WGB"
        manufacturer: "SmartGateways.nl"
        name: "Slimme Watermeter Gateway"
        model: "Versie B"
    - name: Firmware Version
      state_topic: "watermeter/smart_gateways/running_firmware_version"
      unique_id: watermeter_current_firmware
      device:
        identifiers: "SG-WGB"
        manufacturer: "SmartGateways.nl"
        name: "Slimme Watermeter Gateway"
        model: "Versie B"
    - name: Available Firmware Version
      state_topic: "watermeter/smart_gateways/available_firmware_version"
      unique_id: watermeter_available_firmware_version
      device:
        identifiers: "SG-WGB"
        manufacturer: "SmartGateways.nl"
        name: "Slimme Watermeter Gateway"
        model: "Versie B"
    - name: MAC Address
      state_topic: "watermeter/smart_gateways/mac_address"
      unique_id: watermeter_mac_address
      device:
        identifiers: "SG-WGB"
        manufacturer: "SmartGateways.nl"
        name: "Slimme Watermeter Gateway"
        model: "Versie B"
    - name: IP Address
      state_topic: "watermeter/smart_gateways/ip_address"
      unique_id: watermeter_ip_address
      device:
        identifiers: "SG-WGB"
        manufacturer: "SmartGateways.nl"
        name: "Slimme Watermeter Gateway"
        model: "Versie B"
    - name: Wifi RSSI
      state_topic: "watermeter/smart_gateways/wifi_rssi"
      unique_id: watermeter_wifi_rssi
      device_class: "signal_strength"
      unit_of_measurement: "dBm"
      device:
        identifiers: "SG-WGB"
        manufacturer: "SmartGateways.nl"
        name: "Slimme Watermeter Gateway"
        model: "Versie B"
    - name: Startup Time
      state_topic: "watermeter/smart_gateways/startup_time"
      unique_id: watermeter_startup_time
      device:
        identifiers: "SG-WGB"
        manufacturer: "SmartGateways.nl"
        name: "Slimme Watermeter Gateway"
        model: "Versie B"
  binary_sensor:
    - name: Leak detected
      state_topic: "watermeter/reading/leak_detect"
      device_class: "problem"
      payload_on: "true"
      payload_off: "false"
      unique_id: watermeter_leak_detection
      device:
        identifiers: "SG-WGB"
        manufacturer: "SmartGateways.nl"
        name: "Slimme Watermeter Gateway"
        model: "Versie B"
    - name: Update Available
      state_topic: "watermeter/smart_gateways/update_available"
      unique_id: watermeter_update_available
      device_class: "update"
      payload_on: "true"
      payload_off: "false"
      device:
        identifiers: "SG-WGB"
        manufacturer: "SmartGateways.nl"
        name: "Slimme Watermeter Gateway"
        model: "Versie B"


Once Home-Assistant has been reloaded, the device and entities should appear:

HA Device Info

We can now it as a water source in the Energy Dashboard.

Water Consumption entities
Energy Distribution with Water
Water Consumption