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
22 changes: 15 additions & 7 deletions custom_components/mass_queue/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ async def player_queue(
except IndexError:
offset = 0
offset = max(offset, 0)
return queue[offset : offset + limit]
return queue[offset : offset + limit] if queue else []

async def update_queue_items(self, queue_id: str):
"""Update the queue items for a single queue."""
Expand All @@ -213,11 +213,19 @@ async def get_queue(
except IndexError:
offset = 0
offset = max(offset, 0)
return await self._client.player_queues.get_player_queue_items(
queue_id=queue_id,
limit=limit,
offset=offset,
)
# HA 2025.12 Fix: `get_player_queue_items` replaced with `get_queue_items`
try:
return await self._client.player_queues.get_queue_items(
queue_id=queue_id,
limit=limit,
offset=offset,
)
except AttributeError:
return await self._client.player_queues.get_player_queue_items(
queue_id=queue_id,
limit=limit,
offset=offset,
)

async def get_active_queue(self, queue_id: str):
"""Get the active queue for a single queue."""
Expand Down Expand Up @@ -308,7 +316,7 @@ def __init__(

def get(self, queue_id):
"""Returns cached queue records."""
return self.queues[queue_id]
return self.queues.get(queue_id, [])

def add(self, queue_id: str, queue_items: int):
"""Adds a single queue."""
Expand Down
8 changes: 4 additions & 4 deletions custom_components/mass_queue/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from homeassistant.helpers import aiohttp_client
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.template import device_id

if TYPE_CHECKING:
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -299,9 +298,10 @@ def get_entity_info(hass: HomeAssistant, entity_id: str):
"""Gets the server and client info for a given player."""
client = get_mass_client(hass, entity_id)
state = hass.states.get(entity_id)
registry = dr.async_get(hass)
dev_id = device_id(hass, entity_id)
dev = registry.async_get(dev_id)
device_registry = dr.async_get(hass)
entity_registry = er.async_get(hass)
dev_id = entity_registry.async_get(entity_id).device_id
dev = device_registry.async_get(dev_id)
identifiers = dev.identifiers

player_id = [_id[1] for _id in identifiers if _id[0] == "music_assistant"][0]
Expand Down
Loading