diff --git a/homeassistant/components/sfr_box/config_flow.py b/homeassistant/components/sfr_box/config_flow.py index df7f64c376e..8eae4ab49f2 100644 --- a/homeassistant/components/sfr_box/config_flow.py +++ b/homeassistant/components/sfr_box/config_flow.py @@ -30,14 +30,11 @@ class SFRBoxFlowHandler(ConfigFlow, domain=DOMAIN): """Handle a flow initialized by the user.""" errors = {} if user_input is not None: + box = SFRBox(ip=user_input[CONF_HOST], client=get_async_client(self.hass)) try: - box = SFRBox( - ip=user_input[CONF_HOST], - client=get_async_client(self.hass), - ) system_info = await box.system_get_info() except SFRBoxError: - errors["base"] = "unknown" + errors["base"] = "cannot_connect" else: await self.async_set_unique_id(system_info.mac_addr) self._abort_if_unique_id_configured() diff --git a/homeassistant/components/sfr_box/strings.json b/homeassistant/components/sfr_box/strings.json index 675a179dfd3..52d57eda809 100644 --- a/homeassistant/components/sfr_box/strings.json +++ b/homeassistant/components/sfr_box/strings.json @@ -8,7 +8,7 @@ } }, "error": { - "unknown": "[%key:common::config_flow::error::unknown%]" + "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]" }, "abort": { "already_configured": "[%key:common::config_flow::abort::already_configured_device%]" diff --git a/homeassistant/components/sfr_box/translations/en.json b/homeassistant/components/sfr_box/translations/en.json index 0bfaeb19d9d..10441d21536 100644 --- a/homeassistant/components/sfr_box/translations/en.json +++ b/homeassistant/components/sfr_box/translations/en.json @@ -4,7 +4,7 @@ "already_configured": "Device is already configured" }, "error": { - "unknown": "Unexpected error" + "cannot_connect": "Failed to connect" }, "step": { "user": { diff --git a/tests/components/sfr_box/test_config_flow.py b/tests/components/sfr_box/test_config_flow.py index a8625b90eee..ecdebad66e2 100644 --- a/tests/components/sfr_box/test_config_flow.py +++ b/tests/components/sfr_box/test_config_flow.py @@ -43,7 +43,7 @@ async def test_config_flow(hass: HomeAssistant, mock_setup_entry: AsyncMock): ) assert result["type"] == data_entry_flow.FlowResultType.FORM - assert result["errors"] == {"base": "unknown"} + assert result["errors"] == {"base": "cannot_connect"} system_info = SystemInfo(**json.loads(load_fixture("system_getInfo.json", DOMAIN))) with patch(