mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 23:37:18 +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"
|
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:
|
if change == ssdp.SsdpChange.BYEBYE:
|
||||||
return
|
return
|
||||||
|
|
||||||
uid = info.get(ssdp.ATTR_UPNP_UDN)
|
uid = info.upnp[ssdp.ATTR_UPNP_UDN]
|
||||||
if not uid.startswith("uuid:RINCON_"):
|
if not uid.startswith("uuid:RINCON_"):
|
||||||
return
|
return
|
||||||
|
|
||||||
uid = uid[5:]
|
uid = uid[5:]
|
||||||
discovered_ip = urlparse(info[ssdp.ATTR_SSDP_LOCATION]).hostname
|
discovered_ip = urlparse(info.ssdp_location).hostname
|
||||||
boot_seqnum = info.get("X-RINCON-BOOTSEQ")
|
boot_seqnum = info.ssdp_headers.get("X-RINCON-BOOTSEQ")
|
||||||
self.async_discovered_player(
|
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
|
@callback
|
||||||
|
@ -94,10 +94,14 @@ def discover_fixture(soco):
|
|||||||
|
|
||||||
async def do_callback(hass, callback, *args, **kwargs):
|
async def do_callback(hass, callback, *args, **kwargs):
|
||||||
await callback(
|
await callback(
|
||||||
{
|
ssdp.SsdpServiceInfo(
|
||||||
ssdp.ATTR_UPNP_UDN: f"uuid:{soco.uid}",
|
ssdp_location=f"http://{soco.ip_address}/",
|
||||||
ssdp.ATTR_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,
|
ssdp.SsdpChange.ALIVE,
|
||||||
)
|
)
|
||||||
return MagicMock()
|
return MagicMock()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user