Dont rely on config flow to monitor homekit_controller c# changes (#76861)

This commit is contained in:
Jc2k
2022-08-20 21:58:59 +01:00
committed by GitHub
parent 8b1713a691
commit eb0828efdb
11 changed files with 36 additions and 83 deletions

View File

@@ -8,6 +8,7 @@ from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.core import Event, HomeAssistant
from .const import CONTROLLER
from .storage import async_get_entity_storage
def folded_name(name: str) -> str:
@@ -22,6 +23,8 @@ async def async_get_controller(hass: HomeAssistant) -> Controller:
async_zeroconf_instance = await zeroconf.async_get_async_instance(hass)
char_cache = await async_get_entity_storage(hass)
# In theory another call to async_get_controller could have run while we were
# trying to get the zeroconf instance. So we check again to make sure we
# don't leak a Controller instance here.
@@ -33,6 +36,7 @@ async def async_get_controller(hass: HomeAssistant) -> Controller:
controller = Controller(
async_zeroconf_instance=async_zeroconf_instance,
bleak_scanner_instance=bleak_scanner_instance, # type: ignore[arg-type]
char_cache=char_cache,
)
hass.data[CONTROLLER] = controller