Skip to content

Commit

Permalink
Fix transfer queue
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Oct 22, 2024
1 parent 70835b1 commit e6f914c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions custom_components/mass/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,10 @@ async def _async_transfer_queue(
) -> None:
"""Transfer the current queue to another player."""
if not source_player:
# no source player given; try to find a playing player
# no source player given; try to find a playing player(queue)
for queue in self.mass.player_queues:
if queue.state == PlayerState.PLAYING:
mass_queue_id = queue.queue_id
source_queue_id = queue.queue_id
break
else:
raise HomeAssistantError(
Expand All @@ -561,11 +561,12 @@ async def _async_transfer_queue(
# resolve HA entity_id to MA player_id
if (hass_state := self.hass.states.get(source_player)) is None:
return # guard
if (mass_queue_id := hass_state.attributes.get("mass_player_id")) is None:
if (source_queue_id := hass_state.attributes.get("mass_player_id")) is None:
return # guard

target_queue_id = self.player_id
await self.mass.player_queues.transfer_queue(
mass_queue_id, queue.queue_id, auto_play
source_queue_id, target_queue_id, auto_play
)

async def async_browse_media(
Expand Down

0 comments on commit e6f914c

Please sign in to comment.