-
Notifications
You must be signed in to change notification settings - Fork 70
Do not bind clusters whose entities are not created #783
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1198,6 +1198,32 @@ async def test_join_binding_reporting(zha_gateway: Gateway) -> None: | |
| ] | ||
|
|
||
|
|
||
| async def test_quirks_v2_prevent_entity_also_prevents_binding( | ||
| zha_gateway: Gateway, | ||
| ) -> None: | ||
| """A quirk-prevented entity must not drive cluster binding.""" | ||
| zigpy_dev = await zigpy_device_from_json( | ||
| zha_gateway.application_controller, | ||
| "tests/data/devices/innr-sp-240.json", | ||
| ) | ||
|
|
||
| level = zigpy_dev.endpoints[1].level | ||
| on_off = zigpy_dev.endpoints[1].on_off | ||
|
|
||
| with ( | ||
| patch.object(level, "bind", wraps=level.bind) as mock_level_bind, | ||
| patch.object(on_off, "bind", wraps=on_off.bind) as mock_on_off_bind, | ||
| ): | ||
| zha_device = await join_zigpy_device(zha_gateway, zigpy_dev) | ||
|
Comment on lines
+1205
to
+1217
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, my docstring comment below is related to this. I do kind of agree that it's not perfect to have ZHA rely on zha-quirks for its tests (that do not test the quirk but some ZHA feature). Realistically, the quirk for this device should never change, so I think updating the docstring a bit is probably enough. |
||
|
|
||
| assert zha_device.quirk_applied | ||
|
|
||
| # The prevented LevelControl entity no longer binds its cluster, while the | ||
| # sibling OnOff entity (not prevented) still does. | ||
| assert mock_level_bind.mock_calls == [] | ||
| assert mock_on_off_bind.mock_calls == [call()] | ||
|
|
||
|
|
||
| async def test_endpoint_none_profile( | ||
| zha_gateway: Gateway, | ||
| caplog: pytest.LogCaptureFixture, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1158,10 +1158,14 @@ def _discover_new_entities(self) -> None: | |
|
|
||
| # Discover all applicable entities | ||
| for entity in new_entities: | ||
| self._discovered_entities.append(entity) | ||
| # A quirk-prevented entity must not drive cluster binding or | ||
| # reporting either, so it's kept out of `_discovered_entities` | ||
| # (the source for `aggregate_cluster_configs`) entirely. | ||
| if self._is_entity_removed_by_quirk(entity): | ||
| continue | ||
|
|
||
| self._discovered_entities.append(entity) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docstring on this list at |
||
|
|
||
|
Comment on lines
+1161
to
+1168
|
||
| # Apply any metadata changes from quirks v2 | ||
| self._apply_entity_metadata_changes(entity) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, the docstring would describe a bit better what the quirk does here, since you have to guess a bit, or know that it prevents default entity creation for all entities on the
LevelControlcluster.