Skip to content
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

[feature] debounce for groups #3461

Closed
sjorge opened this issue Apr 30, 2020 · 19 comments
Closed

[feature] debounce for groups #3461

sjorge opened this issue Apr 30, 2020 · 19 comments
Labels
feature request Feature request

Comments

@sjorge
Copy link
Sponsor Contributor

sjorge commented Apr 30, 2020

Bug Report

What happened

I noticed I get a attReport from 2 bulbs in a group usually within a second of eachother, the group update get published twice to mqtt with the sam payload.

What did you expect to happen

I expected to be able to set 'debounce' for a group, but that had no effect.
Looking at the code, I don't think that is currently support. So I guess this is a feature request.

How to reproduce it (minimal and precise)

Add 2 trådfri bulbs to a group, then change the state via the group.

  • both bulbs change state
  • both bulbs withing < 1 sec publish an attReport for genOnOff with the new state
  • group gets published twice more (I think 3 times as once gets published form setting the state via the group too)
@sjorge sjorge changed the title [featyre] debounce for groups [feature] debounce for groups May 1, 2020
@Koenkk Koenkk added the feature request Feature request label May 2, 2020
@stale
Copy link

stale bot commented Jul 2, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Stale issues label Jul 2, 2020
@sjorge
Copy link
Sponsor Contributor Author

sjorge commented Jul 2, 2020

Still wanted

@stale stale bot removed the stale Stale issues label Jul 2, 2020
@stale
Copy link

stale bot commented Aug 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Stale issues label Aug 1, 2020
@sjorge
Copy link
Sponsor Contributor Author

sjorge commented Aug 1, 2020

Unstale

@stale stale bot removed the stale Stale issues label Aug 1, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Sep 1, 2020

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

@github-actions github-actions bot added the stale Stale issues label Sep 1, 2020
@sjorge
Copy link
Sponsor Contributor Author

sjorge commented Sep 1, 2020

Unstale

@github-actions github-actions bot removed the stale Stale issues label Sep 1, 2020
@Koenkk
Copy link
Owner

Koenkk commented Oct 8, 2020

I'm wondering that instead of debounce, we can also not publish a new group state when there is nothing different to be published. This has to advantage of not having to wait the debounce time before a new state gets published.

@sjorge
Copy link
Sponsor Contributor Author

sjorge commented Oct 8, 2020

Should we not try to keep the behavior consistent between groups and devices?

Although both would work for my use case.

@Koenkk
Copy link
Owner

Koenkk commented Oct 8, 2020

Both yes and no, the no part is not to add features/settings for things that are not used. Besides that not republishing the "optimistic" state for groups when it didn't change makes a lot of sense, I can't imagine why you don't want this.

@sjorge
Copy link
Sponsor Contributor Author

sjorge commented Oct 8, 2020

True but should this not be done for groups and devices then? (although, I guess if the elapse or last_seen are in the payload we then should...)

Edit, attempt at better phrasing

Yes, not updating when there is no change makes more sense and would make debounce for groups not necessary.
But if we do this publish on change only, we should also do it for devices, as it would also make sense there.

Although for devices there are some exceptions I think like when the elapsed or last_seen payload is present.

@Koenkk
Copy link
Owner

Koenkk commented Oct 9, 2020

I only meant the optimistic state for groups based on device changes. So a /set on a group will still publish a state update, even when identical. But when e.g. 2 bulbs in a group report they have been turned off, the group will only publish it's updated state once.

Please try the groups.js changes from https://github.com/Koenkk/zigbee2mqtt/pull/4623/files

@sjorge
Copy link
Sponsor Contributor Author

sjorge commented Oct 9, 2020

Seems to behave as expected.

Both triggered via remote or via mqtt will result in 1 publish

@Koenkk
Copy link
Owner

Koenkk commented Oct 9, 2020

Good, does it solve your OP issue? Because this is exactly what you described in "How to reproduce"

@sjorge
Copy link
Sponsor Contributor Author

sjorge commented Oct 9, 2020

Yeah this is fine for my use case. my 6 bulb groups now no longer spam mqtt messages 1-3 sec after toggling them via de group.

Koenkk added a commit that referenced this issue Oct 9, 2020
* Don't republish identical optimistic state for groups. #3461

* Fixes
@Koenkk
Copy link
Owner

Koenkk commented Oct 9, 2020

Great, merged I assume we can close this now 😄

@Koenkk Koenkk closed this as completed Oct 9, 2020
@sjorge
Copy link
Sponsor Contributor Author

sjorge commented Oct 9, 2020

Something is still broken after restarting z2m, I need to investigate more but it looks like it does not republish retained messages for groups at startup now.

@sjorge
Copy link
Sponsor Contributor Author

sjorge commented Oct 10, 2020

I've just verified this is indeed the case! :(

How I verified this:

  • start the following mqtt subs
    • mosquitto_sub -t 'zigbee2mqtt/office/floor_light' | jq .
    • mosquitto_sub -t 'zigbee2mqtt/office/floor_light/bulb' | jq .
  • restart zigbee2mqtt

Only the sub that was for a device got the payload published again as expected, the sub for the group did not.
This breaks most of my node-red integration, I assume it's a side effect of checking if the current payload changed vs the cached payload. Which after restart, would be the case and also be skipped.

I guess the one that publishes at startup should get called with a 'force' flag or something that will always (re)publish.

@Koenkk
Copy link
Owner

Koenkk commented Oct 10, 2020

@sjorge fixed

@sjorge
Copy link
Sponsor Contributor Author

sjorge commented Oct 10, 2020

Looks good now after grabbing the latest dev.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature request
Projects
None yet
Development

No branches or pull requests

2 participants