Improve Config Flow and handle TooManyAttemptsBannedException in Overkiz (#68868)
parent
9a150c2234
commit
365ea59b64
|
@ -9,6 +9,7 @@ from pyoverkiz.const import SUPPORTED_SERVERS
|
||||||
from pyoverkiz.exceptions import (
|
from pyoverkiz.exceptions import (
|
||||||
BadCredentialsException,
|
BadCredentialsException,
|
||||||
MaintenanceException,
|
MaintenanceException,
|
||||||
|
TooManyAttemptsBannedException,
|
||||||
TooManyRequestsException,
|
TooManyRequestsException,
|
||||||
)
|
)
|
||||||
from pyoverkiz.models import obfuscate_id
|
from pyoverkiz.models import obfuscate_id
|
||||||
|
@ -51,7 +52,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
async with OverkizClient(
|
async with OverkizClient(
|
||||||
username=username, password=password, server=server, session=session
|
username=username, password=password, server=server, session=session
|
||||||
) as client:
|
) as client:
|
||||||
await client.login()
|
await client.login(register_event_listener=False)
|
||||||
|
|
||||||
# Set first gateway id as unique id
|
# Set first gateway id as unique id
|
||||||
if gateways := await client.get_gateways():
|
if gateways := await client.get_gateways():
|
||||||
|
@ -78,6 +79,8 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||||
errors["base"] = "cannot_connect"
|
errors["base"] = "cannot_connect"
|
||||||
except MaintenanceException:
|
except MaintenanceException:
|
||||||
errors["base"] = "server_in_maintenance"
|
errors["base"] = "server_in_maintenance"
|
||||||
|
except TooManyAttemptsBannedException:
|
||||||
|
errors["base"] = "too_many_attempts"
|
||||||
except Exception as exception: # pylint: disable=broad-except
|
except Exception as exception: # pylint: disable=broad-except
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
LOGGER.exception(exception)
|
LOGGER.exception(exception)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/overkiz",
|
"documentation": "https://www.home-assistant.io/integrations/overkiz",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"pyoverkiz==1.3.12"
|
"pyoverkiz==1.3.13"
|
||||||
],
|
],
|
||||||
"zeroconf": [
|
"zeroconf": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||||
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
||||||
"server_in_maintenance": "Server is down for maintenance",
|
"server_in_maintenance": "Server is down for maintenance",
|
||||||
|
"too_many_attempts": "Too many attempts with an invalid token, temporarily banned",
|
||||||
"too_many_requests": "Too many requests, try again later",
|
"too_many_requests": "Too many requests, try again later",
|
||||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||||
},
|
},
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
"cannot_connect": "Failed to connect",
|
"cannot_connect": "Failed to connect",
|
||||||
"invalid_auth": "Invalid authentication",
|
"invalid_auth": "Invalid authentication",
|
||||||
"server_in_maintenance": "Server is down for maintenance",
|
"server_in_maintenance": "Server is down for maintenance",
|
||||||
|
"too_many_attempts": "Too many attempts with an invalid token, temporarily banned",
|
||||||
"too_many_requests": "Too many requests, try again later",
|
"too_many_requests": "Too many requests, try again later",
|
||||||
"unknown": "Unexpected error"
|
"unknown": "Unexpected error"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1700,7 +1700,7 @@ pyotgw==1.1b1
|
||||||
pyotp==2.6.0
|
pyotp==2.6.0
|
||||||
|
|
||||||
# homeassistant.components.overkiz
|
# homeassistant.components.overkiz
|
||||||
pyoverkiz==1.3.12
|
pyoverkiz==1.3.13
|
||||||
|
|
||||||
# homeassistant.components.openweathermap
|
# homeassistant.components.openweathermap
|
||||||
pyowm==3.2.0
|
pyowm==3.2.0
|
||||||
|
|
|
@ -1135,7 +1135,7 @@ pyotgw==1.1b1
|
||||||
pyotp==2.6.0
|
pyotp==2.6.0
|
||||||
|
|
||||||
# homeassistant.components.overkiz
|
# homeassistant.components.overkiz
|
||||||
pyoverkiz==1.3.12
|
pyoverkiz==1.3.13
|
||||||
|
|
||||||
# homeassistant.components.openweathermap
|
# homeassistant.components.openweathermap
|
||||||
pyowm==3.2.0
|
pyowm==3.2.0
|
||||||
|
|
|
@ -7,6 +7,7 @@ from aiohttp import ClientError
|
||||||
from pyoverkiz.exceptions import (
|
from pyoverkiz.exceptions import (
|
||||||
BadCredentialsException,
|
BadCredentialsException,
|
||||||
MaintenanceException,
|
MaintenanceException,
|
||||||
|
TooManyAttemptsBannedException,
|
||||||
TooManyRequestsException,
|
TooManyRequestsException,
|
||||||
)
|
)
|
||||||
import pytest
|
import pytest
|
||||||
|
@ -86,6 +87,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
||||||
(TimeoutError, "cannot_connect"),
|
(TimeoutError, "cannot_connect"),
|
||||||
(ClientError, "cannot_connect"),
|
(ClientError, "cannot_connect"),
|
||||||
(MaintenanceException, "server_in_maintenance"),
|
(MaintenanceException, "server_in_maintenance"),
|
||||||
|
(TooManyAttemptsBannedException, "too_many_attempts"),
|
||||||
(Exception, "unknown"),
|
(Exception, "unknown"),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue