Adjust Sonos visibility checks (#67196)

This commit is contained in:
jjlawren 2022-02-25 10:27:06 -06:00 committed by GitHub
parent 199d359814
commit a4ba71408b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -182,6 +182,9 @@ class SonosDiscoveryManager:
soco = SoCo(ip_address) soco = SoCo(ip_address)
# Ensure that the player is available and UID is cached # Ensure that the player is available and UID is cached
uid = soco.uid uid = soco.uid
# Abort early if the device is not visible
if not soco.is_visible:
return None
_ = soco.volume _ = soco.volume
return soco return soco
except NotSupportedException as exc: except NotSupportedException as exc:
@ -240,8 +243,7 @@ class SonosDiscoveryManager:
None, None,
) )
if not known_uid: if not known_uid:
soco = self._create_soco(ip_addr, SoCoCreationSource.CONFIGURED) if soco := self._create_soco(ip_addr, SoCoCreationSource.CONFIGURED):
if soco and soco.is_visible:
self._discovered_player(soco) self._discovered_player(soco)
self.data.hosts_heartbeat = call_later( self.data.hosts_heartbeat = call_later(
@ -249,8 +251,7 @@ class SonosDiscoveryManager:
) )
def _discovered_ip(self, ip_address): def _discovered_ip(self, ip_address):
soco = self._create_soco(ip_address, SoCoCreationSource.DISCOVERED) if soco := self._create_soco(ip_address, SoCoCreationSource.DISCOVERED):
if soco and soco.is_visible:
self._discovered_player(soco) self._discovered_player(soco)
async def _async_create_discovered_player(self, uid, discovered_ip, boot_seqnum): async def _async_create_discovered_player(self, uid, discovered_ip, boot_seqnum):