Skip to content

Commit 5936334

Browse files
authored
Fix printing log message for None profile id (#440)
* Fix printing log message for `None` profile id * Add test for coverage * Remove part of test already tested elsewhere
1 parent 19221a5 commit 5936334

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

tests/test_device.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,3 +950,16 @@ async def test_join_binding_reporting(zha_gateway: Gateway) -> None:
950950
assert mock_reporting_config.mock_calls == [
951951
call({"measured_value": (30, 900, 1e-6)})
952952
]
953+
954+
955+
async def test_endpoint_none_profile(
956+
zha_gateway: Gateway,
957+
caplog: pytest.LogCaptureFixture,
958+
) -> None:
959+
"""Test endpoint with None profile id being skipped."""
960+
zigpy_dev = zigpy_device(zha_gateway, with_basic_cluster_handler=True)
961+
zigpy_dev.endpoints[3].profile_id = None
962+
zha_device = await join_zigpy_device(zha_gateway, zigpy_dev)
963+
964+
assert zha_device.async_get_std_clusters() == {}
965+
assert "Skipping endpoint, profile is None" in caplog.text

zha/zigbee/endpoint.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,13 @@ def new(cls, zigpy_endpoint: ZigpyEndpoint, device: Device) -> Endpoint:
135135
def add_all_cluster_handlers(self) -> None:
136136
"""Create and add cluster handlers for all input clusters."""
137137
profile_id = self._zigpy_endpoint.profile_id
138-
if profile_id not in (ZLL_PROFILE_ID, ZHA_PROFILE_ID):
138+
if profile_id is None:
139+
_LOGGER.debug("Skipping endpoint, profile is None")
140+
return
141+
elif profile_id not in (ZLL_PROFILE_ID, ZHA_PROFILE_ID):
139142
_LOGGER.debug(
140143
"Skipping endpoint, profile is not ZLL or ZHA: 0x%04X",
141-
self._zigpy_endpoint.profile_id,
144+
profile_id,
142145
)
143146
return
144147

0 commit comments

Comments
 (0)