Skip to content

Commit

Permalink
More logging
Browse files Browse the repository at this point in the history
  • Loading branch information
aunefyren committed Feb 3, 2024
1 parent 389cced commit ec8222a
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions custom_components/bluesound_alt/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ async def force_update_sync_status(self, on_updated_cb=None, raise_timeout=False
self._group_list = new_device_group

else:
# Device is a master
_LOGGER.debug("Device is independent: %s", self._id)

self._is_master = False
self._master = None
self._group_list = []
Expand Down Expand Up @@ -922,6 +925,9 @@ def extra_state_attributes(self):

async def async_join(self, master):
"""Join the player to a group."""

_LOGGER.debug("Device '%s' joining master '%s'.", self._id, master._id)

master_device = [
device
for device in self.hass.data[DATA_BLUESOUND]
Expand All @@ -941,6 +947,8 @@ async def async_join(self, master):

# the sleep is needed to make sure that the devices are synced
# await asyncio.sleep(1)

_LOGGER.debug("Syncing all devices.")

# rebuild ordered list of entity_ids that are in the group, master is first
await self.async_trigger_sync_on_all()
Expand All @@ -949,39 +957,51 @@ async def async_unjoin(self):
"""Unjoin the player from a group."""
if self._master is None:
return

_LOGGER.debug("Trying to unjoin player: %s", self.id)
_LOGGER.debug("Trying to unjoin player from group: %s", self.id)
await self._master.async_remove_slave(self)

# the sleep is needed to make sure that the devices are synced
# await asyncio.sleep(1)

_LOGGER.debug("Syncing all devices.")

# rebuild ordered list of entity_ids that are in the group, master is first
await self.async_trigger_sync_on_all()

async def async_add_slave(self, slave_device):
"""Add slave to master."""

_LOGGER.debug("Master '%s' is adding slave '%s'.", self._id)

result = await self.send_bluesound_command(
f"/AddSlave?slave={slave_device.host}&port={slave_device.port}"
)

# the sleep is needed to make sure that the devices are synced
# await asyncio.sleep(1)

_LOGGER.debug("Syncing all devices.")

# rebuild ordered list of entity_ids that are in the group, master is first
await self.async_trigger_sync_on_all()

return result

async def async_remove_slave(self, slave_device):
"""Remove slave to master."""

_LOGGER.debug("Master '%s' is removing slave '%s'.", self._id)

result = await self.send_bluesound_command(
f"/RemoveSlave?slave={slave_device.host}&port={slave_device.port}"
)

# the sleep is needed to make sure that the devices are synced
# await asyncio.sleep(1)

_LOGGER.debug("Syncing all devices.")

# rebuild ordered list of entity_ids that are in the group, master is first
await self.async_trigger_sync_on_all()

Expand Down

0 comments on commit ec8222a

Please sign in to comment.