Skip to content

Commit

Permalink
Fix race condition where provider is not yet available at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Nov 21, 2024
1 parent da17da1 commit 1900922
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion custom_components/mass/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, mass: MusicAssistantClient, player_id: str) -> None:
self.mass = mass
self.player_id = player_id
player = mass.players.get(player_id)
provider = self.mass.get_provider(player.provider)
provider = self.mass.get_provider(player.provider, True)
if TYPE_CHECKING:
assert provider is not None

Expand Down
4 changes: 3 additions & 1 deletion custom_components/mass/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
from music_assistant_models.player import Player
from music_assistant_models.player_queue import PlayerQueue

from . import MusicAssistantConfigEntry

SUPPORTED_FEATURES = (
MediaPlayerEntityFeature.PAUSE
| MediaPlayerEntityFeature.VOLUME_SET
Expand Down Expand Up @@ -126,7 +128,7 @@ async def wrapper(

async def async_setup_entry(
hass: HomeAssistant,
entry: MusicAssistantBaseEntity,
entry: MusicAssistantConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Music Assistant MediaPlayer(s) from Config Entry."""
Expand Down

0 comments on commit 1900922

Please sign in to comment.