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,
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 .const import DOMAIN
@ -161,9 +161,6 @@ class BTHomeConfigFlow(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
@ -182,10 +179,10 @@ class BTHomeConfigFlow(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"],