Use new reauth helpers in xiaomi_ble (#128827)
parent
5f662988ff
commit
d9c61a37bb
|
@ -17,7 +17,7 @@ from homeassistant.components.bluetooth import (
|
||||||
async_discovered_service_info,
|
async_discovered_service_info,
|
||||||
async_process_advertisements,
|
async_process_advertisements,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
|
from homeassistant.config_entries import SOURCE_REAUTH, ConfigFlow, ConfigFlowResult
|
||||||
from homeassistant.const import CONF_ADDRESS
|
from homeassistant.const import CONF_ADDRESS
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
@ -264,9 +264,6 @@ class XiaomiConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
self, entry_data: Mapping[str, Any]
|
self, entry_data: Mapping[str, Any]
|
||||||
) -> ConfigFlowResult:
|
) -> ConfigFlowResult:
|
||||||
"""Handle a flow initialized by a reauth event."""
|
"""Handle a flow initialized by a reauth event."""
|
||||||
entry = self.hass.config_entries.async_get_entry(self.context["entry_id"])
|
|
||||||
assert entry is not None
|
|
||||||
|
|
||||||
device: DeviceData = entry_data["device"]
|
device: DeviceData = entry_data["device"]
|
||||||
self._discovered_device = device
|
self._discovered_device = device
|
||||||
|
|
||||||
|
@ -289,10 +286,10 @@ class XiaomiConfigFlow(ConfigFlow, domain=DOMAIN):
|
||||||
if bindkey:
|
if bindkey:
|
||||||
data["bindkey"] = bindkey
|
data["bindkey"] = bindkey
|
||||||
|
|
||||||
if entry_id := self.context.get("entry_id"):
|
if self.source == SOURCE_REAUTH:
|
||||||
entry = self.hass.config_entries.async_get_entry(entry_id)
|
return self.async_update_reload_and_abort(
|
||||||
assert entry is not None
|
self._get_reauth_entry(), data=data
|
||||||
return self.async_update_reload_and_abort(entry, data=data)
|
)
|
||||||
|
|
||||||
return self.async_create_entry(
|
return self.async_create_entry(
|
||||||
title=self.context["title_placeholders"]["name"],
|
title=self.context["title_placeholders"]["name"],
|
||||||
|
|
Loading…
Reference in New Issue