mirror of
https://github.com/home-assistant/core.git
synced 2026-02-23 19:37:12 +00:00
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Co-authored-by: Franck Nijhof <git@frenck.dev>
24 lines
700 B
Python
24 lines
700 B
Python
"""Common functions for SSDP discovery."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from ipaddress import IPv4Address, IPv6Address
|
|
from typing import cast
|
|
|
|
from homeassistant.components import network
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
|
|
async def async_build_source_set(hass: HomeAssistant) -> set[IPv4Address | IPv6Address]:
|
|
"""Build the list of ssdp sources."""
|
|
return {
|
|
source_ip
|
|
for source_ip in await network.async_get_enabled_source_ips(hass)
|
|
if not source_ip.is_loopback
|
|
and not source_ip.is_global
|
|
and (
|
|
(source_ip.version == 6 and cast(IPv6Address, source_ip).scope_id)
|
|
or source_ip.version == 4
|
|
)
|
|
}
|