(hass: HomeAssistant, _: ConfigType)
return True
Activate Yandex Smart Home component.
Activate Yandex Smart Home component.
Activate Yandex Smart Home component .
async def async_setup(hass: HomeAssistant, _: ConfigType):
    """Activate Yandex Smart Home component."""
    hass.data[DOMAIN] = {}
    hass.data[DOMAIN][NOTIFIERS]: list[YandexNotifier] = []
    hass.data[DOMAIN][CONFIG]: Config | None = None
    hass.data[DOMAIN][CLOUD_MANAGER]: CloudManager | None = None

    async_register_http(hass)
    async_setup_notifier(hass)

    def _device_discovery_listener(_: Event):
        for entry in hass.config_entries.async_entries(DOMAIN):
            if not entry.data[const.CONF_DEVICES_DISCOVERED]:
                data = dict(entry.data)
                data[const.CONF_DEVICES_DISCOVERED] = True

                hass.config_entries.async_update_entry(entry, data=data, options=entry.options)

    hass.bus.async_listen(EVENT_DEVICE_DISCOVERY, _device_discovery_listener)

    async def _handle_reload(*_):
        current_entries = hass.config_entries.async_entries(DOMAIN)
        reload_tasks = [
            hass.config_entries.async_reload(entry.entry_id)
            for entry in current_entries
        ]

        await asyncio.gather(*reload_tasks)

    hass.helpers.service.async_register_admin_service(DOMAIN, SERVICE_RELOAD, _handle_reload)

    return True
async def async_setup ( hass : HomeAssistant , _ : ConfigType ) : hass . data [ DOMAIN ] = { } hass . data [ DOMAIN ] [ NOTIFIERS ] : list [ YandexNotifier ] = [ ] hass . data [ DOMAIN ] [ CONFIG ] : Config | None = None hass . data [ DOMAIN ] [ CLOUD_MANAGER ] : CloudManager | None = None async_register_http ( hass ) async_setup_notifier ( hass ) def _device_discovery_listener ( _ : Event ) : for entry in hass . config_entries . async_entries ( DOMAIN ) : if not entry . data [ const . CONF_DEVICES_DISCOVERED ] : data = dict ( entry . data ) data [ const . CONF_DEVICES_DISCOVERED ] = True hass . config_entries . async_update_entry ( entry , data = data , options = entry . options ) hass . bus . async_listen ( EVENT_DEVICE_DISCOVERY , _device_discovery_listener ) async def _handle_reload ( * _ ) : current_entries = hass . config_entries . async_entries ( DOMAIN ) reload_tasks = [ hass . config_entries . async_reload ( entry . entry_id ) for entry in current_entries ] await asyncio . gather ( * reload_tasks ) hass . helpers . service . async_register_admin_service ( DOMAIN , SERVICE_RELOAD , _handle_reload ) return True