mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Ensure sonos ssdp callbacks use dataclass methods (#60782)
This commit is contained in:
parent
0c18d710cc
commit
8e0ef52cc8
@ -266,19 +266,27 @@ class SonosDiscoveryManager:
|
||||
self.hass, f"{SONOS_SPEAKER_ACTIVITY}-{uid}", "discovery"
|
||||
)
|
||||
|
||||
async def _async_ssdp_discovered_player(self, info, change):
|
||||
async def _async_ssdp_discovered_player(
|
||||
self, info: ssdp.SsdpServiceInfo, change: ssdp.SsdpChange
|
||||
) -> None:
|
||||
if change == ssdp.SsdpChange.BYEBYE:
|
||||
return
|
||||
|
||||
uid = info.get(ssdp.ATTR_UPNP_UDN)
|
||||
uid = info.upnp[ssdp.ATTR_UPNP_UDN]
|
||||
if not uid.startswith("uuid:RINCON_"):
|
||||
return
|
||||
|
||||
uid = uid[5:]
|
||||
discovered_ip = urlparse(info[ssdp.ATTR_SSDP_LOCATION]).hostname
|
||||
boot_seqnum = info.get("X-RINCON-BOOTSEQ")
|
||||
discovered_ip = urlparse(info.ssdp_location).hostname
|
||||
boot_seqnum = info.ssdp_headers.get("X-RINCON-BOOTSEQ")
|
||||
self.async_discovered_player(
|
||||
"SSDP", info, discovered_ip, uid, boot_seqnum, info.get("modelName"), None
|
||||
"SSDP",
|
||||
info,
|
||||
discovered_ip,
|
||||
uid,
|
||||
boot_seqnum,
|
||||
info.upnp.get(ssdp.ATTR_UPNP_MODEL_NAME),
|
||||
None,
|
||||
)
|
||||
|
||||
@callback
|
||||
|
@ -94,10 +94,14 @@ def discover_fixture(soco):
|
||||
|
||||
async def do_callback(hass, callback, *args, **kwargs):
|
||||
await callback(
|
||||
{
|
||||
ssdp.ATTR_UPNP_UDN: f"uuid:{soco.uid}",
|
||||
ssdp.ATTR_SSDP_LOCATION: f"http://{soco.ip_address}/",
|
||||
},
|
||||
ssdp.SsdpServiceInfo(
|
||||
ssdp_location=f"http://{soco.ip_address}/",
|
||||
ssdp_st="urn:schemas-upnp-org:device:ZonePlayer:1",
|
||||
ssdp_usn=f"uuid:{soco.uid}_MR::urn:schemas-upnp-org:service:GroupRenderingControl:1",
|
||||
upnp={
|
||||
ssdp.ATTR_UPNP_UDN: f"uuid:{soco.uid}",
|
||||
},
|
||||
),
|
||||
ssdp.SsdpChange.ALIVE,
|
||||
)
|
||||
return MagicMock()
|
||||
|
Loading…
x
Reference in New Issue
Block a user