Skip to content

Commit

Permalink
Fix join action
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Nov 6, 2024
1 parent ca681c8 commit ca13751
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions custom_components/mass/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,18 @@ async def async_play_media(
async def async_join_players(self, group_members: list[str]) -> None:
"""Join `group_members` as a player group with the current player."""
player_ids: list[str] = []
entity_registry = er.async_get(self.hass)
for child_entity_id in group_members:
# resolve HA entity_id to MA player_id
if (hass_state := self.hass.states.get(child_entity_id)) is None:
continue
if (mass_player_id := hass_state.attributes.get("mass_player_id")) is None:
if (not hass_state.attributes.get(ATTR_MASS_PLAYER_TYPE)) is None:
continue
player_ids.append(mass_player_id)
if not (entity_reg_entry := entity_registry.async_get(child_entity_id)):
# can not happen, but guard for typing
continue
# unique id is the player_id
player_ids.append(entity_reg_entry.unique_id[5:])
await self.mass.players.player_command_sync_many(self.player_id, player_ids)

@catch_musicassistant_error
Expand Down

0 comments on commit ca13751

Please sign in to comment.