Use async_start_reauth in blink (#129281)

This commit is contained in:
G Johansson 2024-10-28 07:57:18 +01:00 committed by GitHub
parent 9bf0cbd659
commit 87f2a4242e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,7 +10,6 @@ from blinkpy.blinkpy import Blink
import voluptuous as vol
from homeassistant.components import persistent_notification
from homeassistant.config_entries import SOURCE_REAUTH
from homeassistant.const import (
CONF_FILE_PATH,
CONF_FILENAME,
@ -41,13 +40,11 @@ SERVICE_SAVE_RECENT_CLIPS_SCHEMA = vol.Schema(
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
async def _reauth_flow_wrapper(hass: HomeAssistant, data: dict[str, Any]) -> None:
async def _reauth_flow_wrapper(
hass: HomeAssistant, entry: BlinkConfigEntry, data: dict[str, Any]
) -> None:
"""Reauth flow wrapper."""
hass.add_job(
hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_REAUTH}, data=data
)
)
entry.async_start_reauth(hass, data=data)
persistent_notification.async_create(
hass,
(
@ -64,10 +61,10 @@ async def async_migrate_entry(hass: HomeAssistant, entry: BlinkConfigEntry) -> b
data = {**entry.data}
if entry.version == 1:
data.pop("login_response", None)
await _reauth_flow_wrapper(hass, data)
await _reauth_flow_wrapper(hass, entry, data)
return False
if entry.version == 2:
await _reauth_flow_wrapper(hass, data)
await _reauth_flow_wrapper(hass, entry, data)
return False
return True