diff --git a/homeassistant/components/deconz/config_flow.py b/homeassistant/components/deconz/config_flow.py index e4d61394ce0..109afb6190f 100644 --- a/homeassistant/components/deconz/config_flow.py +++ b/homeassistant/components/deconz/config_flow.py @@ -33,6 +33,7 @@ from .const import ( CONF_BRIDGE_ID, DEFAULT_PORT, DOMAIN, + HASSIO_CONFIGURATION_URL, LOGGER, ) from .gateway import DeconzGateway, get_gateway_from_config_entry @@ -227,7 +228,12 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN): updates={CONF_HOST: hostname, CONF_PORT: port} ) - self.context["title_placeholders"] = {"host": hostname} + self.context.update( + { + "title_placeholders": {"host": hostname}, + "configuration_url": f"http://{hostname}:{port}", + } + ) self.deconz_config = {CONF_HOST: hostname, CONF_PORT: port} @@ -251,6 +257,8 @@ class DeconzFlowHandler(ConfigFlow, domain=DOMAIN): } ) + self.context["configuration_url"] = HASSIO_CONFIGURATION_URL + self._hassio_discovery = discovery_info.config return await self.async_step_hassio_confirm() diff --git a/homeassistant/components/deconz/const.py b/homeassistant/components/deconz/const.py index ad668934acf..5f6d77a69fd 100644 --- a/homeassistant/components/deconz/const.py +++ b/homeassistant/components/deconz/const.py @@ -7,6 +7,8 @@ LOGGER = logging.getLogger(__package__) DOMAIN = "deconz" +HASSIO_CONFIGURATION_URL = "homeassistant://hassio/ingress/core_deconz" + CONF_BRIDGE_ID = "bridgeid" CONF_GROUP_ID_BASE = "group_id_base" diff --git a/homeassistant/components/deconz/gateway.py b/homeassistant/components/deconz/gateway.py index 8742cd087d4..8fa0c6133df 100644 --- a/homeassistant/components/deconz/gateway.py +++ b/homeassistant/components/deconz/gateway.py @@ -25,6 +25,7 @@ from .const import ( DEFAULT_ALLOW_DECONZ_GROUPS, DEFAULT_ALLOW_NEW_DEVICES, DOMAIN as DECONZ_DOMAIN, + HASSIO_CONFIGURATION_URL, LOGGER, PLATFORMS, ) @@ -152,7 +153,7 @@ class DeconzGateway: # Gateway service configuration_url = f"http://{self.host}:{self.config_entry.data[CONF_PORT]}" if self.config_entry.source == SOURCE_HASSIO: - configuration_url = "homeassistant://hassio/ingress/core_deconz" + configuration_url = HASSIO_CONFIGURATION_URL device_registry.async_get_or_create( config_entry_id=self.config_entry.entry_id, configuration_url=configuration_url, diff --git a/tests/components/deconz/test_config_flow.py b/tests/components/deconz/test_config_flow.py index ecfb324207f..8ed1e348fee 100644 --- a/tests/components/deconz/test_config_flow.py +++ b/tests/components/deconz/test_config_flow.py @@ -17,6 +17,7 @@ from homeassistant.components.deconz.const import ( CONF_ALLOW_NEW_DEVICES, CONF_MASTER_GATEWAY, DOMAIN as DECONZ_DOMAIN, + HASSIO_CONFIGURATION_URL, ) from homeassistant.components.hassio import HassioServiceInfo from homeassistant.components.ssdp import ATTR_UPNP_MANUFACTURER_URL, ATTR_UPNP_SERIAL @@ -425,6 +426,10 @@ async def test_flow_ssdp_discovery(hass, aioclient_mock): assert result["type"] == RESULT_TYPE_FORM assert result["step_id"] == "link" + 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" + aioclient_mock.post( "http://1.2.3.4:80/api", json=[{"success": {"username": API_KEY}}], @@ -558,6 +563,12 @@ async def test_flow_hassio_discovery(hass): assert result["step_id"] == "hassio_confirm" assert result["description_placeholders"] == {"addon": "Mock Addon"} + flows = hass.config_entries.flow.async_progress() + assert len(flows) == 1 + assert ( + flows[0].get("context", {}).get("configuration_url") == HASSIO_CONFIGURATION_URL + ) + with patch( "homeassistant.components.deconz.async_setup_entry", return_value=True,