Connectix Smart Gateways Wifi Water Meter

Hi,

I would like to share my yaml file for the Connectix Smart Gateways Wifi Water Meter. This device measures water consumption from an analogue water meter.


The company behind this device is not willing to share any details about the board and pin setup inside and is mentioning that flashing the device with your own firmware will void the waranty. No judgement call from my side, just stating the facts as they are.

Anyhow, since the company did not share the details needed to do the conversion to esphome, I decided to crack open the casing and peek inside. Itā€™s a NodeMCU-32S and the sensor is connected to GPIO19. Based on this information, I created the yaml config below.

The internal_filter is set to 200ms since my water meter gives one pulse per 1 liter of water usage. Given the maximum speed at which i can use water, i choose for this number to prevent false-positive pulses (observing a non-existing pulse) without creating false-negative pulses (missing a real pulse). This setting works perfect in my situation, but you can tune it if needed.

esphome:
  name: water_meter
  friendly_name: Water meter
  comment: NodeMCU-32S

esp32:
  board: nodemcu-32s
#  framework:
#    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "your_encryption_key"

ota:
  password: "your_password"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "your_hotspot_name"
    password: "your_hotspot_password"

captive_portal:

sensor:
  - platform: pulse_meter
    pin: GPIO19
    name: "Water Usage"
    id: water_usage
    unit_of_measurement: "liter/min"
    icon: "mdi:water"
    accuracy_decimals: 1
    internal_filter: 200ms
    internal_filter_mode: edge
    timeout: 30s
    total:
      name: "Total Usage"
      id: total_usage
      unit_of_measurement: "l"
      accuracy_decimals: 0
      state_class: total_increasing

This setup gives to sensors:

  • water-usage per minute

  • total water usage. This can be used in combination with the Home Assistant Utility meter. Donā€™t forget to enable ā€œPeriodically resttingā€ in the utility meter settings since the ā€œTotal Usageā€ sensor will drop to 0 when disconnecting the sensor from power.

I did not want to store the sensor value internally, since this would lead to level wear of the flash memory.

image

All in all, this is a major improvement over the stock firmware due to 1) tighter integration to home assistant, 2) more control, 3) no more unneeded sensor updates every 5 seconds while no water was used: the esphome solution will only update the sensor value when another liter of water is used. 4) no internet connection is required to check for firmware updates, since you do this locally with esphome.

Hopfully this setup will help others.

1 Like

PS: flashing is really simple since the device has a usb-connection to deliver power. Donā€™t forget to push the reset-button at the beginning of the flash process.

Where exactly do you set this?
image

In the Utility Meter Options menu.

image

I did some more testing, and it is actually better to leave the " Periodically restting" option off. Advantages of leaving it off:

  • it prevents unjustly warnings during home assistant restarts (for details, see: Utility Meter: Invalid state Ā· Issue #90914 Ā· home-assistant/core Ā· GitHub )
  • if water was used while home assistant was rebooting, it will catch-up
  • if power to the water meter itself would be lost somehow, it would not calculate water usage anyway. So no difference there. When reconnecting power, the total meter will jump to 0, but the utility meter sensor will handle this scenario just fine.

So, itā€™s best to set the option like this:
image

are you flashing a standard esp32 firmware to the device?

Iā€™m flashing the firmware as compiled from the yaml code in the first post. Itā€™s pretty standard indeed.

thanks for responding! I am newish to esp32ā€™s so when I see that yaml it looks like HA code and not something I would flash to the esp itself, so I am a little lost on the firmware flashing part is all :slight_smile:

I did some digging around to figure out how this all works and I think I have it. for future reference for anyone that might be interested hereā€™s what I did

  1. install esphome! you can connect this with home assistant, but for now you donā€™t need to
  2. adopt the device to your network, I did it via the Web - ESPHome wizard when it was connected to my laptop
  3. check everything is working, that you can open the web portal for the device and/or ping it, and that is shows up in esphome as online
  4. apply the yaml here from @pimw, make sure you edit as needed
  5. whack the sensor on your water meter
  6. you should be good to go!
1 Like

Hi, i just flashed my connectix watermeter with ESPhome, and it works wonderfull. Better than the original firmware, and costumizable which is a real bonus.

Im wondering is since i also have a connectix ā€œslimmemeterā€ P1 reader if it is possible to also flash this device with ESPhome. since on a regular basis i experience disconnects from this device which works with MQTT and by the way this was also the case with the ā€œwatermeterā€.

How would i go about this?

I will have a crack at it, tonight to see ad which port the data input is connected and try somethings out.

having this device local in esphome would be very nice. next to the already stated above, I would love it to not be calling ā€˜homeā€™ continuously, the stock which the device is doing (if only to check for updates, but recently added was the optional cloud storage of your data).

I do wonder if the Esphome version also has the ā€˜AIā€™ sensor for leakage.
at first believed hat to be a gimmick, but got tone honest, it is quite clever (a toilet flush that keeps running, or worse, the pond refillā€¦)

Yeah that woud be Nice maybe if continues pulses with a curtain amount of time between them could indicatie unwanted water usage

Iā€™ve the Slimmelezer+ https://www.zuidwijk.com/product/slimmelezer-plus/ , which contains the Wemos D1 (ESP8266).

For this device, the below yaml code works perfectly for me:

esphome:
  name: gang-energiemeter-dsmr
  friendly_name: Gang Energiemeter DSMR
  comment: Wemos D1 (ESP8266) + SlimmeLezer+
  platform: ESP8266
  esp8266_restore_from_flash: true
  board: d1_mini

# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:
  encryption:
    key: "yourencryptionkey"

ota:
  password: "yourpassword"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Energiemeter-Dsmr"
    password: "password"

captive_portal:

uart:
  baud_rate: 115200
  rx_pin: D7
  rx_buffer_size: 1700

globals:
  - id: has_key
    type: bool
    restore_value: yes
    initial_value: "false"
  - id: stored_decryption_key
    type: char[32]
    restore_value: yes

dsmr:
  id: dsmr_instance
  max_telegram_length: 1700

sensor:
  - platform: dsmr
    energy_delivered_tariff1:
      name: "Energy Consumed Tariff 1"
      filters:
        - throttle: 60s
    energy_delivered_tariff2:
      name: "Energy Consumed Tariff 2"
      filters:
        - throttle: 60s
    power_delivered:
      name: "Power Consumption"
      accuracy_decimals: 3
      filters:
        - throttle: 5s
    gas_delivered:
      name: "Gas Consumed"
      id: gas_consumed
      accuracy_decimals: 5
      filters:
        - throttle: 60s
  - platform: copy
    source_id: gas_consumed
    id: gas_consumption_per_hour
    name: "Gas Consumption Per Hour"
    accuracy_decimals: 1
    device_class: ""
    state_class: "measurement"
    unit_of_measurement: "mĀ³/hour"
    #We measure the delta between current en previous value
    #Ignore high bootup values (above 100)
    #Since we measure per 60 seconds, we need to multiply by 60 to get the hourly consumption value
    filters:
      - lambda: !lambda |- 
          static float last_value = 0;
          float change = 0;
          change = x - last_value;
          last_value = x;
          if (change > 100) return {};
          return change*60;

If you check the board of the Connectix ā€œslimmemeter P1ā€ , you should be able to adjust and use this code.

1 Like

I have managed to get the Slimmemeter P1 from Smartgateways to work with ESPhome.
The GPIO pin that is used is ā€œGPIO18ā€.
Also I donā€™t know if it is hardware specific or that my particular electricity meter just send the telegrams in a different format but the inverted option of the uart settings needs to bet set to ā€œTRUEā€.

I have included the yaml coding for my unit of smartgateways.nl


esphome:
  name: dsmr_meter
  friendly_name: DSMR Meter
  comment: NodeMCU-32S

esp32:
  board: nodemcu-32s
#  framework:
#    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "api key here"

ota:
  password: "randompassword"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "ssid"
    password: "password"
    
captive_portal:


uart:
  baud_rate: 115200
  rx_pin:
    number: GPIO18
    inverted: true
  rx_buffer_size: 1700

dsmr:
  id: dsmr_instance
  max_telegram_length: 1700

sensor:
  - platform: dsmr
    energy_delivered_tariff1:
      name: "Energy Consumed Tariff 1"
      filters:
        - throttle: 60s
    energy_delivered_tariff2:
      name: "Energy Consumed Tariff 2"
      filters:
        - throttle: 60s
    energy_returned_tariff1:
      name: "Energy Produced Tariff 1"
      filters:
        - throttle: 60s
    energy_returned_tariff2:
      name: "Energy Produced Tariff 2"
      filters:
        - throttle: 60s
    power_delivered:
      name: "Power Consumption"
      accuracy_decimals: 3
      filters:
        - throttle: 1s
    power_returned:
      name: "Power Produced"
      accuracy_decimals: 3
      filters:
        - throttle: 1s
    gas_delivered:
      name: "Gas Consumed"
      id: gas_consumed
      accuracy_decimals: 5
      filters:
        - throttle: 5s
  - platform: uptime
    name: "DSMR meter Uptime"
  - platform: wifi_signal
    name: "DSMR meter Wi-Fi Signal"
    update_interval: 60s
  - platform: copy
    source_id: gas_consumed
    id: gas_consumption_per_hour
    name: "Gas Consumption Per Hour"
    accuracy_decimals: 1
    device_class: ""
    state_class: "measurement"
    unit_of_measurement: "mĀ³/hour"
    #We measure the delta between current en previous value
    #Ignore high bootup values (above 100)
    #Since we measure per 60 seconds, we need to multiply by 60 to get the hourly consumption value
    filters:
      - lambda: !lambda |- 
          static float last_value = 0;
          float change = 0;
          change = x - last_value;
          last_value = x;
          if (change > 100) return {};
          return change*60;

text_sensor:
  - platform: dsmr
    identification:
      name: "DSMR Identification"
    p1_version:
      name: "DSMR Version"
  - platform: wifi_info
    ip_address:
      name: "DSMR meter IP Address"
    ssid:
      name: "DSMR meter Wi-Fi SSID"
    bssid:
      name: "DSMR meter Wi-Fi BSSID"
  - platform: version
    name: "ESPHome Version"
    hide_timestamp: false

Hi all,
Iā€™m not that familliar with ESPhome, could someone point me in the right direction.
I would like to led the blue light thatā€™s on my board connected to GPIO2 to blink every time a something gets published to the API of home assistant, or when de ESP read a telegram. Is this possible?