mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Improve SSDP callback performance (#62359)
This commit is contained in:
parent
e8096e7f51
commit
70947b14a3
@ -472,22 +472,24 @@ class Scanner:
|
||||
)
|
||||
|
||||
location = ssdp_device.location
|
||||
info_desc = await self._async_get_description_dict(location) or {}
|
||||
info_desc = None
|
||||
combined_headers = ssdp_device.combined_headers(dst)
|
||||
info_with_desc = CaseInsensitiveDict(combined_headers, **info_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:
|
||||
info_desc = await self._async_get_description_dict(location) or {}
|
||||
assert isinstance(combined_headers, CaseInsensitiveDict)
|
||||
matching_domains = self.integration_matchers.async_matching_domains(
|
||||
info_with_desc
|
||||
CaseInsensitiveDict({**combined_headers.as_dict(), **info_desc})
|
||||
)
|
||||
|
||||
if not callbacks and not matching_domains:
|
||||
return
|
||||
|
||||
if info_desc is None:
|
||||
info_desc = await self._async_get_description_dict(location) or {}
|
||||
discovery_info = discovery_info_from_headers_and_description(
|
||||
combined_headers, info_desc
|
||||
)
|
||||
@ -565,7 +567,10 @@ def discovery_info_from_headers_and_description(
|
||||
"""Convert headers and description to discovery_info."""
|
||||
ssdp_usn = combined_headers["usn"]
|
||||
ssdp_st = combined_headers.get("st")
|
||||
upnp_info = {**info_desc}
|
||||
if isinstance(info_desc, CaseInsensitiveDict):
|
||||
upnp_info = {**info_desc.as_dict()}
|
||||
else:
|
||||
upnp_info = {**info_desc}
|
||||
|
||||
# Increase compatibility: depending on the message type,
|
||||
# either the ST (Search Target, from M-SEARCH messages)
|
||||
|
Loading…
x
Reference in New Issue
Block a user