diff --git a/homeassistant/components/fritzbox/config_flow.py b/homeassistant/components/fritzbox/config_flow.py index 6f4befab8ff..ee1b3aff241 100644 --- a/homeassistant/components/fritzbox/config_flow.py +++ b/homeassistant/components/fritzbox/config_flow.py @@ -31,8 +31,8 @@ DATA_SCHEMA_CONFIRM = vol.Schema( } ) -RESULT_AUTH_FAILED = "auth_failed" -RESULT_NOT_FOUND = "not_found" +RESULT_INVALID_AUTH = "invalid_auth" +RESULT_NO_DEVICES_FOUND = "no_devices_found" RESULT_NOT_SUPPORTED = "not_supported" RESULT_SUCCESS = "success" @@ -73,11 +73,11 @@ class FritzboxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): fritzbox.logout() return RESULT_SUCCESS except LoginError: - return RESULT_AUTH_FAILED + return RESULT_INVALID_AUTH except HTTPError: return RESULT_NOT_SUPPORTED except OSError: - return RESULT_NOT_FOUND + return RESULT_NO_DEVICES_FOUND async def async_step_import(self, user_input=None): """Handle configuration by yaml file.""" @@ -102,7 +102,7 @@ class FritzboxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): if result == RESULT_SUCCESS: return self._get_entry() - if result != RESULT_AUTH_FAILED: + if result != RESULT_INVALID_AUTH: return self.async_abort(reason=result) errors["base"] = result @@ -150,7 +150,7 @@ class FritzboxConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): if result == RESULT_SUCCESS: return self._get_entry() - if result != RESULT_AUTH_FAILED: + if result != RESULT_INVALID_AUTH: return self.async_abort(reason=result) errors["base"] = result diff --git a/homeassistant/components/fritzbox/strings.json b/homeassistant/components/fritzbox/strings.json index 5a537b33e7b..141348583f4 100644 --- a/homeassistant/components/fritzbox/strings.json +++ b/homeassistant/components/fritzbox/strings.json @@ -20,12 +20,12 @@ }, "abort": { "already_in_progress": "[%key:common::config_flow::abort::already_in_progress%]", - "already_configured": "This AVM FRITZ!Box is already configured.", - "not_found": "No supported AVM FRITZ!Box found on the network.", + "already_configured": "[%key:common::config_flow::abort::already_configured_device%]", + "no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]", "not_supported": "Connected to AVM FRITZ!Box but it's unable to control Smart Home devices." }, "error": { - "auth_failed": "Username and/or password are incorrect." + "invalid_auth": "[%key:common::config_flow::error::invalid_auth%]" } } } diff --git a/tests/components/fritzbox/test_config_flow.py b/tests/components/fritzbox/test_config_flow.py index 35b41d52118..41396735441 100644 --- a/tests/components/fritzbox/test_config_flow.py +++ b/tests/components/fritzbox/test_config_flow.py @@ -61,7 +61,7 @@ async def test_user_auth_failed(hass: HomeAssistantType, fritz: Mock): ) assert result["type"] == "form" assert result["step_id"] == "user" - assert result["errors"]["base"] == "auth_failed" + assert result["errors"]["base"] == "invalid_auth" async def test_user_not_successful(hass: HomeAssistantType, fritz: Mock): @@ -72,7 +72,7 @@ async def test_user_not_successful(hass: HomeAssistantType, fritz: Mock): DOMAIN, context={"source": "user"}, data=MOCK_USER_DATA ) assert result["type"] == "abort" - assert result["reason"] == "not_found" + assert result["reason"] == "no_devices_found" async def test_user_already_configured(hass: HomeAssistantType, fritz: Mock): @@ -162,7 +162,7 @@ async def test_ssdp_auth_failed(hass: HomeAssistantType, fritz: Mock): ) assert result["type"] == "form" assert result["step_id"] == "confirm" - assert result["errors"]["base"] == "auth_failed" + assert result["errors"]["base"] == "invalid_auth" async def test_ssdp_not_successful(hass: HomeAssistantType, fritz: Mock): @@ -180,7 +180,7 @@ async def test_ssdp_not_successful(hass: HomeAssistantType, fritz: Mock): user_input={CONF_PASSWORD: "whatever", CONF_USERNAME: "whatever"}, ) assert result["type"] == "abort" - assert result["reason"] == "not_found" + assert result["reason"] == "no_devices_found" async def test_ssdp_not_supported(hass: HomeAssistantType, fritz: Mock):