def __init__(self): """Initialize the homekit_controller flow.""" self.model = None self.hkid = None self.devices = {} self.controller = aiohomekit.Controller() self.finish_pairing = None
async def async_setup(hass, config): """Set up for Homekit devices.""" map_storage = hass.data[ENTITY_MAP] = EntityMapStorage(hass) await map_storage.async_initialize() hass.data[CONTROLLER] = aiohomekit.Controller() hass.data[KNOWN_DEVICES] = {} return True
async def async_setup(hass, config): """Set up for Homekit devices.""" map_storage = hass.data[ENTITY_MAP] = EntityMapStorage(hass) await map_storage.async_initialize() zeroconf_instance = await zeroconf.async_get_instance(hass) hass.data[CONTROLLER] = aiohomekit.Controller(zeroconf_instance=zeroconf_instance) hass.data[KNOWN_DEVICES] = {} hass.data[TRIGGERS] = {} return True
async def async_setup(hass, config): """Set up for Homekit devices.""" map_storage = hass.data[ENTITY_MAP] = EntityMapStorage(hass) await map_storage.async_initialize() hass.data[CONTROLLER] = aiohomekit.Controller() hass.data[KNOWN_DEVICES] = {} dothomekit_dir = hass.config.path(".homekit") if os.path.exists(dothomekit_dir): _LOGGER.warning( ("Legacy homekit_controller state found in %s. Support for reading " "the folder is deprecated and will be removed in 0.109.0."), dothomekit_dir, ) return True
async def async_setup(hass, config): """Set up for Homekit devices.""" map_storage = hass.data[ENTITY_MAP] = EntityMapStorage(hass) await map_storage.async_initialize() async_zeroconf_instance = await zeroconf.async_get_async_instance(hass) hass.data[CONTROLLER] = aiohomekit.Controller( async_zeroconf_instance=async_zeroconf_instance) 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
async def async_setup(opp, config): """Set up for Homekit devices.""" map_storage = opp.data[ENTITY_MAP] = EntityMapStorage(opp) await map_storage.async_initialize() zeroconf_instance = await zeroconf.async_get_instance(opp) opp.data[CONTROLLER] = aiohomekit.Controller( zeroconf_instance=zeroconf_instance) opp.data[KNOWN_DEVICES] = {} opp.data[TRIGGERS] = {} async def _async_stop_homekit_controller(event): await asyncio.gather(*[ connection.async_unload() for connection in opp.data[KNOWN_DEVICES].values() ]) opp.bus.async_listen_once(EVENT_OPENPEERPOWER_STOP, _async_stop_homekit_controller) return True
async def async_remove_entry(hass: HomeAssistant, entry: ConfigEntry) -> None: """Cleanup caches before removing config entry.""" hkid = entry.data["AccessoryPairingID"] # Remove cached type data from .storage/homekit_controller-entity-map hass.data[ENTITY_MAP].async_delete_map(hkid) # Remove the pairing on the device, making the device discoverable again. # Don't reuse any objects in hass.data as they are already unloaded async_zeroconf_instance = await zeroconf.async_get_async_instance(hass) controller = aiohomekit.Controller( async_zeroconf_instance=async_zeroconf_instance) controller.load_pairing(hkid, dict(entry.data)) try: await controller.remove_pairing(hkid) except aiohomekit.AccessoryDisconnectedError: _LOGGER.warning( "Accessory %s was removed from HomeAssistant but was not reachable " "to properly unpair. It may need resetting before you can use it with " "HomeKit again", entry.title, )
async def _async_setup_controller(self): """Create the controller.""" async_zeroconf_instance = await zeroconf.async_get_async_instance( self.hass) self.controller = aiohomekit.Controller( async_zeroconf_instance=async_zeroconf_instance)
async def _async_setup_controller(self): """Create the controller.""" zeroconf_instance = await zeroconf.async_get_instance(self.opp) self.controller = aiohomekit.Controller( zeroconf_instance=zeroconf_instance)