mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Add missing brackets to ESPHome configuration URLs with IPv6 addresses (#137132)
fixes #137125
This commit is contained in:
parent
27f89f7710
commit
39a575dd29
@ -573,7 +573,9 @@ def _async_setup_device_registry(
|
|||||||
|
|
||||||
configuration_url = None
|
configuration_url = None
|
||||||
if device_info.webserver_port > 0:
|
if device_info.webserver_port > 0:
|
||||||
configuration_url = f"http://{entry.data['host']}:{device_info.webserver_port}"
|
entry_host = entry.data["host"]
|
||||||
|
host = f"[{entry_host}]" if ":" in entry_host else entry_host
|
||||||
|
configuration_url = f"http://{host}:{device_info.webserver_port}"
|
||||||
elif (
|
elif (
|
||||||
(dashboard := async_get_dashboard(hass))
|
(dashboard := async_get_dashboard(hass))
|
||||||
and dashboard.data
|
and dashboard.data
|
||||||
|
@ -1100,6 +1100,42 @@ async def test_esphome_device_with_web_server(
|
|||||||
assert dev.configuration_url == "http://test.local:80"
|
assert dev.configuration_url == "http://test.local:80"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_esphome_device_with_ipv6_web_server(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
device_registry: dr.DeviceRegistry,
|
||||||
|
mock_client: APIClient,
|
||||||
|
mock_esphome_device: Callable[
|
||||||
|
[APIClient, list[EntityInfo], list[UserService], list[EntityState]],
|
||||||
|
Awaitable[MockESPHomeDevice],
|
||||||
|
],
|
||||||
|
) -> None:
|
||||||
|
"""Test a device with a web server."""
|
||||||
|
entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN,
|
||||||
|
data={
|
||||||
|
CONF_HOST: "fe80::1",
|
||||||
|
CONF_PORT: 6053,
|
||||||
|
CONF_PASSWORD: "",
|
||||||
|
},
|
||||||
|
options={},
|
||||||
|
)
|
||||||
|
entry.add_to_hass(hass)
|
||||||
|
device = await mock_esphome_device(
|
||||||
|
mock_client=mock_client,
|
||||||
|
entry=entry,
|
||||||
|
entity_info=[],
|
||||||
|
user_service=[],
|
||||||
|
device_info={"webserver_port": 80},
|
||||||
|
states=[],
|
||||||
|
)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
entry = device.entry
|
||||||
|
dev = device_registry.async_get_device(
|
||||||
|
connections={(dr.CONNECTION_NETWORK_MAC, entry.unique_id)}
|
||||||
|
)
|
||||||
|
assert dev.configuration_url == "http://[fe80::1]:80"
|
||||||
|
|
||||||
|
|
||||||
async def test_esphome_device_with_compilation_time(
|
async def test_esphome_device_with_compilation_time(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
device_registry: dr.DeviceRegistry,
|
device_registry: dr.DeviceRegistry,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user