only get accounts data in config flow + failure translation
This commit is contained in:
@@ -7,14 +7,14 @@ from homeassistant import config_entries
|
||||
from homeassistant.helpers.aiohttp_client import async_create_clientsession
|
||||
from homeassistant.core import callback
|
||||
|
||||
from .fplapi import FplApi
|
||||
|
||||
from .const import DOMAIN, CONF_USERNAME, CONF_PASSWORD, CONF_NAME
|
||||
|
||||
from .fplapi import (
|
||||
LOGIN_RESULT_OK,
|
||||
LOGIN_RESULT_FAILURE,
|
||||
LOGIN_RESULT_INVALIDUSER,
|
||||
LOGIN_RESULT_INVALIDPASSWORD,
|
||||
FplApi,
|
||||
)
|
||||
|
||||
|
||||
@@ -59,8 +59,9 @@ class FplFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
result = await api.login()
|
||||
|
||||
if result == LOGIN_RESULT_OK:
|
||||
fplData = await api.async_get_data()
|
||||
accounts = fplData["accounts"]
|
||||
|
||||
accounts = await api.async_get_open_accounts()
|
||||
await api.logout()
|
||||
|
||||
user_input["accounts"] = accounts
|
||||
|
||||
@@ -72,8 +73,8 @@ class FplFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
if result == LOGIN_RESULT_INVALIDPASSWORD:
|
||||
self._errors[CONF_PASSWORD] = "invalid_password"
|
||||
|
||||
if result is None:
|
||||
self._errors["base"] = "auth"
|
||||
if result == LOGIN_RESULT_FAILURE:
|
||||
self._errors["base"] = "failure"
|
||||
|
||||
else:
|
||||
self._errors[CONF_NAME] = "name_exists"
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
}
|
||||
},
|
||||
"error": {
|
||||
"failure": "An error ocurred, please check the logs",
|
||||
"auth": "Username/Password is wrong.",
|
||||
"name_exists": "Configuration already exists.",
|
||||
"invalid_username": "Invalid Email",
|
||||
|
||||
Reference in New Issue
Block a user