Adjust device registry for Matter devices (#86108)

* adjust device registry

* ignore test unique id

* update test

* ditch uniqueid + prefix serial

* adjust test

* add tests

* fix switch test

* prefix all identifiers

* Update homeassistant/components/matter/adapter.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* no underscore in id

* fix test

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Marcel van der Veldt 2023-01-18 17:17:33 +01:00 committed by GitHub
parent 5e6ba594aa
commit 4bebf00598
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 57 additions and 21 deletions

View file

@ -28,10 +28,13 @@ async def test_device_registry_single_node_device(
dev_reg = dr.async_get(hass)
entry = dev_reg.async_get_device(
{(DOMAIN, "00000000000004D2-0000000000000001-MatterNodeDevice")}
{(DOMAIN, "deviceid_00000000000004D2-0000000000000001-MatterNodeDevice")}
)
assert entry is not None
# test serial id present as additional identifier
assert (DOMAIN, "serial_12345678") in entry.identifiers
assert entry.name == "Mock OnOff Light"
assert entry.manufacturer == "Nabu Casa"
assert entry.model == "Mock Light"
@ -39,6 +42,30 @@ async def test_device_registry_single_node_device(
assert entry.sw_version == "v1.0"
async def test_device_registry_single_node_device_alt(
hass: HomeAssistant,
matter_client: MagicMock,
) -> None:
"""Test additional device with different attribute values."""
await setup_integration_with_node_fixture(
hass,
"on-off-plugin-unit",
matter_client,
)
dev_reg = dr.async_get(hass)
entry = dev_reg.async_get_device(
{(DOMAIN, "deviceid_00000000000004D2-0000000000000001-MatterNodeDevice")}
)
assert entry is not None
# test name is derived from productName (because nodeLabel is absent)
assert entry.name == "Mock OnOffPluginUnit (powerplug/switch)"
# test serial id NOT present as additional identifier
assert (DOMAIN, "serial_TEST_SN") not in entry.identifiers
@pytest.mark.skip("Waiting for a new test fixture")
async def test_device_registry_bridge(
hass: HomeAssistant,