mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Use new reauth helpers in whirlpool (#128825)
This commit is contained in:
parent
0ede15dcbf
commit
87c9c0c3b1
@ -12,7 +12,7 @@ from whirlpool.appliancesmanager import AppliancesManager
|
||||
from whirlpool.auth import Auth
|
||||
from whirlpool.backendselector import BackendSelector
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_REGION, CONF_USERNAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
@ -71,14 +71,11 @@ class WhirlpoolConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a config flow for Whirlpool Sixth Sense."""
|
||||
|
||||
VERSION = 1
|
||||
entry: ConfigEntry | None
|
||||
|
||||
async def async_step_reauth(
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle re-authentication with Whirlpool Sixth Sense."""
|
||||
|
||||
self.entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
||||
return await self.async_step_reauth_confirm()
|
||||
|
||||
async def async_step_reauth_confirm(
|
||||
@ -88,10 +85,10 @@ class WhirlpoolConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
errors: dict[str, str] = {}
|
||||
|
||||
if user_input:
|
||||
assert self.entry is not None
|
||||
reauth_entry = self._get_reauth_entry()
|
||||
password = user_input[CONF_PASSWORD]
|
||||
brand = user_input[CONF_BRAND]
|
||||
data = {**self.entry.data, CONF_PASSWORD: password, CONF_BRAND: brand}
|
||||
data = {**reauth_entry.data, CONF_PASSWORD: password, CONF_BRAND: brand}
|
||||
|
||||
try:
|
||||
await validate_input(self.hass, data)
|
||||
@ -100,9 +97,7 @@ class WhirlpoolConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
except (CannotConnect, TimeoutError):
|
||||
errors["base"] = "cannot_connect"
|
||||
else:
|
||||
self.hass.config_entries.async_update_entry(self.entry, data=data)
|
||||
await self.hass.config_entries.async_reload(self.entry.entry_id)
|
||||
return self.async_abort(reason="reauth_successful")
|
||||
return self.async_update_reload_and_abort(reauth_entry, data=data)
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="reauth_confirm",
|
||||
|
Loading…
x
Reference in New Issue
Block a user