diff --git a/homeassistant/components/axis/.translations/en.json b/homeassistant/components/axis/.translations/en.json index 5fd5d9be565..c7d84aa8cc3 100644 --- a/homeassistant/components/axis/.translations/en.json +++ b/homeassistant/components/axis/.translations/en.json @@ -12,6 +12,7 @@ "device_unavailable": "Device is not available", "faulty_credentials": "Bad user credentials" }, + "flow_title": "Axis device: {name} ({host})", "step": { "user": { "data": { diff --git a/homeassistant/components/axis/config_flow.py b/homeassistant/components/axis/config_flow.py index 3473eba3065..5eb4f9daddd 100644 --- a/homeassistant/components/axis/config_flow.py +++ b/homeassistant/components/axis/config_flow.py @@ -191,6 +191,12 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): load_json, self.hass.config.path(CONFIG_FILE) ) + # pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167 + self.context["title_placeholders"] = { + "name": discovery_info["hostname"][:-7], + "host": discovery_info[CONF_HOST], + } + if serialnumber not in config_file: self.discovery_schema = { vol.Required(CONF_HOST, default=discovery_info[CONF_HOST]): str, @@ -198,6 +204,7 @@ class AxisFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): vol.Required(CONF_PASSWORD): str, vol.Required(CONF_PORT, default=discovery_info[CONF_PORT]): int, } + return await self.async_step_user() try: diff --git a/homeassistant/components/axis/strings.json b/homeassistant/components/axis/strings.json index 29fe09b7e5b..2dc23f3e466 100644 --- a/homeassistant/components/axis/strings.json +++ b/homeassistant/components/axis/strings.json @@ -1,6 +1,7 @@ { "config": { "title": "Axis device", + "flow_title": "Axis device: {name} ({host})", "step": { "user": { "title": "Set up Axis device", diff --git a/tests/components/axis/test_config_flow.py b/tests/components/axis/test_config_flow.py index 5ec3f933e9e..5aec416961d 100644 --- a/tests/components/axis/test_config_flow.py +++ b/tests/components/axis/test_config_flow.py @@ -186,6 +186,7 @@ async def test_zeroconf_flow(hass): data={ config_flow.CONF_HOST: "1.2.3.4", config_flow.CONF_PORT: 80, + "hostname": "name", "properties": {"macaddress": "00408C12345"}, }, context={"source": "zeroconf"}, @@ -319,6 +320,7 @@ async def test_zeroconf_flow_bad_config_file(hass): config_flow.DOMAIN, data={ config_flow.CONF_HOST: "1.2.3.4", + "hostname": "name", "properties": {"macaddress": "00408C12345"}, }, context={"source": "zeroconf"},