mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Use new reauth helpers in rympro (#128728)
This commit is contained in:
parent
9622a11b2e
commit
0581d614f6
@ -9,7 +9,7 @@ from typing import Any
|
||||
from pyrympro import CannotConnectError, RymPro, UnauthorizedError
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
|
||||
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, CONF_TOKEN, CONF_UNIQUE_ID
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
@ -46,10 +46,6 @@ class RymproConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
|
||||
VERSION = 1
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Init the config flow."""
|
||||
self._reauth_entry: ConfigEntry | None = None
|
||||
|
||||
async def async_step_user(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> ConfigFlowResult:
|
||||
@ -74,19 +70,17 @@ class RymproConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
title = user_input[CONF_EMAIL]
|
||||
data = {**user_input, **info}
|
||||
|
||||
if not self._reauth_entry:
|
||||
if self.source != SOURCE_REAUTH:
|
||||
await self.async_set_unique_id(info[CONF_UNIQUE_ID])
|
||||
self._abort_if_unique_id_configured()
|
||||
return self.async_create_entry(title=title, data=data)
|
||||
|
||||
self.hass.config_entries.async_update_entry(
|
||||
self._reauth_entry,
|
||||
return self.async_update_reload_and_abort(
|
||||
self._get_reauth_entry(),
|
||||
title=title,
|
||||
data=data,
|
||||
unique_id=info[CONF_UNIQUE_ID],
|
||||
)
|
||||
await self.hass.config_entries.async_reload(self._reauth_entry.entry_id)
|
||||
return self.async_abort(reason="reauth_successful")
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors
|
||||
@ -96,7 +90,4 @@ class RymproConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||
self, entry_data: Mapping[str, Any]
|
||||
) -> ConfigFlowResult:
|
||||
"""Handle configuration by re-auth."""
|
||||
self._reauth_entry = self.hass.config_entries.async_get_entry(
|
||||
self.context["entry_id"]
|
||||
)
|
||||
return await self.async_step_user()
|
||||
|
Loading…
x
Reference in New Issue
Block a user