diff --git a/homeassistant/components/roborock/config_flow.py b/homeassistant/components/roborock/config_flow.py index 2b409bdf8c4..c6dee7ce4ed 100644 --- a/homeassistant/components/roborock/config_flow.py +++ b/homeassistant/components/roborock/config_flow.py @@ -12,6 +12,7 @@ from roborock.exceptions import ( RoborockException, RoborockInvalidCode, RoborockInvalidEmail, + RoborockTooFrequentCodeRequests, RoborockUrlException, ) from roborock.web_api import RoborockApiClient @@ -83,6 +84,8 @@ class RoborockFlowHandler(ConfigFlow, domain=DOMAIN): errors["base"] = "unknown_url" except RoborockInvalidEmail: errors["base"] = "invalid_email_format" + except RoborockTooFrequentCodeRequests: + errors["base"] = "too_frequent_code_requests" except RoborockException: _LOGGER.exception("Unexpected exception") errors["base"] = "unknown_roborock" diff --git a/homeassistant/components/roborock/strings.json b/homeassistant/components/roborock/strings.json index 081e4c68a75..d1fc50f27e8 100644 --- a/homeassistant/components/roborock/strings.json +++ b/homeassistant/components/roborock/strings.json @@ -22,6 +22,7 @@ "invalid_code": "The code you entered was incorrect, please check it and try again.", "invalid_email": "There is no account associated with the email you entered, please try again.", "invalid_email_format": "There is an issue with the formatting of your email - please try again.", + "too_frequent_code_requests": "You have attempted to request too many codes. Try again later.", "unknown_roborock": "There was an unknown roborock exception - please check your logs.", "unknown_url": "There was an issue determining the correct url for your roborock account - please check your logs.", "unknown": "[%key:common::config_flow::error::unknown%]" diff --git a/tests/components/roborock/test_config_flow.py b/tests/components/roborock/test_config_flow.py index a5a86e44372..39d8117847c 100644 --- a/tests/components/roborock/test_config_flow.py +++ b/tests/components/roborock/test_config_flow.py @@ -4,6 +4,7 @@ from copy import deepcopy from unittest.mock import patch import pytest +from roborock import RoborockTooFrequentCodeRequests from roborock.exceptions import ( RoborockAccountDoesNotExist, RoborockException, @@ -71,6 +72,7 @@ async def test_config_flow_success( (RoborockException(), {"base": "unknown_roborock"}), (RoborockAccountDoesNotExist(), {"base": "invalid_email"}), (RoborockInvalidEmail(), {"base": "invalid_email_format"}), + (RoborockTooFrequentCodeRequests(), {"base": "too_frequent_code_requests"}), (RoborockUrlException(), {"base": "unknown_url"}), (Exception(), {"base": "unknown"}), ],