Use new config entry update/abort helper in bond (#108690)

Use new config entry update/abort helper in bond

uses the new helper from https://github.com/home-assistant/core/pull/108034
pull/108704/head
J. Nick Koston 2024-01-22 19:09:33 -10:00 committed by GitHub
parent 7c86ab14c3
commit 6fb86f179a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 9 deletions

View File

@ -16,7 +16,7 @@ from homeassistant.components import zeroconf
from homeassistant.config_entries import ConfigEntryState
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_HOST, CONF_NAME
from homeassistant.core import HomeAssistant
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from .const import DOMAIN
@ -105,7 +105,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
host: str = discovery_info.host
bond_id = name.partition(".")[0]
await self.async_set_unique_id(bond_id)
hass = self.hass
for entry in self._async_current_entries():
if entry.unique_id != bond_id:
continue
@ -114,13 +113,9 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
token := await async_get_token(self.hass, host)
):
updates[CONF_ACCESS_TOKEN] = token
new_data = {**entry.data, **updates}
changed = new_data != dict(entry.data)
if changed:
hass.config_entries.async_update_entry(entry, data=new_data)
entry_id = entry.entry_id
hass.async_create_task(hass.config_entries.async_reload(entry_id))
raise AbortFlow("already_configured")
return self.async_update_reload_and_abort(
entry, data={**entry.data, **updates}, reason="already_configured"
)
self._discovered = {CONF_HOST: host, CONF_NAME: bond_id}
await self._async_try_automatic_configure()