Update to iaqualink 0.4.1 (#53745)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
5824477298
commit
3c2d5d5f8c
14 changed files with 580 additions and 65 deletions
|
@ -3,7 +3,11 @@ from __future__ import annotations
|
|||
|
||||
from typing import Any
|
||||
|
||||
from iaqualink import AqualinkClient, AqualinkLoginException
|
||||
from iaqualink.client import AqualinkClient
|
||||
from iaqualink.exception import (
|
||||
AqualinkServiceException,
|
||||
AqualinkServiceUnauthorizedException,
|
||||
)
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
|
@ -32,16 +36,22 @@ class AqualinkFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
password = user_input[CONF_PASSWORD]
|
||||
|
||||
try:
|
||||
aqualink = AqualinkClient(username, password)
|
||||
await aqualink.login()
|
||||
return self.async_create_entry(title=username, data=user_input)
|
||||
except AqualinkLoginException:
|
||||
async with AqualinkClient(username, password):
|
||||
pass
|
||||
except AqualinkServiceUnauthorizedException:
|
||||
errors["base"] = "invalid_auth"
|
||||
except AqualinkServiceException:
|
||||
errors["base"] = "cannot_connect"
|
||||
else:
|
||||
return self.async_create_entry(title=username, data=user_input)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=vol.Schema(
|
||||
{vol.Required(CONF_USERNAME): str, vol.Required(CONF_PASSWORD): str}
|
||||
{
|
||||
vol.Required(CONF_USERNAME): str,
|
||||
vol.Required(CONF_PASSWORD): str,
|
||||
}
|
||||
),
|
||||
errors=errors,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue