From 1551da33ac2c7fd9f81cf3e3e5c40ce3ff992009 Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Thu, 20 Jan 2022 09:47:02 +0100 Subject: [PATCH] Expose Axis device configuration url from discovered entry (#64517) --- homeassistant/components/axis/config_flow.py | 13 +++++++++---- tests/components/axis/test_config_flow.py | 4 ++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/axis/config_flow.py b/homeassistant/components/axis/config_flow.py index a47592fc877..5ec68073610 100644 --- a/homeassistant/components/axis/config_flow.py +++ b/homeassistant/components/axis/config_flow.py @@ -205,10 +205,15 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=AXIS_DOMAIN): } ) - self.context["title_placeholders"] = { - CONF_NAME: device[CONF_NAME], - CONF_HOST: device[CONF_HOST], - } + self.context.update( + { + "title_placeholders": { + CONF_NAME: device[CONF_NAME], + CONF_HOST: device[CONF_HOST], + }, + "configuration_url": f"http://{device[CONF_HOST]}:{device[CONF_PORT]}", + } + ) self.discovery_schema = { vol.Required(CONF_HOST, default=device[CONF_HOST]): str, diff --git a/tests/components/axis/test_config_flow.py b/tests/components/axis/test_config_flow.py index 6263c62be42..bc03cb99f07 100644 --- a/tests/components/axis/test_config_flow.py +++ b/tests/components/axis/test_config_flow.py @@ -319,6 +319,10 @@ async def test_discovery_flow(hass, source: str, discovery_info: dict): assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == SOURCE_USER + flows = hass.config_entries.flow.async_progress() + assert len(flows) == 1 + assert flows[0].get("context", {}).get("configuration_url") == "http://1.2.3.4:80" + with respx.mock: mock_default_vapix_requests(respx) result = await hass.config_entries.flow.async_configure(