Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Aug 26, 2024
1 parent d6cdef1 commit 8397417
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions music_assistant/server/providers/sonos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import asyncio
import logging
import time
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, cast

import shortuuid
from aiohttp import web
Expand Down Expand Up @@ -139,8 +139,9 @@ def __init__(
@property
def airplay_mode(self) -> bool:
"""Return if the player is in airplay mode."""
return self.mass.config.get_raw_player_config_value(
self.airplay_player_id, CONF_AIRPLAY_MODE, False
return cast(
bool,
self.mass.config.get_raw_player_config_value(self.player_id, CONF_AIRPLAY_MODE, False),
)

def get_linked_airplay_player(self, active_only: bool = True) -> Player | None:
Expand Down Expand Up @@ -461,7 +462,7 @@ class SonosPlayerProvider(PlayerProvider):
@property
def supported_features(self) -> tuple[ProviderFeature, ...]:
"""Return the features supported by this Provider."""
return (ProviderFeature.SYNC_PLAYERS, ProviderFeature.SYNC_GROUP)
return (ProviderFeature.SYNC_PLAYERS,)

async def handle_async_init(self) -> None:
"""Handle async initialization of the provider."""
Expand Down Expand Up @@ -561,7 +562,9 @@ async def get_player_config_entries(
"By default, Music Assistant uses the Sonos protocol for playback but with this "
"feature enabled, it will use the Airplay protocol instead by redirecting "
"the playback related commands to the linked Airplay player in Music Assistant, "
"allowing you to mix and match Sonos speakers with Airplay speakers.",
"allowing you to mix and match Sonos speakers with Airplay speakers. \n\n"
"TIP: When this feature is enabled, it make sense to set the underlying airplay "
"players to hide in the UI in the player settings to prevent duplicate players.",
required=False,
default_value=False,
hidden=SonosCapability.AIRPLAY
Expand Down Expand Up @@ -650,9 +653,11 @@ async def play_media(
if len(sonos_player.client.player.group_members) > 1
else []
)
if group_childs:
await self.cmd_unsync_many(group_childs)
await self.mass.players.play_media(airplay.player_id, media)
if group_childs:
self.mass.call_later(1, self.cmd_sync_many, player_id, group_childs)
self.mass.call_later(5, self.cmd_sync_many(player_id, group_childs))
return

if media.queue_id:
Expand Down
2 changes: 1 addition & 1 deletion music_assistant/server/providers/sonos_s1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class SonosPlayerProvider(PlayerProvider):
@property
def supported_features(self) -> tuple[ProviderFeature, ...]:
"""Return the features supported by this Provider."""
return (ProviderFeature.SYNC_PLAYERS, ProviderFeature.PLAYER_GROUP_CREATE)
return (ProviderFeature.SYNC_PLAYERS,)

async def handle_async_init(self) -> None:
"""Handle async initialization of the provider."""
Expand Down

0 comments on commit 8397417

Please sign in to comment.