From: Marvin Schenkel Date: Tue, 23 Dec 2025 15:44:10 +0000 (+0100) Subject: Fix Sonos S1 not reconnecting after having gone offline. (#2874) X-Git-Url: https://git.kitaultman.com/?a=commitdiff_plain;h=91ca2427480078054422d6a647a0fb900af51da9;p=music-assistant-server.git Fix Sonos S1 not reconnecting after having gone offline. (#2874) --- 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."""