def load_platform(hass, component, platform, discovered=None, hass_config=None): """Load a component and platform dynamically. Target components will be loaded and an EVENT_PLATFORM_DISCOVERED will be fired to load the platform. The event will contain: { ATTR_SERVICE = LOAD_PLATFORM + '.' + <<component>> ATTR_PLATFORM = <<platform>> ATTR_DISCOVERED = <<discovery info>> } Use `listen_platform` to register a callback for these events. """ fire_coroutine_threadsafe( async_load_platform(hass, component, platform, discovered, hass_config), hass.loop)
def start(self) -> None: """Start home assistant.""" # Register the async start fire_coroutine_threadsafe(self.async_start(), self.loop) # Run forever and catch keyboard interrupt try: # Block until stopped _LOGGER.info("Starting Home Assistant core loop") self.loop.run_forever() return self.exit_code except KeyboardInterrupt: self.loop.call_soon_threadsafe( self.loop.create_task, self.async_stop()) self.loop.run_forever() finally: self.loop.close()
def stop(self) -> None: """Stop Home Assistant and shuts down all threads.""" fire_coroutine_threadsafe(self.async_stop(), self.loop)