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

Debounce group entity update when member state changes #74

Merged
merged 4 commits into from
Jul 10, 2024

Conversation

dmulcahey
Copy link
Contributor

This pull request primarily focuses on implementing debouncing for group member updates. Debouncing is used to ensure that updates are not processed immediately but are delayed to accumulate all updates from members before updating the group entity.

Here are the most significant changes:

Debouncing implementation:

  • zha/application/platforms/__init__.py: Introduced a Debouncer for group member updates and created a debounced_update method to delay updates from member entities. Also, added a cleanup step in the on_remove method to cancel any tasks owned by the entity. [1] [2]
  • zha/zigbee/group.py: Updated the update_entity_subscriptions method to use the debounced_update method instead of the update method.

Test file updates:

  • tests/test_fan.py: Imported asyncio and added a delay after member updates to account for debouncing. Also added a pytest.mark.looptime decorator to the test_zha_group_fan_entity method. [1] [2] [3]
  • tests/test_light.py, tests/test_switch.py: Similar changes were made as in test_fan.py, adding delays after member updates and importing asyncio. [1] [2] [3]
  • Multiple changes were made in the tests/test_light.py file to add delays after member updates in various test methods. [1] [2] [3] [4] [5] [6] [7]
  • Similar changes were made in the tests/test_switch.py file to add delays after member updates in the test_zha_group_switch_entity method. [1] [2]

Copy link

codecov bot commented Jul 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.39%. Comparing base (155b877) to head (d793fe4).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #74      +/-   ##
==========================================
+ Coverage   95.30%   95.39%   +0.09%     
==========================================
  Files          61       61              
  Lines        9268     9279      +11     
==========================================
+ Hits         8833     8852      +19     
+ Misses        435      427       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@puddly puddly linked an issue Jul 10, 2024 that may be closed by this pull request
@puddly puddly merged commit 782f9f6 into dev Jul 10, 2024
4 checks passed
@dmulcahey dmulcahey deleted the dm/debounce-group-updates branch August 18, 2024 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing group light debouncing support
3 participants