diff --git a/homeassistant/components/dlna_dmr/manifest.json b/homeassistant/components/dlna_dmr/manifest.json index 582e48de839..9d05b02000b 100644 --- a/homeassistant/components/dlna_dmr/manifest.json +++ b/homeassistant/components/dlna_dmr/manifest.json @@ -3,7 +3,7 @@ "name": "DLNA Digital Media Renderer", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/dlna_dmr", - "requirements": ["async-upnp-client==0.32.0"], + "requirements": ["async-upnp-client==0.32.1"], "dependencies": ["ssdp"], "after_dependencies": ["media_source"], "ssdp": [ diff --git a/homeassistant/components/dlna_dms/manifest.json b/homeassistant/components/dlna_dms/manifest.json index 569b2cc635e..98ad81e653a 100644 --- a/homeassistant/components/dlna_dms/manifest.json +++ b/homeassistant/components/dlna_dms/manifest.json @@ -3,7 +3,7 @@ "name": "DLNA Digital Media Server", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/dlna_dms", - "requirements": ["async-upnp-client==0.32.0"], + "requirements": ["async-upnp-client==0.32.1"], "dependencies": ["ssdp"], "after_dependencies": ["media_source"], "ssdp": [ diff --git a/homeassistant/components/samsungtv/manifest.json b/homeassistant/components/samsungtv/manifest.json index 0fc989c57c6..a7aa842f485 100644 --- a/homeassistant/components/samsungtv/manifest.json +++ b/homeassistant/components/samsungtv/manifest.json @@ -7,7 +7,7 @@ "samsungctl[websocket]==0.7.1", "samsungtvws[async,encrypted]==2.5.0", "wakeonlan==2.1.0", - "async-upnp-client==0.32.0" + "async-upnp-client==0.32.1" ], "ssdp": [ { diff --git a/homeassistant/components/ssdp/__init__.py b/homeassistant/components/ssdp/__init__.py index 8783f5eeb34..195bebb8321 100644 --- a/homeassistant/components/ssdp/__init__.py +++ b/homeassistant/components/ssdp/__init__.py @@ -9,6 +9,7 @@ from enum import Enum from ipaddress import IPv4Address, IPv6Address import logging import socket +from time import time from typing import Any from urllib.parse import urljoin import xml.etree.ElementTree as ET @@ -29,7 +30,12 @@ from async_upnp_client.server import ( UpnpServerDevice, UpnpServerService, ) -from async_upnp_client.ssdp import SSDP_PORT, determine_source_target, is_ipv4_address +from async_upnp_client.ssdp import ( + SSDP_PORT, + determine_source_target, + fix_ipv6_address_scope_id, + is_ipv4_address, +) from async_upnp_client.ssdp_listener import SsdpDevice, SsdpDeviceTracker, SsdpListener from async_upnp_client.utils import CaseInsensitiveDict @@ -213,8 +219,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: UPNP_SERVER: server, } - hass.create_task(scanner.async_start()) - hass.create_task(server.async_start()) + await scanner.async_start() + await server.async_start() return True @@ -415,6 +421,7 @@ class Scanner: else: source_tuple = (source_ip_str, 0) source, target = determine_source_target(source_tuple) + source = fix_ipv6_address_scope_id(source) or source self._ssdp_listeners.append( SsdpListener( async_callback=self._ssdp_listener_callback, @@ -710,6 +717,7 @@ class Server: ) # Start a server on all source IPs. + boot_id = int(time()) for source_ip in await async_build_source_set(self.hass): source_ip_str = str(source_ip) if source_ip.version == 6: @@ -722,6 +730,7 @@ class Server: else: source_tuple = (source_ip_str, 0) source, target = determine_source_target(source_tuple) + source = fix_ipv6_address_scope_id(source) or source http_port = await _async_find_next_available_port(source) _LOGGER.debug("Binding UPnP HTTP server to: %s:%s", source_ip, http_port) self._upnp_servers.append( @@ -730,6 +739,7 @@ class Server: target=target, http_port=http_port, server_device=HassUpnpServiceDevice, + boot_id=boot_id, options={ SSDP_SEARCH_RESPONDER_OPTIONS: { SSDP_SEARCH_RESPONDER_OPTION_ALWAYS_REPLY_WITH_ROOT_DEVICE: True diff --git a/homeassistant/components/ssdp/manifest.json b/homeassistant/components/ssdp/manifest.json index b74883e2008..59d9d6ddad8 100644 --- a/homeassistant/components/ssdp/manifest.json +++ b/homeassistant/components/ssdp/manifest.json @@ -2,7 +2,7 @@ "domain": "ssdp", "name": "Simple Service Discovery Protocol (SSDP)", "documentation": "https://www.home-assistant.io/integrations/ssdp", - "requirements": ["async-upnp-client==0.32.0"], + "requirements": ["async-upnp-client==0.32.1"], "dependencies": ["network"], "after_dependencies": ["zeroconf"], "codeowners": [], diff --git a/homeassistant/components/upnp/manifest.json b/homeassistant/components/upnp/manifest.json index b81b0ceb777..c574a5d7269 100644 --- a/homeassistant/components/upnp/manifest.json +++ b/homeassistant/components/upnp/manifest.json @@ -3,7 +3,7 @@ "name": "UPnP/IGD", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/upnp", - "requirements": ["async-upnp-client==0.32.0", "getmac==0.8.2"], + "requirements": ["async-upnp-client==0.32.1", "getmac==0.8.2"], "dependencies": ["network", "ssdp"], "codeowners": ["@StevenLooman"], "ssdp": [ diff --git a/homeassistant/components/yeelight/manifest.json b/homeassistant/components/yeelight/manifest.json index ac688719fea..16fe2ae7700 100644 --- a/homeassistant/components/yeelight/manifest.json +++ b/homeassistant/components/yeelight/manifest.json @@ -2,7 +2,7 @@ "domain": "yeelight", "name": "Yeelight", "documentation": "https://www.home-assistant.io/integrations/yeelight", - "requirements": ["yeelight==0.7.10", "async-upnp-client==0.32.0"], + "requirements": ["yeelight==0.7.10", "async-upnp-client==0.32.1"], "codeowners": ["@zewelor", "@shenxn", "@starkillerOG", "@alexyao2015"], "config_flow": true, "dependencies": ["network"], diff --git a/homeassistant/package_constraints.txt b/homeassistant/package_constraints.txt index 2aca1d72eba..80402eef843 100644 --- a/homeassistant/package_constraints.txt +++ b/homeassistant/package_constraints.txt @@ -4,7 +4,7 @@ aiodiscover==1.4.13 aiohttp==3.8.1 aiohttp_cors==0.7.0 astral==2.2 -async-upnp-client==0.32.0 +async-upnp-client==0.32.1 async_timeout==4.0.2 atomicwrites-homeassistant==1.4.1 attrs==21.2.0 diff --git a/requirements_all.txt b/requirements_all.txt index c25834d151b..7770c84193e 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -353,7 +353,7 @@ asterisk_mbox==0.5.0 # homeassistant.components.ssdp # homeassistant.components.upnp # homeassistant.components.yeelight -async-upnp-client==0.32.0 +async-upnp-client==0.32.1 # homeassistant.components.supla asyncpysupla==0.0.5 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index f4d4e2ed2ba..1679aee7e6d 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -307,7 +307,7 @@ arcam-fmj==0.12.0 # homeassistant.components.ssdp # homeassistant.components.upnp # homeassistant.components.yeelight -async-upnp-client==0.32.0 +async-upnp-client==0.32.1 # homeassistant.components.sleepiq asyncsleepiq==1.2.3 diff --git a/tests/components/ssdp/test_init.py b/tests/components/ssdp/test_init.py index e5d452af948..4076ef4685d 100644 --- a/tests/components/ssdp/test_init.py +++ b/tests/components/ssdp/test_init.py @@ -671,7 +671,7 @@ async def test_async_detect_interfaces_setting_empty_route( ssdp_listeners = hass.data[ssdp.DOMAIN][ssdp.SSDP_SCANNER]._ssdp_listeners sources = {ssdp_listener.source for ssdp_listener in ssdp_listeners} - assert sources == {("2001:db8::%1", 0, 0, 1), ("192.168.1.5", 0)} + assert sources == {("2001:db8::", 0, 0, 1), ("192.168.1.5", 0)} @pytest.mark.usefixtures("mock_get_source_ip") @@ -695,7 +695,7 @@ async def test_bind_failure_skips_adapter( """Test that an adapter with a bind failure is skipped.""" async def _async_start(self): - if self.source == ("2001:db8::%1", 0, 0, 1): + if self.source == ("2001:db8::", 0, 0, 1): raise OSError SsdpListener.async_start = _async_start