From d9c61a37bb98413dc283bd999bcc9ab3fdfbcf13 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Sun, 20 Oct 2024 10:01:18 +0200 Subject: [PATCH] Use new reauth helpers in xiaomi_ble (#128827) --- homeassistant/components/xiaomi_ble/config_flow.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/xiaomi_ble/config_flow.py b/homeassistant/components/xiaomi_ble/config_flow.py index 8209c9565bd..7a24763c011 100644 --- a/homeassistant/components/xiaomi_ble/config_flow.py +++ b/homeassistant/components/xiaomi_ble/config_flow.py @@ -17,7 +17,7 @@ from homeassistant.components.bluetooth import ( async_discovered_service_info, 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 .const import DOMAIN @@ -264,9 +264,6 @@ class XiaomiConfigFlow(ConfigFlow, domain=DOMAIN): self, entry_data: Mapping[str, Any] ) -> ConfigFlowResult: """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"] self._discovered_device = device @@ -289,10 +286,10 @@ class XiaomiConfigFlow(ConfigFlow, domain=DOMAIN): if bindkey: data["bindkey"] = bindkey - if entry_id := self.context.get("entry_id"): - entry = self.hass.config_entries.async_get_entry(entry_id) - assert entry is not None - return self.async_update_reload_and_abort(entry, data=data) + if self.source == SOURCE_REAUTH: + return self.async_update_reload_and_abort( + self._get_reauth_entry(), data=data + ) return self.async_create_entry( title=self.context["title_placeholders"]["name"], -- GitLab