diff --git a/homeassistant/components/thread/discovery.py b/homeassistant/components/thread/discovery.py index b2373ff9825..7dce5a429d8 100644 --- a/homeassistant/components/thread/discovery.py +++ b/homeassistant/components/thread/discovery.py @@ -32,6 +32,7 @@ class ThreadRouterDiscoveryData: addresses: list[str] | None brand: str | None + extended_address: str | None extended_pan_id: str | None model_name: str | None network_name: str | None @@ -55,6 +56,7 @@ def async_discovery_data_from_service( except UnicodeDecodeError: return None + ext_addr = service.properties.get(b"xa") ext_pan_id = service.properties.get(b"xp") network_name = try_decode(service.properties.get(b"nn")) model_name = try_decode(service.properties.get(b"mn")) @@ -78,6 +80,7 @@ def async_discovery_data_from_service( return ThreadRouterDiscoveryData( addresses=service.parsed_addresses(), brand=brand, + extended_address=ext_addr.hex() if ext_addr is not None else None, extended_pan_id=ext_pan_id.hex() if ext_pan_id is not None else None, model_name=model_name, network_name=network_name, diff --git a/tests/components/thread/test_discovery.py b/tests/components/thread/test_discovery.py index e832f18c4e6..84fe4c30974 100644 --- a/tests/components/thread/test_discovery.py +++ b/tests/components/thread/test_discovery.py @@ -73,6 +73,7 @@ async def test_discover_routers(hass: HomeAssistant, mock_async_zeroconf: None) discovery.ThreadRouterDiscoveryData( addresses=["192.168.0.115"], brand="homeassistant", + extended_address="aeeb2f594b570bbf", extended_pan_id="e60fc7c186212ce5", model_name="OpenThreadBorderRouter", network_name="OpenThread HC", @@ -98,6 +99,7 @@ async def test_discover_routers(hass: HomeAssistant, mock_async_zeroconf: None) discovery.ThreadRouterDiscoveryData( addresses=["192.168.0.124"], brand="google", + extended_address="f6a99b425a67abed", extended_pan_id="9e75e256f61409a3", model_name="Google Nest Hub", network_name="NEST-PAN-E1AF", @@ -175,6 +177,7 @@ async def test_discover_routers_unconfigured( discovery.ThreadRouterDiscoveryData( addresses=["192.168.0.115"], brand="homeassistant", + extended_address="aeeb2f594b570bbf", extended_pan_id="e60fc7c186212ce5", model_name="OpenThreadBorderRouter", network_name="OpenThread HC", @@ -219,6 +222,7 @@ async def test_discover_routers_bad_data( discovery.ThreadRouterDiscoveryData( addresses=["192.168.0.115"], brand=None, + extended_address="aeeb2f594b570bbf", extended_pan_id="e60fc7c186212ce5", model_name="OpenThreadBorderRouter", network_name="OpenThread HC", diff --git a/tests/components/thread/test_websocket_api.py b/tests/components/thread/test_websocket_api.py index 0f3a2ff7654..f8f09b0b8cc 100644 --- a/tests/components/thread/test_websocket_api.py +++ b/tests/components/thread/test_websocket_api.py @@ -236,6 +236,7 @@ async def test_discover_routers( "data": { "addresses": ["192.168.0.115"], "brand": "homeassistant", + "extended_address": "aeeb2f594b570bbf", "extended_pan_id": "e60fc7c186212ce5", "model_name": "OpenThreadBorderRouter", "network_name": "OpenThread HC", @@ -264,6 +265,7 @@ async def test_discover_routers( "data": { "addresses": ["192.168.0.124"], "brand": "google", + "extended_address": "f6a99b425a67abed", "extended_pan_id": "9e75e256f61409a3", "model_name": "Google Nest Hub", "network_name": "NEST-PAN-E1AF",