From 91ca2427480078054422d6a647a0fb900af51da9 Mon Sep 17 00:00:00 2001 From: Marvin Schenkel Date: Tue, 23 Dec 2025 16:44:10 +0100 Subject: [PATCH] Fix Sonos S1 not reconnecting after having gone offline. (#2874) --- music_assistant/providers/sonos_s1/player.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/music_assistant/providers/sonos_s1/player.py b/music_assistant/providers/sonos_s1/player.py index 1d4137ae..36036ee5 100644 --- a/music_assistant/providers/sonos_s1/player.py +++ b/music_assistant/providers/sonos_s1/player.py @@ -280,7 +280,9 @@ class SonosPlayer(Player): self._attr_volume_level = self.soco.volume self._attr_volume_muted = self.soco.mute - await asyncio.to_thread(_poll) + await self._check_availability() + if self._attr_available: + await asyncio.to_thread(_poll) @soco_error() def poll_media(self) -> None: @@ -317,6 +319,20 @@ class SonosPlayer(Player): ) self.update_player() + async def _check_availability(self) -> None: + """Check if the player is still available.""" + try: + await asyncio.to_thread(self.ping) + self._speaker_activity("ping") + except SonosUpdateError: + if not self._attr_available: + return + self.logger.warning( + "No recent activity and cannot reach %s, marking unavailable", + self.display_name, + ) + await self.offline() + @soco_error() def ping(self) -> None: """Test device availability. Failure will raise SonosUpdateError.""" -- 2.34.1