Ignore commands to sonos players if not available
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Sat, 15 Jun 2024 05:34:07 +0000 (07:34 +0200)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Sat, 15 Jun 2024 05:34:07 +0000 (07:34 +0200)
music_assistant/server/providers/sonos/__init__.py

index 41628b56a6348a424e538fcc0381356fa7319c41..d45c3cbc93fa3f0f36d7f233468c54af0f8c742b 100644 (file)
@@ -266,9 +266,14 @@ class SonosPlayerProvider(PlayerProvider):
         if sonos_player.sync_coordinator:
             self.logger.debug(
                 "Ignore STOP command for %s: Player is synced to another player.",
-                player_id,
+                sonos_player.zone_name,
             )
             return
+        if "Stop" not in sonos_player.soco.available_actions:
+            self.logger.debug(
+                "Ignore STOP command for %s: Player reports this action is not available now.",
+                sonos_player.zone_name,
+            )
         await asyncio.to_thread(sonos_player.soco.stop)
 
     async def cmd_play(self, player_id: str) -> None:
@@ -280,6 +285,11 @@ class SonosPlayerProvider(PlayerProvider):
                 player_id,
             )
             return
+        if "Play" not in sonos_player.soco.available_actions:
+            self.logger.debug(
+                "Ignore STOP command for %s: Player reports this action is not available now.",
+                sonos_player.zone_name,
+            )
         await asyncio.to_thread(sonos_player.soco.play)
 
     async def cmd_pause(self, player_id: str) -> None: