Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion custom_components/mass_queue/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,18 @@ async def get_recommendations(self, providers: list | None = None):
recs = await self._client.music.recommendations()
if not providers:
return recs
return [rec for rec in recs if rec.provider in providers]
rec_providers = []
for rec in recs:
if rec.provider not in rec_providers:
rec_providers.append(rec.provider)

used_rec_providers = [
rec_provider
for rec_provider in rec_providers
for provider in providers
if rec_provider.startswith(provider)
]
return [rec for rec in recs if rec.provider in used_rec_providers]

async def get_grouped_volume(self, player_id: str):
"""Get the grouped volume for a given player."""
Expand Down
2 changes: 1 addition & 1 deletion custom_components/mass_queue/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"issue_tracker": "https://github.com/droans/mass_queue/issues",
"requirements": ["music-assistant-client"],
"ssdp": [],
"version": "0.9.1",
"version": "0.9.2",
"zeroconf": ["_mass._tcp.local."]
}
11 changes: 5 additions & 6 deletions custom_components/mass_queue/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def _get_config_entry(
def get_mass_queue_entry(hass, entity_id):
"""Gets the actions for the selected entity."""
mass_entry = get_mass_entry(hass, entity_id)
mass = mass_entry.runtime_data.mass.connection.ws_server_url
return find_mass_queue_entry(hass, mass)
unique_id = mass_entry.unique_id
return find_mass_queue_entry_from_unique_id(hass, unique_id)


def get_entity_actions_controller(hass, entity_id):
Expand All @@ -69,14 +69,13 @@ def _get_mass_entity_config_entry_id(hass, entity_id):
return registry.async_get(entity_id).config_entry_id


def find_mass_queue_entry(hass, mass_url):
def find_mass_queue_entry_from_unique_id(hass: HomeAssistant, unique_id: str):
"""Finds the mass_queue entry for the given MA URL."""
entries = _get_mass_queue_entries(hass)
for entry in entries:
entry_url = entry.runtime_data.mass.connection.ws_server_url
if entry_url == mass_url:
if entry.unique_id == unique_id:
return entry
msg = f"Cannot find entry for Music Assistant at {mass_url}"
msg = f"Cannot find entry for Music Assistant with unique ID {unique_id}"
raise ServiceValidationError(msg)


Expand Down
Loading