(hass: HomeAssistant)
Common setup stages.
Common setup stages.
Common setup stages .
async def _async_common_setup(hass: HomeAssistant):
    """Common setup stages."""
    integration = await async_get_integration(hass, DOMAIN)

    hacs = get_hacs()

    hacs.enable_hacs()
    await hacs.async_set_stage(None)

    hacs.log.info(STARTUP.format(version=integration.version))

    hacs.integration = integration
    hacs.version = integration.version
    hacs.hass = hass
    hacs.data = HacsData()
    hacs.system.running = True
    hacs.session = async_create_clientsession(hass)
    hacs.tasks = HacsTaskManager(hacs=hacs, hass=hass)

    try:
        lovelace_info = await system_health_info(hacs.hass)
    except (TypeError, KeyError, HomeAssistantError):
        # If this happens, the users YAML is not valid, we assume YAML mode
        lovelace_info = {"mode": "yaml"}
    hacs.log.debug(f"Configuration type: {hacs.configuration.config_type}")
    hacs.core.config_path = hacs.hass.config.path()
    hacs.core.ha_version = HAVERSION

    hacs.core.lovelace_mode = lovelace_info.get("mode", "yaml")
    hacs.core.lovelace_mode = LovelaceMode(lovelace_info.get("mode", "yaml"))

    await hacs.tasks.async_load()

    # Setup session for API clients
    session = async_create_clientsession(hacs.hass)

    ## Legacy GitHub client
    hacs.github = GitHub(
        hacs.configuration.token,
        session,
        headers={
            "User-Agent": f"HACS/{hacs.version}",
            "Accept": ACCEPT_HEADERS["preview"],
        },
    )

    ## New GitHub client
    hacs.githubapi = GitHubAPI(
        token=hacs.configuration.token,
        session=session,
        **{"client_name": f"HACS/{hacs.version}"},
    )

    hass.data[DOMAIN] = hacs
async def _async_common_setup ( hass : HomeAssistant ) : integration = await async_get_integration ( hass , DOMAIN ) hacs = get_hacs ( ) hacs . enable_hacs ( ) await hacs . async_set_stage ( None ) hacs . log . info ( STARTUP . format ( version = integration . version ) ) hacs . integration = integration hacs . version = integration . version hacs . hass = hass hacs . data = HacsData ( ) hacs . system . running = True hacs . session = async_create_clientsession ( hass ) hacs . tasks = HacsTaskManager ( hacs = hacs , hass = hass ) try : lovelace_info = await system_health_info ( hacs . hass ) except ( TypeError , KeyError , HomeAssistantError ) : # If this happens, the users YAML is not valid, we assume YAML mode lovelace_info = { "mode" : "yaml" } hacs . log . debug ( f"Configuration type: {hacs.configuration.config_type}" ) hacs . core . config_path = hacs . hass . config . path ( ) hacs . core . ha_version = HAVERSION hacs . core . lovelace_mode = lovelace_info . get ( "mode" , "yaml" ) hacs . core . lovelace_mode = LovelaceMode ( lovelace_info . get ( "mode" , "yaml" ) ) await hacs . tasks . async_load ( ) # Setup session for API clients session = async_create_clientsession ( hacs . hass ) ## Legacy GitHub client hacs . github = GitHub ( hacs . configuration . token , session , headers = { "User-Agent" : f"HACS/{hacs.version}" , "Accept" : ACCEPT_HEADERS [ "preview" ] , } , ) ## New GitHub client hacs . githubapi = GitHubAPI ( token = hacs . configuration . token , session = session , * * { "client_name" : f"HACS/{hacs.version}" } , ) hass . data [ DOMAIN ] = hacs