Use _get_reauth_entry in bthome config flow (#127323)

This commit is contained in:
epenet 2024-10-02 19:44:54 +02:00 committed by GitHub
parent d8d392990d
commit da0ebbe57c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,7 +15,7 @@ from homeassistant.components.bluetooth import (
BluetoothServiceInfoBleak, BluetoothServiceInfoBleak,
async_discovered_service_info, async_discovered_service_info,
) )
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
@ -161,9 +161,6 @@ class BTHomeConfigFlow(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
@ -182,10 +179,10 @@ class BTHomeConfigFlow(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"],