Use reauth helpers in ista_ecotrend (#128647)
This commit is contained in:
parent
7a77a3d7ce
commit
42e6ac4f6d
1 changed files with 5 additions and 14 deletions
|
@ -17,7 +17,6 @@ from homeassistant.helpers.selector import (
|
||||||
TextSelectorType,
|
TextSelectorType,
|
||||||
)
|
)
|
||||||
|
|
||||||
from . import IstaConfigEntry
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
@ -43,8 +42,6 @@ STEP_USER_DATA_SCHEMA = vol.Schema(
|
||||||
class IstaConfigFlow(ConfigFlow, domain=DOMAIN):
|
class IstaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
"""Handle a config flow for ista EcoTrend."""
|
"""Handle a config flow for ista EcoTrend."""
|
||||||
|
|
||||||
reauth_entry: IstaConfigEntry | None = None
|
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
|
@ -88,9 +85,6 @@ class IstaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Perform reauth upon an API authentication error."""
|
"""Perform reauth upon an API authentication error."""
|
||||||
self.reauth_entry = self.hass.config_entries.async_get_entry(
|
|
||||||
self.context["entry_id"]
|
|
||||||
)
|
|
||||||
return await self.async_step_reauth_confirm()
|
return await self.async_step_reauth_confirm()
|
||||||
|
|
||||||
async def async_step_reauth_confirm(
|
async def async_step_reauth_confirm(
|
||||||
|
@ -98,9 +92,8 @@ class IstaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Dialog that informs the user that reauth is required."""
|
"""Dialog that informs the user that reauth is required."""
|
||||||
errors: dict[str, str] = {}
|
errors: dict[str, str] = {}
|
||||||
if TYPE_CHECKING:
|
|
||||||
assert self.reauth_entry
|
|
||||||
|
|
||||||
|
reauth_entry = self._get_reauth_entry()
|
||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
ista = PyEcotrendIsta(
|
ista = PyEcotrendIsta(
|
||||||
user_input[CONF_EMAIL],
|
user_input[CONF_EMAIL],
|
||||||
|
@ -117,9 +110,7 @@ class IstaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
_LOGGER.exception("Unexpected exception")
|
_LOGGER.exception("Unexpected exception")
|
||||||
errors["base"] = "unknown"
|
errors["base"] = "unknown"
|
||||||
else:
|
else:
|
||||||
return self.async_update_reload_and_abort(
|
return self.async_update_reload_and_abort(reauth_entry, data=user_input)
|
||||||
self.reauth_entry, data=user_input
|
|
||||||
)
|
|
||||||
|
|
||||||
return self.async_show_form(
|
return self.async_show_form(
|
||||||
step_id="reauth_confirm",
|
step_id="reauth_confirm",
|
||||||
|
@ -128,12 +119,12 @@ class IstaConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
suggested_values={
|
suggested_values={
|
||||||
CONF_EMAIL: user_input[CONF_EMAIL]
|
CONF_EMAIL: user_input[CONF_EMAIL]
|
||||||
if user_input is not None
|
if user_input is not None
|
||||||
else self.reauth_entry.data[CONF_EMAIL]
|
else reauth_entry.data[CONF_EMAIL]
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
description_placeholders={
|
description_placeholders={
|
||||||
CONF_NAME: self.reauth_entry.title,
|
CONF_NAME: reauth_entry.title,
|
||||||
CONF_EMAIL: self.reauth_entry.data[CONF_EMAIL],
|
CONF_EMAIL: reauth_entry.data[CONF_EMAIL],
|
||||||
},
|
},
|
||||||
errors=errors,
|
errors=errors,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue