Use new reauth helpers in tplink (#128768)

This commit is contained in:
epenet 2024-10-19 14:25:53 +02:00 committed by GitHub
parent 85899a59c0
commit 7fc4a65868
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -69,7 +69,6 @@ class TPLinkConfigFlow(ConfigFlow, domain=DOMAIN):
MINOR_VERSION = CONF_CONFIG_ENTRY_MINOR_VERSION MINOR_VERSION = CONF_CONFIG_ENTRY_MINOR_VERSION
host: str | None = None host: str | None = None
reauth_entry: ConfigEntry | None = None
def __init__(self) -> None: def __init__(self) -> None:
"""Initialize the config flow.""" """Initialize the config flow."""
@ -372,8 +371,8 @@ class TPLinkConfigFlow(ConfigFlow, domain=DOMAIN):
"""Reload any in progress config flow that now have credentials.""" """Reload any in progress config flow that now have credentials."""
_config_entries = self.hass.config_entries _config_entries = self.hass.config_entries
if reauth_entry := self.reauth_entry: if self.source == SOURCE_REAUTH:
await _config_entries.async_reload(reauth_entry.entry_id) await _config_entries.async_reload(self._get_reauth_entry().entry_id)
for flow in _config_entries.flow.async_progress_by_handler( for flow in _config_entries.flow.async_progress_by_handler(
DOMAIN, include_uninitialized=True DOMAIN, include_uninitialized=True
@ -473,9 +472,6 @@ class TPLinkConfigFlow(ConfigFlow, domain=DOMAIN):
self, entry_data: Mapping[str, Any] self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult: ) -> ConfigFlowResult:
"""Start the reauthentication flow if the device needs updated credentials.""" """Start the reauthentication flow if the device needs updated credentials."""
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(
@ -484,8 +480,7 @@ class TPLinkConfigFlow(ConfigFlow, domain=DOMAIN):
"""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] = {}
placeholders: dict[str, str] = {} placeholders: dict[str, str] = {}
reauth_entry = self.reauth_entry reauth_entry = self._get_reauth_entry()
assert reauth_entry is not None
entry_data = reauth_entry.data entry_data = reauth_entry.data
host = entry_data[CONF_HOST] host = entry_data[CONF_HOST]