Fix Matter device ID for non-bridged composed device (#118256)
This commit is contained in:
parent
a5f81262aa
commit
21f5ac7715
2 changed files with 20 additions and 6 deletions
|
@ -59,12 +59,12 @@ def get_device_id(
|
|||
) -> str:
|
||||
"""Return HA device_id for the given MatterEndpoint."""
|
||||
operational_instance_id = get_operational_instance_id(server_info, endpoint.node)
|
||||
# Append endpoint ID if this endpoint is a bridged or composed device
|
||||
if endpoint.is_composed_device:
|
||||
compose_parent = endpoint.node.get_compose_parent(endpoint.endpoint_id)
|
||||
assert compose_parent is not None
|
||||
postfix = str(compose_parent.endpoint_id)
|
||||
elif endpoint.is_bridged_device:
|
||||
# if this is a composed device we need to get the compose parent
|
||||
# example: Philips Hue motion sensor on Hue Hub (bridged to Matter)
|
||||
if compose_parent := endpoint.node.get_compose_parent(endpoint.endpoint_id):
|
||||
endpoint = compose_parent
|
||||
if endpoint.is_bridged_device:
|
||||
# Append endpoint ID if this endpoint is a bridged device
|
||||
postfix = str(endpoint.endpoint_id)
|
||||
else:
|
||||
# this should be compatible with previous versions
|
||||
|
|
|
@ -172,6 +172,20 @@ async def test_node_added_subscription(
|
|||
assert entity_state
|
||||
|
||||
|
||||
async def test_device_registry_single_node_composed_device(
|
||||
hass: HomeAssistant,
|
||||
matter_client: MagicMock,
|
||||
) -> None:
|
||||
"""Test that a composed device within a standalone node only creates one HA device entry."""
|
||||
await setup_integration_with_node_fixture(
|
||||
hass,
|
||||
"air-purifier",
|
||||
matter_client,
|
||||
)
|
||||
dev_reg = dr.async_get(hass)
|
||||
assert len(dev_reg.devices) == 1
|
||||
|
||||
|
||||
async def test_get_clean_name_() -> None:
|
||||
"""Test get_clean_name helper.
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue