mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use SSDP byebye to mark Sonos as offline (#65686)
This commit is contained in:
parent
bebf5009d6
commit
40857bda90
@ -38,6 +38,7 @@ from .const import (
|
|||||||
SONOS_CHECK_ACTIVITY,
|
SONOS_CHECK_ACTIVITY,
|
||||||
SONOS_REBOOTED,
|
SONOS_REBOOTED,
|
||||||
SONOS_SPEAKER_ACTIVITY,
|
SONOS_SPEAKER_ACTIVITY,
|
||||||
|
SONOS_VANISHED,
|
||||||
UPNP_ST,
|
UPNP_ST,
|
||||||
)
|
)
|
||||||
from .favorites import SonosFavorites
|
from .favorites import SonosFavorites
|
||||||
@ -274,14 +275,19 @@ class SonosDiscoveryManager:
|
|||||||
async def _async_ssdp_discovered_player(
|
async def _async_ssdp_discovered_player(
|
||||||
self, info: ssdp.SsdpServiceInfo, change: ssdp.SsdpChange
|
self, info: ssdp.SsdpServiceInfo, change: ssdp.SsdpChange
|
||||||
) -> None:
|
) -> None:
|
||||||
if change == ssdp.SsdpChange.BYEBYE:
|
|
||||||
return
|
|
||||||
|
|
||||||
uid = info.upnp[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:]
|
||||||
|
|
||||||
|
if change == ssdp.SsdpChange.BYEBYE:
|
||||||
|
_LOGGER.debug(
|
||||||
|
"ssdp:byebye received from %s", info.upnp.get("friendlyName", uid)
|
||||||
|
)
|
||||||
|
reason = info.ssdp_headers.get("X-RINCON-REASON", "ssdp:byebye")
|
||||||
|
async_dispatcher_send(self.hass, f"{SONOS_VANISHED}-{uid}", reason)
|
||||||
|
return
|
||||||
|
|
||||||
discovered_ip = urlparse(info.ssdp_location).hostname
|
discovered_ip = urlparse(info.ssdp_location).hostname
|
||||||
boot_seqnum = info.ssdp_headers.get("X-RINCON-BOOTSEQ")
|
boot_seqnum = info.ssdp_headers.get("X-RINCON-BOOTSEQ")
|
||||||
self.async_discovered_player(
|
self.async_discovered_player(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user