diff --git a/homeassistant/components/overkiz/config_flow.py b/homeassistant/components/overkiz/config_flow.py index 71e5a3691eb0..4c86d4055312 100644 --- a/homeassistant/components/overkiz/config_flow.py +++ b/homeassistant/components/overkiz/config_flow.py @@ -25,6 +25,7 @@ from pyoverkiz.exceptions import ( MaintenanceError, NoSuchTokenError, NotAuthenticatedError, + ServiceUnavailableError, TooManyAttemptsBannedError, TooManyRequestsError, UnknownUserError, @@ -169,7 +170,12 @@ class OverkizConfigFlow( data_schema=probatio.Schema( { probatio.Required(CONF_HUB, default=self._server): probatio.In( - {key: hub.name for key, hub in SUPPORTED_SERVERS.items()} + { + key: hub.name + for key, hub in SUPPORTED_SERVERS.items() + # Needs multi-account site selection, not supported yet + if key != Server.SOMFY + } ), } ), @@ -248,10 +254,10 @@ class OverkizConfigFlow( errors["base"] = "unsupported_hardware" else: errors["base"] = "invalid_auth" - except TimeoutError, ClientError: - errors["base"] = "cannot_connect" except MaintenanceError: errors["base"] = "server_in_maintenance" + except TimeoutError, ClientError, ServiceUnavailableError: + errors["base"] = "cannot_connect" except TooManyAttemptsBannedError: errors["base"] = "too_many_attempts" except UnknownUserError: @@ -325,11 +331,11 @@ class OverkizConfigFlow( except ClientConnectorCertificateError as exception: errors["base"] = "certificate_verify_failed" LOGGER.debug(exception) - except (TimeoutError, ClientError) as exception: - errors["base"] = "cannot_connect" - LOGGER.debug(exception) except MaintenanceError: errors["base"] = "server_in_maintenance" + except (TimeoutError, ClientError, ServiceUnavailableError) as exception: + errors["base"] = "cannot_connect" + LOGGER.debug(exception) except TooManyAttemptsBannedError: errors["base"] = "too_many_attempts" except UnknownUserError: diff --git a/homeassistant/components/overkiz/manifest.json b/homeassistant/components/overkiz/manifest.json index f47b2d0a74a3..d281fe4415af 100644 --- a/homeassistant/components/overkiz/manifest.json +++ b/homeassistant/components/overkiz/manifest.json @@ -14,7 +14,7 @@ "integration_type": "hub", "iot_class": "local_polling", "loggers": ["boto3", "botocore", "pyoverkiz", "s3transfer"], - "requirements": ["pyoverkiz[nexity]==2.1.2"], + "requirements": ["pyoverkiz[nexity]==2.2.2"], "zeroconf": [ { "name": "gateway*", diff --git a/requirements_all.txt b/requirements_all.txt index ec27c76447a2..7533d6e1181e 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2508,7 +2508,7 @@ pyotgw==2.2.3 pyotp==2.10.0 # homeassistant.components.overkiz -pyoverkiz[nexity]==2.1.2 +pyoverkiz[nexity]==2.2.2 # homeassistant.components.palazzetti pypalazzetti==0.1.20 diff --git a/tests/components/overkiz/test_config_flow.py b/tests/components/overkiz/test_config_flow.py index 0b0722eb7f3d..c6e9a77d8809 100644 --- a/tests/components/overkiz/test_config_flow.py +++ b/tests/components/overkiz/test_config_flow.py @@ -18,6 +18,7 @@ from pyoverkiz.exceptions import ( BadCredentialsError, MaintenanceError, NoSuchTokenError, + ServiceUnavailableError, TooManyAttemptsBannedError, TooManyRequestsError, UnknownUserError, @@ -31,7 +32,7 @@ from homeassistant.components.application_credentials import ( ) from homeassistant.components.overkiz.const import DOMAIN from homeassistant.core import HomeAssistant -from homeassistant.data_entry_flow import FlowResultType +from homeassistant.data_entry_flow import FlowResultType, InvalidData from homeassistant.helpers import config_entry_oauth2_flow from homeassistant.helpers.service_info.dhcp import DhcpServiceInfo from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo @@ -148,6 +149,19 @@ async def test_form_cloud(hass: HomeAssistant, mock_setup_entry: AsyncMock) -> N assert len(mock_setup_entry.mock_calls) == 1 +async def test_form_somfy_multi_account_hidden(hass: HomeAssistant) -> None: + """Test the experimental Somfy multi-account server cannot be selected.""" + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": config_entries.SOURCE_USER} + ) + + with pytest.raises(InvalidData): + await hass.config_entries.flow.async_configure( + result["flow_id"], + {"hub": "somfy"}, + ) + + async def test_form_only_cloud_supported( hass: HomeAssistant, mock_setup_entry: AsyncMock ) -> None: @@ -249,6 +263,7 @@ async def test_form_local_happy_flow( (TimeoutError, "cannot_connect"), (ClientError, "cannot_connect"), (MaintenanceError, "server_in_maintenance"), + (ServiceUnavailableError, "cannot_connect"), (TooManyAttemptsBannedError, "too_many_attempts"), (UnknownUserError, "unsupported_hardware"), (ApplicationNotAllowedError, "application_not_allowed"), @@ -425,6 +440,7 @@ async def test_form_invalid_hardware_cloud_local( (TimeoutError, "cannot_connect"), (ClientError, "cannot_connect"), (MaintenanceError, "server_in_maintenance"), + (ServiceUnavailableError, "cannot_connect"), (TooManyAttemptsBannedError, "too_many_attempts"), (UnknownUserError, "unsupported_hardware"), (NoSuchTokenError, "invalid_auth"),