mirror of
https://github.com/home-assistant/core.git
synced 2026-05-29 19:57:40 +01:00
d766aae436
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: frenck <195327+frenck@users.noreply.github.com>
22 lines
664 B
Python
22 lines
664 B
Python
"""Common functions for SSDP discovery."""
|
|
|
|
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
|
|
)
|
|
}
|