Force an attempted subscribe on speaker reboot (#54100)
* Force an attempted subscribe on speaker reboot * Recreate subscriptions and timers explicitly on speaker reboot * only create poll timer if there is not one already Co-authored-by: jjlawren <jjlawren@users.noreply.github.com> * Black Co-authored-by: jjlawren <jjlawren@users.noreply.github.com>
This commit is contained in:
parent
a23da30c29
commit
74d41ac5e5
1 changed files with 21 additions and 8 deletions
|
@ -496,9 +496,7 @@ class SonosSpeaker:
|
||||||
|
|
||||||
self.async_write_entity_states()
|
self.async_write_entity_states()
|
||||||
|
|
||||||
async def async_unseen(
|
async def async_unseen(self, now: datetime.datetime | None = None) -> None:
|
||||||
self, now: datetime.datetime | None = None, will_reconnect: bool = False
|
|
||||||
) -> None:
|
|
||||||
"""Make this player unavailable when it was not seen recently."""
|
"""Make this player unavailable when it was not seen recently."""
|
||||||
if self._seen_timer:
|
if self._seen_timer:
|
||||||
self._seen_timer()
|
self._seen_timer()
|
||||||
|
@ -527,9 +525,8 @@ class SonosSpeaker:
|
||||||
|
|
||||||
await self.async_unsubscribe()
|
await self.async_unsubscribe()
|
||||||
|
|
||||||
if not will_reconnect:
|
self.hass.data[DATA_SONOS].discovery_known.discard(self.soco.uid)
|
||||||
self.hass.data[DATA_SONOS].discovery_known.discard(self.soco.uid)
|
self.async_write_entity_states()
|
||||||
self.async_write_entity_states()
|
|
||||||
|
|
||||||
async def async_rebooted(self, soco: SoCo) -> None:
|
async def async_rebooted(self, soco: SoCo) -> None:
|
||||||
"""Handle a detected speaker reboot."""
|
"""Handle a detected speaker reboot."""
|
||||||
|
@ -538,8 +535,24 @@ class SonosSpeaker:
|
||||||
self.zone_name,
|
self.zone_name,
|
||||||
soco,
|
soco,
|
||||||
)
|
)
|
||||||
await self.async_unseen(will_reconnect=True)
|
await self.async_unsubscribe()
|
||||||
await self.async_seen(soco)
|
self.soco = soco
|
||||||
|
await self.async_subscribe()
|
||||||
|
if self._seen_timer:
|
||||||
|
self._seen_timer()
|
||||||
|
self._seen_timer = self.hass.helpers.event.async_call_later(
|
||||||
|
SEEN_EXPIRE_TIME.total_seconds(), self.async_unseen
|
||||||
|
)
|
||||||
|
if not self._poll_timer:
|
||||||
|
self._poll_timer = self.hass.helpers.event.async_track_time_interval(
|
||||||
|
partial(
|
||||||
|
async_dispatcher_send,
|
||||||
|
self.hass,
|
||||||
|
f"{SONOS_POLL_UPDATE}-{self.soco.uid}",
|
||||||
|
),
|
||||||
|
SCAN_INTERVAL,
|
||||||
|
)
|
||||||
|
self.async_write_entity_states()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Battery management
|
# Battery management
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue