mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Use reauth helpers in dormakaba_dkey config flow (#127446)
This commit is contained in:
parent
464da23d4e
commit
07bc9f6477
@ -15,12 +15,7 @@ from homeassistant.components.bluetooth import (
|
|||||||
async_discovered_service_info,
|
async_discovered_service_info,
|
||||||
async_last_service_info,
|
async_last_service_info,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
|
||||||
SOURCE_REAUTH,
|
|
||||||
ConfigEntry,
|
|
||||||
ConfigFlow,
|
|
||||||
ConfigFlowResult,
|
|
||||||
)
|
|
||||||
from homeassistant.const import CONF_ADDRESS
|
from homeassistant.const import CONF_ADDRESS
|
||||||
|
|
||||||
from .const import CONF_ASSOCIATION_DATA, DOMAIN
|
from .const import CONF_ASSOCIATION_DATA, DOMAIN
|
||||||
@ -39,8 +34,6 @@ class DormkabaConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
|
|
||||||
VERSION = 1
|
VERSION = 1
|
||||||
|
|
||||||
_reauth_entry: ConfigEntry
|
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""Initialize the config flow."""
|
"""Initialize the config flow."""
|
||||||
self._lock: DKEYLock | None = None
|
self._lock: DKEYLock | None = None
|
||||||
@ -126,7 +119,6 @@ class DormkabaConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle reauthorization request."""
|
"""Handle reauthorization request."""
|
||||||
self._reauth_entry = self._get_reauth_entry()
|
|
||||||
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(
|
||||||
@ -138,7 +130,7 @@ class DormkabaConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
if user_input is not None:
|
if user_input is not None:
|
||||||
if (
|
if (
|
||||||
discovery_info := async_last_service_info(
|
discovery_info := async_last_service_info(
|
||||||
self.hass, self._reauth_entry.data[CONF_ADDRESS], True
|
self.hass, self._get_reauth_entry().data[CONF_ADDRESS], True
|
||||||
)
|
)
|
||||||
) is None:
|
) is None:
|
||||||
errors = {"base": "no_longer_in_range"}
|
errors = {"base": "no_longer_in_range"}
|
||||||
@ -185,11 +177,9 @@ class DormkabaConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
CONF_ASSOCIATION_DATA: association_data.to_json(),
|
CONF_ASSOCIATION_DATA: association_data.to_json(),
|
||||||
}
|
}
|
||||||
if self.source == SOURCE_REAUTH:
|
if self.source == SOURCE_REAUTH:
|
||||||
self.hass.config_entries.async_update_entry(
|
return self.async_update_reload_and_abort(
|
||||||
self._reauth_entry, data=data
|
self._get_reauth_entry(), data=data
|
||||||
)
|
)
|
||||||
await self.hass.config_entries.async_reload(self._reauth_entry.entry_id)
|
|
||||||
return self.async_abort(reason="reauth_successful")
|
|
||||||
|
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title=lock.device_info.device_name
|
title=lock.device_info.device_name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user