Use new reauth helpers in purpleair (#128719)

This commit is contained in:
epenet 2024-10-19 10:37:01 +02:00 committed by GitHub
parent 088cfed794
commit 004b323fd4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -202,7 +202,6 @@ class PurpleAirConfigFlow(ConfigFlow, domain=DOMAIN):
def __init__(self) -> None: def __init__(self) -> None:
"""Initialize.""" """Initialize."""
self._flow_data: dict[str, Any] = {} self._flow_data: dict[str, Any] = {}
self._reauth_entry: ConfigEntry | None = None
@staticmethod @staticmethod
@callback @callback
@ -265,9 +264,6 @@ class PurpleAirConfigFlow(ConfigFlow, domain=DOMAIN):
self, entry_data: Mapping[str, Any] self, entry_data: Mapping[str, Any]
) -> ConfigFlowResult: ) -> ConfigFlowResult:
"""Handle configuration by re-auth.""" """Handle configuration by re-auth."""
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(
@ -289,15 +285,9 @@ class PurpleAirConfigFlow(ConfigFlow, domain=DOMAIN):
errors=validation.errors, errors=validation.errors,
) )
assert self._reauth_entry return self.async_update_reload_and_abort(
self._get_reauth_entry(), data={CONF_API_KEY: api_key}
self.hass.config_entries.async_update_entry(
self._reauth_entry, data={CONF_API_KEY: api_key}
) )
self.hass.async_create_task(
self.hass.config_entries.async_reload(self._reauth_entry.entry_id)
)
return self.async_abort(reason="reauth_successful")
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