watermeter recognized as incremental

For devices supporting the Auto Discovery feature. Like ZWaveJS2MQTT, Zigbee2MQTT.

Moderator: leecollings

Post Reply
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

watermeter recognized as incremental

Post by Gravityz »

Hello,
i have a watermeter which sends out it's total value over MQTT

MQTT AD recognizes it as a counter incremental.
this creates a big problem because it sends out the complete value everytime so the counter increases rapidly with a faulty value

can i somehow change the device into a counter total?
if not what do i need to send out over mqtt so domoticz recognizes it as a total counter.


thanks
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: watermeter recognized as incremental

Post by waltervl »

You cannot change the device.
From what MQTT interface (zigbee2mqtt, Zwave-JS-UI, esphome etc) is it sending?
If the wrong MQTT AD config is sent Domoticz will create the wrong device.
So what is the config topic including message and the state topic including message?

See the wiki for examples https://wiki.domoticz.com/MQTT_AD_Report_Problems
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: watermeter recognized as incremental

Post by Gravityz »

it is send from esphome

esp32-watermeter/sensor/watermeter_totaal/state
esp32-watermeter/sensor/watermeter_flow/state


i can not se the messages, only the values

how can i see this in mqtt explorer
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: watermeter recognized as incremental

Post by waltervl »

See the wiki, there should be a config topic used to discover the device. Normally in the /homeassistant folder but that depends on your settings. See the wiki for examples.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: watermeter recognized as incremental

Post by Gravityz »

ok, when. i look in MQTT i see this posted

Code: Select all

{"dev_cla":"water","unit_of_meas":"Liter","stat_cla":"measurement","name":"Watermeter Totaal","ic":"mdi:pulse","stat_t":"esp32-watermeter/sensor/watermeter_totaal/state","avty_t":"esp32-watermeter/status","uniq_id":"ESPsensorwatermeter_totaal","dev":{"ids":"ecda3bc02bcc","name":"ESP32-Watermeter","sw":"2025.10.4 (Nov 21 2025, 18:24:16)","mdl":"esp32-c3-devkitm-1","mf":"Espressif","cns":[["mac","ecda3bc02bcc"]]}}

Code: Select all

{"unit_of_meas":"l/min","stat_cla":"measurement","name":"Watermeter Pulse","ic":"mdi:water-pump","stat_t":"esp32-watermeter/sensor/watermeter_pulse/state","avty_t":"esp32-watermeter/status","uniq_id":"ESPsensorwatermeter_pulse","dev":{"ids":"ecda3bc02bcc","name":"ESP32-Watermeter","sw":"2025.10.4 (Nov 21 2025, 17:32:58)","mdl":"esp32-c3-devkitm-1","mf":"Espressif","cns":[["mac","ecda3bc02bcc"]]}}
Last edited by Gravityz on Saturday 22 November 2025 9:26, edited 1 time in total.
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: watermeter recognized as incremental

Post by Gravityz »

{"dev_cla":"water","unit_of_meas":"Liter","stat_cla":"measurement","name":"Watermeter Totaal","ic":"mdi:pulse","stat_t":"esp32-watermeter/sensor/watermeter_totaal/state","avty_t":"esp32-watermeter/status","uniq_id":"ESPsensorwatermeter_totaal","dev":{"ids":"ecda3bc02bcc","name":"ESP32-Watermeter","sw":"2025.10.4 (Nov 21 2025, 18:24:16)","mdl":"esp32-c3-devkitm-1","mf":"Espressif","cns":[["mac","ecda3bc02bcc"]]}}
{"unit_of_meas":"l/min","stat_cla":"measurement","name":"Watermeter flow","ic":"mdi:water-pump","stat_t":"esp32-watermeter/sensor/watermeter_flow/state","avty_t":"esp32-watermeter/status","uniq_id":"ESPsensorwatermeter_flow","dev":{"ids":"ecda3bc02bcc","name":"ESP32-Watermeter","sw":"2025.10.4 (Nov 21 2025, 18:24:16)","mdl":"esp32-c3-devkitm-1","mf":"Espressif","cns":[["mac","ecda3bc02bcc"]]}}
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: watermeter recognized as incremental

Post by Gravityz »

sorry, had a blackout last night and did not know where to look

this is the watermeter from esphome
it is declared as total but still is recognized as total_increasing

Code: Select all

# ⬇ watermeter pulsen ⬇ #
- platform: pulse_meter
  pin: 
    number: GPIO01
  name: "Watermeter flow"
  id: watermeter_pulse
  internal_filter: 100ms
  internal_filter_mode: PULSE
  timeout: 16s
  state_class: total
  unit_of_measurement: "l/min"    
  accuracy_decimals: 1
  icon: "mdi:water-pump"
  filters:
    lambda: return x ;
  on_value:
    then:
      - output.turn_on: pulse_led
      - delay: 200ms
      - output.turn_off: pulse_led
 

# ⬇ Totaal watermeter ⬇ #      
  total:
    id: sensor_pulse_meter_total
    name: "Watermeter Totaal"
    unit_of_measurement: "Liter"
    state_class: total
    device_class: water
    accuracy_decimals: 0
    filters:
        lambda: |-
          if (isnan(id(num_from_text).raw_state)) {
          return x + id(domoticz_watermeter_value).state;
          } else {
          return x + id(num_from_text).state;
          }

this what is send to MQTT

the pulse_meter in esphome consists of 2 devices, pulse and total

total

topic

Code: Select all

homeassistant/sensor/esp32-watermeter/watermeter_pulse/config
payload

Code: Select all

[quote][code]{"dev_cla":"water","unit_of_meas":"Liter","stat_cla":"total","name":"Watermeter Totaal","ic":"mdi:pulse","stat_t":"esp32-watermeter/sensor/watermeter_totaal/state","avty_t":"esp32-watermeter/status","uniq_id":"ESPsensorwatermeter_totaal","dev":{"ids":"ecda3bc02bcc","name":"ESP32-Watermeter","sw":"2025.10.4 (Nov 22 2025, 07:35:34)","mdl":"esp32-c3-devkitm-1","mf":"Espressif","cns":[["mac","ecda3bc02bcc"]]}}
[/quote][/code]

flow

topic

Code: Select all

homeassistant/sensor/esp32-watermeter/watermeter_pulse/config

payload

Code: Select all

{"unit_of_meas":"l/min","stat_cla":"total","name":"Watermeter flow","ic":"mdi:water-pump","stat_t":"esp32-watermeter/sensor/watermeter_flow/state","avty_t":"esp32-watermeter/status","uniq_id":"ESPsensorwatermeter_flow","dev":{"ids":"ecda3bc02bcc","name":"ESP32-Watermeter","sw":"2025.10.4 (Nov 22 2025, 07:35:34)","mdl":"esp32-c3-devkitm-1","mf":"Espressif","cns":[["mac","ecda3bc02bcc"]]}}
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: watermeter recognized as incremental

Post by Gravityz »

Scherm­afbeelding 2025-11-22 om 09.39.10.png
Scherm­afbeelding 2025-11-22 om 09.39.10.png (236.43 KiB) Viewed 136 times
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: watermeter recognized as incremental

Post by Gravityz »

is there a reason i should create a report( eg should it be working but it is not) or is there something i can change?
sofar i played with state_class and device class, setting them to energy or measurement but everytime a counter incremental is created.
it looks like MQTT AD is ignoring the state_class because it clearly says total in the config payload

i also cleaned out mqtt totally so there were no old messages, rebooted mqtt server, did a discovery again with same result.
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: watermeter recognized as incremental

Post by waltervl »

Domoticz is creating the device based on the config message and indeed seems to ignore the "stat_cla":"total" value.
So best to create a GitHub issue according the instructions on the wiki so gizmocuz can take a look.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: watermeter recognized as incremental

Post by Gravityz »

I reported the issue.
https://github.com/domoticz/domoticz/issues/6445

it seems that playing around with some variables(icons) it is now suddenly recognized as a rain sensor

bummer because esphome is really adjustable but if domoticz does not recognize it correctly it can not be used
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: watermeter recognized as incremental

Post by Gravityz »

if anybody has the json code to send to domoticz so it creates a total counter that would be nice.

i can then adjust it so it works with my code as well
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: watermeter recognized as incremental

Post by waltervl »

I looked at the code and it seems it is not possible. When m3 as unit of measure will create a incremental water meter or a gas meter. Perhaps you can define it as a gas meter for now or wait until the code changes and use a beta.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: watermeter recognized as incremental

Post by Gravityz »

what code will create a normal counter?

i can can change the metrics( m3) to someting else but i need to know what will trigger the creation of a normal counter.
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: watermeter recognized as incremental

Post by waltervl »

Better wait till gizmocuz fixes the issue.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: watermeter recognized as incremental

Post by Gravityz »

Hi Walter,
got things working.

today i got a brainwave and decided to look at the code myself.
This MQTT AD code is really strange, it works with a certain logic i do not understand.

it does not look at all at the state_class

it looks at units and icons

eg. when you specify an icon with the name water in it you get a rain sensor
if you specify anything which use pulse or pulses it figurs you need a counter incremental.

also if you specify l/min it does not understand l/hr however it seems to understand.(but it uses l/min)
this logic escapes me, why are things so illogical!!!!!!!!!!!!!!!!!
this is part of the MQTT AD code
else if (szUnit == "l/hr")
{
//our sensor is in Liters / minute

because the code is working with a lot of if/then statements you need to figur out what to use.
basically it defaults to counter incremental but if it can not find anything which matches the description it finally uses the RFXcounter i want.

here is part of the working code
because i had to state that i am using l/hr(which is not true) i also had to change the output with a factor 60(60 minutes in one hour)
this gives me a value inside the esphome which is 60 times to high but the value in the domoticz sensor is correct.

Code: Select all

sensor:
  
# ⬇ watermeter pulsen ⬇ #
- platform: pulse_meter
  pin: 
    number: GPIO01
  name: "Watermeter Pulse"
  id: watermeter_pulse
  internal_filter: 100ms
  internal_filter_mode: PULSE
  timeout: 16s
  state_class: measurement
  unit_of_measurement: "l/hr"    
  accuracy_decimals: 1
  icon: "mdi:pump"
  filters:
    lambda: return x * 60;
  on_value:
    then:
      - output.turn_on: pulse_led
      - delay: 200ms
      - output.turn_off: pulse_led
 

# ⬇ Totaal watermeter ⬇ #      
  total:
    id: sensor_pulse_meter_total
    name: "Watermeter Totaal"
    unit_of_measurement: "m³"
    state_class: total
    device_class: energy
    icon: "mdi:pump"
    accuracy_decimals: 0
    filters:
        lambda: |-
          if (isnan(id(num_from_text).raw_state)) {
          return x + id(domoticz_watermeter_value).state;
          } else {
          return x + id(num_from_text).state;
          }
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: watermeter recognized as incremental

Post by waltervl »

So it is still better to wait for Gizmocuz the fix this......
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: watermeter recognized as incremental

Post by Gravityz »

agreed but it could well be that Gizmocuz will react with" Nothing wrong" because the things are detected in a strange way.

however i also filed a request on github regarding the waterflow.
it will not detect it correctly unless i specify l/hr
i asked for a second line of code which will also respond if the measurement unit is l/min.
User avatar
waltervl
Posts: 6677
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: watermeter recognized as incremental

Post by waltervl »

Gravityz wrote: Monday 24 November 2025 8:26 agreed but it could well be that Gizmocuz will react with" Nothing wrong" because the things are detected in a strange way.

however i also filed a request on github regarding the waterflow.
it will not detect it correctly unless i specify l/hr
i asked for a second line of code which will also respond if the measurement unit is l/min.
Both issues fixed by GizMocuz in latest beta......
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Gravityz
Posts: 652
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2025.1
Location: Netherlands
Contact:

Re: watermeter recognized as incremental

Post by Gravityz »

Nice. will try it this week
i think this is the 2025.2 release.

i must say, inspecting the MQTTautodiscover.cpp gives you a lot of insight.
code is complex but it is easy to spot where things go wrong(in my case with the l/min)

i will wait for the new docker image which is behind the normal release
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest