Ensure sonos always gets ssdp callbacks from searches (#56591)

This commit is contained in:
J. Nick Koston 2021-09-26 17:16:03 -05:00 committed by GitHub
parent 6399730d2f
commit 26e031984b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 27 additions and 14 deletions

View File

@ -2,7 +2,7 @@
"domain": "dlna_dmr",
"name": "DLNA Digital Media Renderer",
"documentation": "https://www.home-assistant.io/integrations/dlna_dmr",
"requirements": ["async-upnp-client==0.21.2"],
"requirements": ["async-upnp-client==0.22.1"],
"dependencies": ["network"],
"codeowners": [],
"iot_class": "local_push"

View File

@ -71,13 +71,13 @@ SsdpCallback = Callable[[Mapping[str, Any], SsdpChange], Awaitable]
SSDP_SOURCE_SSDP_CHANGE_MAPPING: Mapping[SsdpSource, SsdpChange] = {
SsdpSource.SEARCH: SsdpChange.ALIVE,
SsdpSource.SEARCH_ALIVE: SsdpChange.ALIVE,
SsdpSource.SEARCH_CHANGED: SsdpChange.ALIVE,
SsdpSource.ADVERTISEMENT_ALIVE: SsdpChange.ALIVE,
SsdpSource.ADVERTISEMENT_BYEBYE: SsdpChange.BYEBYE,
SsdpSource.ADVERTISEMENT_UPDATE: SsdpChange.UPDATE,
}
_LOGGER = logging.getLogger(__name__)
@ -374,26 +374,39 @@ class Scanner:
]
async def _ssdp_listener_callback(
self, ssdp_device: SsdpDevice, dst: DeviceOrServiceType, source: SsdpSource
self,
ssdp_device: SsdpDevice,
dst: DeviceOrServiceType,
source: SsdpSource,
) -> None:
"""Handle a device/service change."""
_LOGGER.debug(
"Change, ssdp_device: %s, dst: %s, source: %s", ssdp_device, dst, source
"SSDP: ssdp_device: %s, dst: %s, source: %s", ssdp_device, dst, source
)
location = ssdp_device.location
info_desc = await self._async_get_description_dict(location) or {}
combined_headers = ssdp_device.combined_headers(dst)
info_with_desc = CaseInsensitiveDict(combined_headers, **info_desc)
discovery_info = discovery_info_from_headers_and_description(info_with_desc)
callbacks = self._async_get_matching_callbacks(combined_headers)
matching_domains: set[str] = set()
# If there are no changes from a search, do not trigger a config flow
if source != SsdpSource.SEARCH_ALIVE:
matching_domains = self.integration_matchers.async_matching_domains(
info_with_desc
)
if not callbacks and not matching_domains:
return
discovery_info = discovery_info_from_headers_and_description(info_with_desc)
ssdp_change = SSDP_SOURCE_SSDP_CHANGE_MAPPING[source]
await _async_process_callbacks(callbacks, discovery_info, ssdp_change)
for domain in self.integration_matchers.async_matching_domains(info_with_desc):
for domain in matching_domains:
_LOGGER.debug("Discovered %s at %s", domain, location)
flow: SSDPFlow = {
"domain": domain,
"context": {"source": config_entries.SOURCE_SSDP},

View File

@ -4,7 +4,7 @@
"documentation": "https://www.home-assistant.io/integrations/ssdp",
"requirements": [
"defusedxml==0.7.1",
"async-upnp-client==0.21.2"
"async-upnp-client==0.22.1"
],
"dependencies": ["network"],
"after_dependencies": ["zeroconf"],

View File

@ -3,7 +3,7 @@
"name": "UPnP/IGD",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/upnp",
"requirements": ["async-upnp-client==0.21.2"],
"requirements": ["async-upnp-client==0.22.1"],
"dependencies": ["network", "ssdp"],
"codeowners": ["@StevenLooman","@ehendrix23"],
"ssdp": [

View File

@ -2,7 +2,7 @@
"domain": "yeelight",
"name": "Yeelight",
"documentation": "https://www.home-assistant.io/integrations/yeelight",
"requirements": ["yeelight==0.7.5", "async-upnp-client==0.21.2"],
"requirements": ["yeelight==0.7.5", "async-upnp-client==0.22.1"],
"codeowners": ["@rytilahti", "@zewelor", "@shenxn", "@starkillerOG"],
"config_flow": true,
"dependencies": ["network"],

View File

@ -4,7 +4,7 @@ aiodiscover==1.4.2
aiohttp==3.7.4.post0
aiohttp_cors==0.7.0
astral==2.2
async-upnp-client==0.21.2
async-upnp-client==0.22.1
async_timeout==3.0.1
attrs==21.2.0
awesomeversion==21.8.1

View File

@ -327,7 +327,7 @@ asterisk_mbox==0.5.0
# homeassistant.components.ssdp
# homeassistant.components.upnp
# homeassistant.components.yeelight
async-upnp-client==0.21.2
async-upnp-client==0.22.1
# homeassistant.components.supla
asyncpysupla==0.0.5

View File

@ -221,7 +221,7 @@ arcam-fmj==0.7.0
# homeassistant.components.ssdp
# homeassistant.components.upnp
# homeassistant.components.yeelight
async-upnp-client==0.21.2
async-upnp-client==0.22.1
# homeassistant.components.aurora
auroranoaa==0.0.2