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 (
|
||||
BadCredentialsException,
|
||||
MaintenanceException,
|
||||
TooManyAttemptsBannedException,
|
||||
TooManyRequestsException,
|
||||
)
|
||||
from pyoverkiz.models import obfuscate_id
|
||||
|
@ -51,7 +52,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
async with OverkizClient(
|
||||
username=username, password=password, server=server, session=session
|
||||
) as client:
|
||||
await client.login()
|
||||
await client.login(register_event_listener=False)
|
||||
|
||||
# Set first gateway id as unique id
|
||||
if gateways := await client.get_gateways():
|
||||
|
@ -78,6 +79,8 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
errors["base"] = "cannot_connect"
|
||||
except MaintenanceException:
|
||||
errors["base"] = "server_in_maintenance"
|
||||
except TooManyAttemptsBannedException:
|
||||
errors["base"] = "too_many_attempts"
|
||||
except Exception as exception: # pylint: disable=broad-except
|
||||
errors["base"] = "unknown"
|
||||
LOGGER.exception(exception)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/overkiz",
|
||||
"requirements": [
|
||||
"pyoverkiz==1.3.12"
|
||||
"pyoverkiz==1.3.13"
|
||||
],
|
||||
"zeroconf": [
|
||||
{
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
|
||||
"invalid_auth": "[%key:common::config_flow::error::invalid_auth%]",
|
||||
"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",
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||
},
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
"cannot_connect": "Failed to connect",
|
||||
"invalid_auth": "Invalid authentication",
|
||||
"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",
|
||||
"unknown": "Unexpected error"
|
||||
},
|
||||
|
|
|
@ -1700,7 +1700,7 @@ pyotgw==1.1b1
|
|||
pyotp==2.6.0
|
||||
|
||||
# homeassistant.components.overkiz
|
||||
pyoverkiz==1.3.12
|
||||
pyoverkiz==1.3.13
|
||||
|
||||
# homeassistant.components.openweathermap
|
||||
pyowm==3.2.0
|
||||
|
|
|
@ -1135,7 +1135,7 @@ pyotgw==1.1b1
|
|||
pyotp==2.6.0
|
||||
|
||||
# homeassistant.components.overkiz
|
||||
pyoverkiz==1.3.12
|
||||
pyoverkiz==1.3.13
|
||||
|
||||
# homeassistant.components.openweathermap
|
||||
pyowm==3.2.0
|
||||
|
|
|
@ -7,6 +7,7 @@ from aiohttp import ClientError
|
|||
from pyoverkiz.exceptions import (
|
||||
BadCredentialsException,
|
||||
MaintenanceException,
|
||||
TooManyAttemptsBannedException,
|
||||
TooManyRequestsException,
|
||||
)
|
||||
import pytest
|
||||
|
@ -86,6 +87,7 @@ async def test_form(hass: HomeAssistant) -> None:
|
|||
(TimeoutError, "cannot_connect"),
|
||||
(ClientError, "cannot_connect"),
|
||||
(MaintenanceException, "server_in_maintenance"),
|
||||
(TooManyAttemptsBannedException, "too_many_attempts"),
|
||||
(Exception, "unknown"),
|
||||
],
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue