Debounce group entity update when member state changes #74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 aDebouncer
for group member updates and created adebounced_update
method to delay updates from member entities. Also, added a cleanup step in theon_remove
method to cancel any tasks owned by the entity. [1] [2]zha/zigbee/group.py
: Updated theupdate_entity_subscriptions
method to use thedebounced_update
method instead of theupdate
method.Test file updates:
tests/test_fan.py
: Importedasyncio
and added a delay after member updates to account for debouncing. Also added apytest.mark.looptime
decorator to thetest_zha_group_fan_entity
method. [1] [2] [3]tests/test_light.py
,tests/test_switch.py
: Similar changes were made as intest_fan.py
, adding delays after member updates and importingasyncio
. [1] [2] [3]tests/test_light.py
file to add delays after member updates in various test methods. [1] [2] [3] [4] [5] [6] [7]tests/test_switch.py
file to add delays after member updates in thetest_zha_group_switch_entity
method. [1] [2]