diff --git a/custom_components/bluesound_alt/media_player.py b/custom_components/bluesound_alt/media_player.py index 3425f75..1f94436 100644 --- a/custom_components/bluesound_alt/media_player.py +++ b/custom_components/bluesound_alt/media_player.py @@ -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 = [] @@ -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] @@ -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() @@ -949,18 +957,23 @@ 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}" ) @@ -968,6 +981,8 @@ async def async_add_slave(self, slave_device): # 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() @@ -975,6 +990,9 @@ async def async_add_slave(self, slave_device): 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}" ) @@ -982,6 +1000,8 @@ async def async_remove_slave(self, slave_device): # 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()