mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Eagerly shutdown homekit_controller at the stop event (#113650)
This commit is contained in:
parent
4d430520a0
commit
309fcb5c30
@ -24,6 +24,7 @@ from homeassistant.core import Event, HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.util.async_ import create_eager_task
|
||||
|
||||
from .config_flow import normalize_hkid
|
||||
from .connection import HKDevice
|
||||
@ -80,12 +81,14 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
async def _async_stop_homekit_controller(event: Event) -> None:
|
||||
await asyncio.gather(
|
||||
*(
|
||||
connection.async_unload()
|
||||
create_eager_task(connection.async_unload())
|
||||
for connection in hass.data[KNOWN_DEVICES].values()
|
||||
)
|
||||
)
|
||||
|
||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_stop_homekit_controller)
|
||||
hass.bus.async_listen_once(
|
||||
EVENT_HOMEASSISTANT_STOP, _async_stop_homekit_controller, run_immediately=True
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
@ -77,7 +77,9 @@ async def async_get_controller(hass: HomeAssistant) -> Controller:
|
||||
|
||||
# Right now _async_stop_homekit_controller is only called on HA exiting
|
||||
# So we don't have to worry about leaking a callback here.
|
||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_stop_homekit_controller)
|
||||
hass.bus.async_listen_once(
|
||||
EVENT_HOMEASSISTANT_STOP, _async_stop_homekit_controller, run_immediately=True
|
||||
)
|
||||
|
||||
await controller.async_start()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user