예제 #1
0
    async def _process_entry(self, entry):
        """Process a single entry."""

        info = {"st": entry.st}

        if entry.location:

            # Multiple entries usually share same location. Make sure
            # we fetch it only once.
            info_req = self._description_cache.get(entry.location)

            if info_req is None:
                info_req = self._description_cache[
                    entry.location] = self.hass.async_create_task(
                        self._fetch_description(entry.location))

            info.update(await info_req)

        domains = set()
        for domain, matchers in SSDP.items():
            for matcher in matchers:
                if all(info.get(k) == v for (k, v) in matcher.items()):
                    domains.add(domain)

        if domains:
            return (entry, info_from_entry(entry, info), domains)

        return None
예제 #2
0
async def async_get_ssdp(hass: "HomeAssistant") -> Dict[str, List]:
    """Return cached list of ssdp mappings."""

    ssdp: Dict[str, List] = SSDP.copy()

    integrations = await async_get_custom_components(hass)
    for integration in integrations.values():
        if not integration.ssdp:
            continue

        ssdp[integration.domain] = integration.ssdp

    return ssdp