-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debounce not working for exact duplicate messages in the same second. #17984
Comments
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
This issue has not been addressed |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
Comment to indicate the issue still exists. |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
Not stale |
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days |
Still not stale |
This issue still exists in V1.33.1 (stock version now as I've switched to using a docker container). |
I have the same problem with a MOES UFO-R11. The "debounce" does not work. |
Same issue on 1.35.1 with _TZE200_bcusnqt8 config
Without debounce there are many more msgs for this device
|
Same here with a TS0601 _TZE204_aoclfnxz |
Could you provide the debug log of this + your |
Which kind of debug log, standard, or including zigbee-herdsman? |
Here is one debug log. The Spam-device is ThermostatBuero. Here is a log with debounce = 5
|
I have a seemingly similar issue with the device zigbee2mqtt version is 1.35.1 commit: 3c962042, coordinator is Sonoff 3.0 USB Plus with Firmware 20221226. Here is the general config:
Here is the debug log that shows 3 messages being published instantaneously, even though
|
Debounce does not work for the device BHT-002-GCLZB either. The documentation advises to use this function, but the device still sends several dozen messages per second. |
Ping to see if this could get looked at... |
Ping o' rama to keep this alive. |
Also seeing the same with a Tuya ZS06 ir blaster. |
debounce does not work for this devices, as specified in debouce documentation : https://www.zigbee2mqtt.io/guide/configuration/devices-groups.html#common-device-options " Debounce works for devices that have some silence, and many devices are sending lots of messages that can be just ignored before sending to mqtt. Here I have level sensor and ambient sensor with this behaviour that send same measurement with less than one second.
@Koenkk any other suggestion that can be applied to at least reduce number of mqtt messages for this devices ? They need something to combine and use last value, but send each message at least X seconds, in my devices one each 30 or 60 seconds will be fine because ambient values and water level does not change very fast. |
Perhaps a https://medium.com/@bs903944/debounce-and-throttling-what-they-are-and-when-to-use-them-eadd272fe0be |
I have made some tests and have a "dirty" proof of concept implementation that solves the problem for my devices. --- receive.js.ori 2024-08-04 14:39:39.437046808 -0300
+++ receive.js 2024-08-04 16:04:46.670479142 -0300
@@ -139,6 +139,32 @@
const now = Date.now();
if (this.elapsed[data.device.ieeeAddr]) {
payload.elapsed = now - this.elapsed[data.device.ieeeAddr];
+
+ // very simple and dirty anti-spamming https://github.com/Koenkk/zigbee2mqtt/issues/17984
+ // as a proof of concept maybe Koenkk can find a better solution as the debounce does not help for my SPAMMER devices
+ // ambient sensor and water level that sometimes send mupliple messages on same second
+ // this will not help on zigbee network, but at least help on mqtt and homeassistant recorder and history
+ // this will not work for devices that have actions and specific events that are important
+ // it solves the SPAMMING on sensor devices that does not change values too fast and messages can be ignored
+ // I dont know all the side effects of this code, but here is the ones that I found already
+ // - on web ui, the last-seen is only updated after a non ignored message
+ // - web ui are more responsive than before
+ // - my homeassistant does not have a lot of data from this devices that are not need
+ // - my homeassistant became more responsive
+ // - the CPU load are sensible lower
+ // using "SPAMMER" in description is an easy way to test without changing options on yaml
+ if (data.device.options.min_elapsed || (data.device.options.description && data.device.options.description.includes("SPAMMER"))) {
+ let min_elapsed = 30000;
+ if (data.device.options.min_elapsed) {
+ min_elapsed = data.device.options.min_elapsed;
+ }
+
+ if (payload.elapsed < min_elapsed) {
+ logger_1.default.debug(`Ignoring message from SPAMMER - ${data.device.ieeeAddr} - ${data.device.options.friendly_name} - elapsed=${payload.elapsed} - min_elapsed=${min_elapsed}`);
+ return;
+ }
+ }
+
}
this.elapsed[data.device.ieeeAddr] = now;
}
|
If the web UI is more responsive with your dirty fix in place, I wonder if this is also part of the underlying cause of another issue I have where the settings reset before I can hit save: #23320 To me, it would make sense if the UI is being updated with every message .. especially on a network with 5 "spammy" devices (all Tuya mmWave sensors) .. I also would wonder if this is what's causing me to have to click buttons multiple times in the web UI to get a response I have two Zigbee networks, each having at least one spammy device .. the only differences are the coordinator firmware (just haven't upgraded the one, yet) and the number/types of devices .. here's my setup: Primary:
Secondary:
I'm planning on updating the firmware in the next couple days, so that will take that variable out .. after I do that, I might toss the one spammy device from my secondary network onto the primary network and see if that changes anything on the responsiveness of the web UI |
How do I implement this solution? On HassOs is possible?, or only on z2m in docker? |
I don´t have knowledge about z2m on hassOS. this the docker-compose.override.yaml to change this file :
|
the original file is receive.ts? I have downloaded zigbee2mqtt 1.39.1 and there I see the file /lib/extension/receive.ts. Using '/app/data' as data directory
Starting Zigbee2MQTT without watchdog.
/app/dist/extension/receive.js:1
import bind from 'bind-decorator';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:76:18)
at wrapSafe (node:internal/modules/cjs/loader:1283:20)
at Module._compile (node:internal/modules/cjs/loader:1328:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Function.Module._load (node:internal/modules/cjs/loader:1019:12)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:177:18)
at Object.<anonymous> (/app/lib/controller.ts:26:1)
at Module._compile (node:internal/modules/cjs/loader:1364:14) this is my stack ( on portainer... ): services:
zigbee2mqtt:
container_name: z2m2
restart: always
image: koenkk/zigbee2mqtt
volumes:
- /docker/z2m2/data:/app/data
- /run/udev:/run/udev:ro
- /docker/z2m2/receive.js:/app/dist/extension/receive.js:ro
ports:
- 84:8080
environment:
- TZ=Europe/Madrid Could you explain it for newbies, thanks. |
The ts is the source for the js file. If you have only the ts file you must change the ts file, the js should be changed when it was already generated. The changes are the same, but on different lines, just search for the lines of code that calculate the elapsed attribute. |
thank you for your help. Thank you very much. |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days |
This hasn't been resolved, and still exists with the latest release 1.* release (1.42.0) |
most likely involved my link also: |
What happened?
I was monitoring the zigbee2mqtt logs to debug an unrelated configuration issue, and noticed one of my devices was sending a LOT of duplicate messages, which is taking up a lot of bandwidth. FYI, the device/site being monitored is 100 miles away connected over a cellular network to my home network over a wireguard VPN connection, so bandwidth IS an issue.
After setting debounce to get rid of duplicate messages, no change is being made to the published messages. Messages below are AFTER changing the settings and restarting zigbee2MQTT
And, just a few moments later
devices.yaml
(Device id modified for security.)
Device is a Sonoff S31 Lite zb (firmware version 20191113)

Version of Zigbee2MQTT is 1.30.2 (haven't upgraded as there 1.31 is experiencing a lot of updates, and this is a production setup).
What did you expect to happen?
Not send duplicate messages for the device.
Note, I have debounce on a Tuya motion detection device and that seems to be working fine.

How to reproduce it (minimal and precise)
Use a Sonoff zigbee plug and connect it to Zigbee2MQTT.
Zigbee2MQTT version
1.30.2
Adapter firmware version
20210708
Adapter
Slaesh's CC2652RB stick
Debug log
See above for some of the logs, and below for others
Note, the commit id is different from the release version, as I create a local branch that contains the stock code and commit a custom version of
devices.yaml
andconfiguration.yaml
containing my local changes which I track using git.The text was updated successfully, but these errors were encountered: