Only debug log new Sonos SSDP discoveries (#51247)

* Only debug log new SSDP discoveries

* Use existing reference

* Remove from known on unseen

* Update homeassistant/components/sonos/speaker.py

Co-authored-by: J. Nick Koston <nick@koston.org>

Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
jjlawren 2021-05-30 20:28:22 -05:00 committed by GitHub
parent 319071ba39
commit 1a5d35d7bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -78,6 +78,7 @@ class SonosData:
self.alarms: dict[str, Alarm] = {}
self.topology_condition = asyncio.Condition()
self.hosts_heartbeat = None
self.ssdp_known: set[str] = set()
async def async_setup(hass, config):
@ -184,10 +185,12 @@ async def async_setup_entry( # noqa: C901
@callback
def _async_discovered_player(info):
_LOGGER.debug("Sonos Discovery: %s", info)
uid = info.get(ssdp.ATTR_UPNP_UDN)
if uid.startswith("uuid:"):
uid = uid[5:]
if uid not in data.ssdp_known:
_LOGGER.debug("New discovery: %s", info)
data.ssdp_known.add(uid)
discovered_ip = urlparse(info[ssdp.ATTR_SSDP_LOCATION]).hostname
asyncio.create_task(_async_create_discovered_player(uid, discovered_ip))

View File

@ -460,6 +460,7 @@ class SonosSpeaker:
await subscription.unsubscribe()
self._subscriptions = []
self.hass.data[DATA_SONOS].ssdp_known.remove(self.soco.uid)
#
# Alarm management