Skip to content

Commit

Permalink
Revert "Add mac address as connection for matter device (#121257)" (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt authored Jul 18, 2024
1 parent bf0e5ba commit 3d3bc1c
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 84 deletions.
30 changes: 0 additions & 30 deletions homeassistant/components/matter/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

from typing import TYPE_CHECKING, cast

from chip.clusters.Objects import GeneralDiagnostics
from matter_server.client.models.device_types import BridgedDevice
from matter_server.common.helpers.util import convert_mac_address
from matter_server.common.models import EventType, ServerInfoMessage

from homeassistant.config_entries import ConfigEntry
Expand All @@ -24,30 +22,6 @@
from matter_server.client.models.node import MatterEndpoint, MatterNode


def get_connections_for_endpoint(endpoint: MatterEndpoint) -> set[tuple[str, str]]:
"""Return a set of connections for a MatterEndpoint."""
network_interfaces: list[GeneralDiagnostics.Structs.NetworkInterface] = (
endpoint.get_attribute_value(
None, GeneralDiagnostics.Attributes.NetworkInterfaces
)
or []
)

hardware_addresses: set[str] = {
convert_mac_address(network_interface.hardwareAddress)
for network_interface in network_interfaces
if network_interface.hardwareAddress
}

return {
(dr.CONNECTION_NETWORK_MAC, address)
if len(address) == 17
else (dr.CONNECTION_ZIGBEE, address)
for address in hardware_addresses
if len(address) in (17, 23) # EUI-48 -> 17, EUI-64 -> 23
}


def get_clean_name(name: str | None) -> str | None:
"""Strip spaces and null char from the name."""
if name is None:
Expand Down Expand Up @@ -211,9 +185,6 @@ def _create_device_registry(
endpoint,
)
identifiers = {(DOMAIN, f"{ID_TYPE_DEVICE_ID}_{node_device_id}")}

connections = get_connections_for_endpoint(endpoint)

serial_number: str | None = None
# if available, we also add the serialnumber as identifier
if (
Expand All @@ -232,7 +203,6 @@ def _create_device_registry(
name=name,
config_entry_id=self.config_entry.entry_id,
identifiers=identifiers,
connections=connections,
hw_version=basic_info.hardwareVersionString,
sw_version=basic_info.softwareVersionString,
manufacturer=basic_info.vendorName or endpoint.node.device_info.vendorName,
Expand Down
54 changes: 0 additions & 54 deletions tests/components/matter/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,60 +187,6 @@ async def test_device_registry_single_node_composed_device(
assert len(dev_reg.devices) == 1


async def test_device_registry_single_node_with_connection(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
matter_client: MagicMock,
) -> None:
"""Test that a device with mac address adds a connection to the HA device entry."""
await setup_integration_with_node_fixture(
hass,
"thermostat",
matter_client,
)

assert device_registry.async_get_device(connections={("mac", "DC:54:75:5F:BA:AC")})


async def test_device_registry_single_node_without_mac_address_has_no_mac_connection(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
matter_client: MagicMock,
) -> None:
"""Test that a device without mac address doesn't have a `mac` connection in the HA device entry."""
await setup_integration_with_node_fixture(
hass,
"temperature-sensor",
matter_client,
)

entry = device_registry.async_get_device(
identifiers={
(DOMAIN, "deviceid_00000000000004D2-0000000000000001-MatterNodeDevice")
}
)

for connection_type, _ in entry.connections:
assert connection_type != dr.CONNECTION_NETWORK_MAC


async def test_device_registry_node_with_EUI64_address(
hass: HomeAssistant,
device_registry: dr.DeviceRegistry,
matter_client: MagicMock,
) -> None:
"""Test that a device with a mac address has a `zigbee` connection in the HA device entry."""
await setup_integration_with_node_fixture(
hass,
"eve-energy-plug",
matter_client,
)

assert device_registry.async_get_device(
connections={("zigbee", "ca:6b:4a:23:f6:f8:bb:ee")}
)


async def test_multi_endpoint_name(
hass: HomeAssistant,
matter_client: MagicMock,
Expand Down

0 comments on commit 3d3bc1c

Please sign in to comment.