Auto discovery of pulses

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!

Moderators: leecollings, remb0

Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
mcipjvw
Posts: 8
Joined: Friday 26 May 2023 15:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Auto discovery of pulses

Post by mcipjvw »

Hey there,

I have a MQTT auto discovery sensor system. Works well for the common sensors.

But....
I have a machine now rotating 5 /min with a pulse counter attached, so 5 pulses/min if it is rotating. When I announce the sensor to domoticz as "counter", it indeed creates the counter sensor, but with kWh unit. How can I configure the counter without dimension?

I have c++ code like this:

mqttcfg["name"] = "Count sensor";
mqttcfg["uniq_id"] = uniq_id;
mqttcfg["component_type"] = "sensor";
mqttcfg["icon"] = "pulse";
mqttcfg["unit_of_measurement"] = "counter";
mqttcfg["val_tpl"] = "{{value_json.cntr}}";
mqttcfg["stat_t"] = statetopic.c_str();

Any suggestions? Thanks!
BR Martin
User avatar
waltervl
Posts: 6683
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Auto discovery of pulses

Post by waltervl »

There is no pulse counter device in Domoticz other the the S0 energy meter. But i do not think that can be created from MQTT Auto discovery.

If you want to count pulses you have to create some custom sensor or incremental counter https://wiki.domoticz.com/Dummy_for_vir ... ncremental

If you only want to monitor if the device is rotating you better have your hardware measuring the 5 rpm and send a regular ON if rpm >= 5 and OFF when < 5 by MQTT to a Domoticz switch.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
gizmocuz
Posts: 2710
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Auto discovery of pulses

Post by gizmocuz »

Maybe not a 100% answer, but this is how I created a watermeter that works with pulses that works with MQTT-AD

https://github.com/gizmocuz/esp_proximity_sensor_mqtt
Quality outlives Quantity!
mcipjvw
Posts: 8
Joined: Friday 26 May 2023 15:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Auto discovery of pulses

Post by mcipjvw »

Thanks guys. I think I will announce the pulse sensor for now as 'on' / 'off' switch. Right now I want to know whether the thing is rotating or not, but would be nice to have some more MQTT configuration possibilities, e.g. to set it to type=' custom' immediately.
BR Martin
User avatar
gizmocuz
Posts: 2710
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Auto discovery of pulses

Post by gizmocuz »

You see the configuration at the bottom of my arduino code in the link above
Quality outlives Quantity!
mcipjvw
Posts: 8
Joined: Friday 26 May 2023 15:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Auto discovery of pulses

Post by mcipjvw »

Thanks! I looked at your code.
The MQTT configuration and sensor anouncement was already working. It is just that the 'Counter Type' must be set to 'Custom' manually in domoticz when you want the counter to be dimension less. It would be nice to do this inside the MQTT configuration.
But, once set to 'Custom', it is working as expected: daily pulses in a graph.
The device info structure is nice, but is domoticz doing something with this?
User avatar
gizmocuz
Posts: 2710
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Auto discovery of pulses

Post by gizmocuz »

Yep, make sure you also send

Code: Select all

autoconfPayload["icon"] = "mdi:counter-inc"; //incremental counter
This will let Domoticz create a device with the following type

devType = pTypeGeneral;
subType = sTypeCounterIncremental;

instead of

devType = pTypeRFXMeter;
subType = sTypeRFXMeterCount;
Quality outlives Quantity!
mcipjvw
Posts: 8
Joined: Friday 26 May 2023 15:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Auto discovery of pulses

Post by mcipjvw »

Hi gizmocuz,

Some time ago, but thanks for your support.
What is Domoticz doing with the device info, like "sw-version" and "manufacturer" ?

BR Martin
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest