Await startup in homekit controller (#75021)

This commit is contained in:
J. Nick Koston 2022-07-14 14:44:27 +02:00 committed by GitHub
parent a3c1926da5
commit a31dde9cb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 133 additions and 30 deletions

View file

@ -17,6 +17,7 @@ from homeassistant.core import callback
from homeassistant.data_entry_flow import AbortFlow, FlowResult
from homeassistant.helpers import device_registry as dr
from .connection import HKDevice
from .const import DOMAIN, KNOWN_DEVICES
from .utils import async_get_controller
@ -240,17 +241,19 @@ class HomekitControllerFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
self.hass.config_entries.async_update_entry(
existing_entry, data={**existing_entry.data, **updated_ip_port}
)
conn = self.hass.data[KNOWN_DEVICES][hkid]
conn: HKDevice = self.hass.data[KNOWN_DEVICES][hkid]
# When we rediscover the device, let aiohomekit know
# that the device is available and we should not wait
# to retry connecting any longer. reconnect_soon
# will do nothing if the device is already connected
await conn.pairing.reconnect_soon()
if conn.config_num != config_num:
if config_num and conn.config_num != config_num:
_LOGGER.debug(
"HomeKit info %s: c# incremented, refreshing entities", hkid
)
self.hass.async_create_task(conn.async_refresh_entity_map(config_num))
self.hass.async_create_task(
conn.async_refresh_entity_map_and_entities(config_num)
)
return self.async_abort(reason="already_configured")
_LOGGER.debug("Discovered device %s (%s - %s)", name, model, hkid)