(hacs)
return True
HACS startup tasks.
HACS startup tasks.
HACS startup tasks .
async def hacs_startup(hacs):
    """HACS startup tasks."""
    hacs.logger.debug(f"Configuration type: {hacs.configuration.config_type}")
    hacs.version = const.VERSION
    hacs.logger.info(const.STARTUP)
    hacs.system.config_path = hacs.hass.config.path()
    hacs.system.ha_version = HAVERSION
    hacs.system.disabled = False
    hacs.github = AIOGitHub(
        hacs.configuration.token, async_create_clientsession(hacs.hass)
    )
    hacs.data = HacsData()

    # Check minimum version
    if not check_version(hacs):
        if hacs.configuration.config_type == "flow":
            if hacs.configuration.config_entry is not None:
                await async_remove_entry(hacs.hass, hacs.configuration.config_entry)
        return False

    # Check custom_updater
    if not check_custom_updater(hacs):
        if hacs.configuration.config_type == "flow":
            if hacs.configuration.config_entry is not None:
                await async_remove_entry(hacs.hass, hacs.configuration.config_entry)
        return False

    # Set up frontend
    await setup_frontend(hacs)

    # Load HACS
    if not await load_hacs_repository(hacs):
        if hacs.configuration.config_type == "flow":
            if hacs.configuration.config_entry is not None:
                await async_remove_entry(hacs.hass, hacs.configuration.config_entry)
        return False

    val = ValidateData()
    if not val.validate_local_data_file():
        if hacs.configuration.config_type == "flow":
            if hacs.configuration.config_entry is not None:
                await async_remove_entry(hacs.hass, hacs.configuration.config_entry)
        return False
    else:
        if os.path.exists(f"{hacs.system.config_path}/.storage/hacs"):
            os.remove(f"{hacs.system.config_path}/.storage/hacs")

    # Restore from storefiles
    if not await hacs.data.restore():
        hacs_repo = hacs().get_by_name("custom-components/hacs")
        hacs_repo.pending_restart = True
        if hacs.configuration.config_type == "flow":
            if hacs.configuration.config_entry is not None:
                await async_remove_entry(hacs.hass, hacs.configuration.config_entry)
        return False

    # Add aditional categories
    if hacs.configuration.appdaemon:
        const.ELEMENT_TYPES.append("appdaemon")
    if hacs.configuration.python_script:
        const.ELEMENT_TYPES.append("python_script")
    if hacs.configuration.theme:
        const.ELEMENT_TYPES.append("theme")
    hacs.common.categories = sorted(const.ELEMENT_TYPES)

    # Setup startup tasks
    if hacs.configuration.config_type == "yaml":
        hacs.hass.bus.async_listen_once(
            EVENT_HOMEASSISTANT_START, hacs().startup_tasks()
        )
    else:
        async_call_later(hacs.hass, 5, hacs().startup_tasks())

    # Print DEV warning
    if hacs.configuration.dev:
        hacs.logger.error(const.DEV_MODE)
        hacs.hass.components.persistent_notification.create(
            title="HACS DEV MODE",
            message=const.DEV_MODE,
            notification_id="hacs_dev_mode",
        )

    # Add sensor
    add_sensor(hacs)

    # Set up services
    await add_services(hacs)

    # Mischief managed!
    return True
async def hacs_startup ( hacs ) : hacs . logger . debug ( f"Configuration type: {hacs.configuration.config_type}" ) hacs . version = const . VERSION hacs . logger . info ( const . STARTUP ) hacs . system . config_path = hacs . hass . config . path ( ) hacs . system . ha_version = HAVERSION hacs . system . disabled = False hacs . github = AIOGitHub ( hacs . configuration . token , async_create_clientsession ( hacs . hass ) ) hacs . data = HacsData ( ) # Check minimum version if not check_version ( hacs ) : if hacs . configuration . config_type == "flow" : if hacs . configuration . config_entry is not None : await async_remove_entry ( hacs . hass , hacs . configuration . config_entry ) return False # Check custom_updater if not check_custom_updater ( hacs ) : if hacs . configuration . config_type == "flow" : if hacs . configuration . config_entry is not None : await async_remove_entry ( hacs . hass , hacs . configuration . config_entry ) return False # Set up frontend await setup_frontend ( hacs ) # Load HACS if not await load_hacs_repository ( hacs ) : if hacs . configuration . config_type == "flow" : if hacs . configuration . config_entry is not None : await async_remove_entry ( hacs . hass , hacs . configuration . config_entry ) return False val = ValidateData ( ) if not val . validate_local_data_file ( ) : if hacs . configuration . config_type == "flow" : if hacs . configuration . config_entry is not None : await async_remove_entry ( hacs . hass , hacs . configuration . config_entry ) return False else : if os . path . exists ( f"{hacs.system.config_path}/.storage/hacs" ) : os . remove ( f"{hacs.system.config_path}/.storage/hacs" ) # Restore from storefiles if not await hacs . data . restore ( ) : hacs_repo = hacs ( ) . get_by_name ( "custom-components/hacs" ) hacs_repo . pending_restart = True if hacs . configuration . config_type == "flow" : if hacs . configuration . config_entry is not None : await async_remove_entry ( hacs . hass , hacs . configuration . config_entry ) return False # Add aditional categories if hacs . configuration . appdaemon : const . ELEMENT_TYPES . append ( "appdaemon" ) if hacs . configuration . python_script : const . ELEMENT_TYPES . append ( "python_script" ) if hacs . configuration . theme : const . ELEMENT_TYPES . append ( "theme" ) hacs . common . categories = sorted ( const . ELEMENT_TYPES ) # Setup startup tasks if hacs . configuration . config_type == "yaml" : hacs . hass . bus . async_listen_once ( EVENT_HOMEASSISTANT_START , hacs ( ) . startup_tasks ( ) ) else : async_call_later ( hacs . hass , 5 , hacs ( ) . startup_tasks ( ) ) # Print DEV warning if hacs . configuration . dev : hacs . logger . error ( const . DEV_MODE ) hacs . hass . components . persistent_notification . create ( title = "HACS DEV MODE" , message = const . DEV_MODE , notification_id = "hacs_dev_mode" , ) # Add sensor add_sensor ( hacs ) # Set up services await add_services ( hacs ) # Mischief managed! return True