示例#1
0
async def async_get_zeroconf(hass: "HomeAssistant") -> Dict[str, List]:
    """Return cached list of zeroconf types."""
    zeroconf: Dict[str, List] = ZEROCONF.copy()

    integrations = await async_get_custom_components(hass)
    for integration in integrations.values():
        if not integration.zeroconf:
            continue
        for typ in integration.zeroconf:
            zeroconf.setdefault(typ, [])
            if integration.domain not in zeroconf[typ]:
                zeroconf[typ].append(integration.domain)

    return zeroconf
示例#2
0
文件: loader.py 项目: jhofker/core-1
async def async_get_zeroconf(hass: "HomeAssistant") -> Dict[str, List[Dict[str, str]]]:
    """Return cached list of zeroconf types."""
    zeroconf: Dict[str, List[Dict[str, str]]] = ZEROCONF.copy()

    integrations = await async_get_custom_components(hass)
    for integration in integrations.values():
        if not integration.zeroconf:
            continue
        for entry in integration.zeroconf:
            data = {"domain": integration.domain}
            if isinstance(entry, dict):
                typ = entry["type"]
                entry_without_type = entry.copy()
                del entry_without_type["type"]
                data.update(entry_without_type)
            else:
                typ = entry

            zeroconf.setdefault(typ, []).append(data)

    return zeroconf
示例#3
0
async def async_get_zeroconf(
    hass: HomeAssistant, ) -> dict[str, list[dict[str, str | dict[str, str]]]]:
    """Return cached list of zeroconf types."""
    zeroconf: dict[str, list[dict[
        str,
        str | dict[str, str]]]] = ZEROCONF.copy()  # type: ignore[assignment]

    integrations = await async_get_custom_components(hass)
    for integration in integrations.values():
        if not integration.zeroconf:
            continue
        for entry in integration.zeroconf:
            data: dict[str, str | dict[str, str]] = {
                "domain": integration.domain
            }
            if isinstance(entry, dict):
                typ = entry["type"]
                data.update(async_process_zeroconf_match_dict(entry))
            else:
                typ = entry

            zeroconf.setdefault(typ, []).append(data)

    return zeroconf