Disconnect homekit_controller devices on the stop event (#49244)
This commit is contained in:
parent
54322f84c5
commit
e234fc6e7e
2 changed files with 41 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
"""Support for Homekit device discovery."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from typing import Any
|
||||
|
||||
import aiohomekit
|
||||
|
@ -13,6 +14,7 @@ from aiohomekit.model.characteristics import (
|
|||
from aiohomekit.model.services import Service, ServicesTypes
|
||||
|
||||
from homeassistant.components import zeroconf
|
||||
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
|
@ -228,6 +230,16 @@ async def async_setup(hass, config):
|
|||
hass.data[KNOWN_DEVICES] = {}
|
||||
hass.data[TRIGGERS] = {}
|
||||
|
||||
async def _async_stop_homekit_controller(event):
|
||||
await asyncio.gather(
|
||||
*[
|
||||
connection.async_unload()
|
||||
for connection in hass.data[KNOWN_DEVICES].values()
|
||||
]
|
||||
)
|
||||
|
||||
hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _async_stop_homekit_controller)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue