Handle IPv6 URLs in devolo Home Network (#139191)

* Handle IPv6 URLs in devolo Home Network

* Use yarl
This commit is contained in:
Guido Schmitz 2025-03-01 13:29:50 +01:00 committed by Bram Kragten
parent b4b7142b55
commit a0668e5a5b
4 changed files with 49 additions and 2 deletions

View File

@ -8,6 +8,7 @@ from devolo_plc_api.device_api import (
WifiGuestAccessGet,
)
from devolo_plc_api.plcnet_api import DataRate, LogicalNetwork
from yarl import URL
from homeassistant.const import ATTR_CONNECTIONS
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC, DeviceInfo
@ -43,7 +44,7 @@ class DevoloEntity(Entity):
self.entry = entry
self._attr_device_info = DeviceInfo(
configuration_url=f"http://{self.device.ip}",
configuration_url=URL.build(scheme="http", host=self.device.ip),
identifiers={(DOMAIN, str(self.device.serial_number))},
manufacturer="devolo",
model=self.device.product,

View File

@ -27,6 +27,13 @@ def mock_repeater_device(mock_device: MockDevice):
return mock_device
@pytest.fixture
def mock_ipv6_device(mock_device: MockDevice):
"""Mock connecting to a devolo home network device using IPv6."""
mock_device.ip = "2001:db8::1"
return mock_device
@pytest.fixture
def mock_nonwifi_device(mock_device: MockDevice):
"""Mock connecting to a devolo home network device without wifi."""

View File

@ -36,6 +36,43 @@
'via_device_id': None,
})
# ---
# name: test_setup_entry[mock_ipv6_device]
DeviceRegistryEntrySnapshot({
'area_id': None,
'config_entries': <ANY>,
'config_entries_subentries': <ANY>,
'configuration_url': 'http://[2001:db8::1]',
'connections': set({
tuple(
'mac',
'aa:bb:cc:dd:ee:ff',
),
}),
'disabled_by': None,
'entry_type': None,
'hw_version': None,
'id': <ANY>,
'identifiers': set({
tuple(
'devolo_home_network',
'1234567890',
),
}),
'is_new': False,
'labels': set({
}),
'manufacturer': 'devolo',
'model': 'dLAN pro 1200+ WiFi ac',
'model_id': '2730',
'name': 'Mock Title',
'name_by_user': None,
'primary_config_entry': <ANY>,
'serial_number': '1234567890',
'suggested_area': None,
'sw_version': '5.6.1',
'via_device_id': None,
})
# ---
# name: test_setup_entry[mock_repeater_device]
DeviceRegistryEntrySnapshot({
'area_id': None,

View File

@ -27,7 +27,9 @@ from .mock import MockDevice
from tests.common import MockConfigEntry
@pytest.mark.parametrize("device", ["mock_device", "mock_repeater_device"])
@pytest.mark.parametrize(
"device", ["mock_device", "mock_repeater_device", "mock_ipv6_device"]
)
async def test_setup_entry(
hass: HomeAssistant,
device: str,