@@ -351,6 +351,9 @@ async def force_update_sync_status(self, on_updated_cb=None, raise_timeout=False
351
351
self ._group_list = new_device_group
352
352
353
353
else :
354
+ # Device is a master
355
+ _LOGGER .debug ("Device is independent: %s" , self ._id )
356
+
354
357
self ._is_master = False
355
358
self ._master = None
356
359
self ._group_list = []
@@ -485,13 +488,6 @@ async def async_update_status(self):
485
488
group_name = self ._status .get ("groupName" )
486
489
self ._group_name = group_name
487
490
488
- # rebuild ordered list of entity_ids that are in the group, master is first
489
- # self._group_list = await self.rebuild_bluesound_group()
490
-
491
- # the sleep is needed to make sure that the
492
- # devices is synced
493
- # await asyncio.sleep(1)
494
-
495
491
await self .async_trigger_sync_on_all ()
496
492
497
493
if self .is_grouped :
@@ -502,7 +498,6 @@ async def async_update_status(self):
502
498
# the device is playing. This would solve a lot of
503
499
# problems. This change will be done when the
504
500
# communication is moved to a separate library
505
- await asyncio .sleep (1 )
506
501
await self .force_update_sync_status ()
507
502
508
503
self .async_write_ha_state ()
@@ -922,6 +917,9 @@ def extra_state_attributes(self):
922
917
923
918
async def async_join (self , master ):
924
919
"""Join the player to a group."""
920
+
921
+ _LOGGER .debug ("Device '%s' joining master '%s'." , self ._id , master )
922
+
925
923
master_device = [
926
924
device
927
925
for device in self .hass .data [DATA_BLUESOUND ]
@@ -939,8 +937,7 @@ async def async_join(self, master):
939
937
else :
940
938
_LOGGER .error ("Master not found %s" , master_device )
941
939
942
- # the sleep is needed to make sure that the devices are synced
943
- await asyncio .sleep (1 )
940
+ _LOGGER .debug ("Syncing all devices." )
944
941
945
942
# rebuild ordered list of entity_ids that are in the group, master is first
946
943
await self .async_trigger_sync_on_all ()
@@ -949,24 +946,25 @@ async def async_unjoin(self):
949
946
"""Unjoin the player from a group."""
950
947
if self ._master is None :
951
948
return
952
-
953
- _LOGGER .debug ("Trying to unjoin player: %s" , self .id )
949
+
950
+ _LOGGER .debug ("Trying to unjoin player from group : %s" , self .id )
954
951
await self ._master .async_remove_slave (self )
955
952
956
- # the sleep is needed to make sure that the devices are synced
957
- await asyncio .sleep (1 )
953
+ _LOGGER .debug ("Syncing all devices." )
958
954
959
955
# rebuild ordered list of entity_ids that are in the group, master is first
960
956
await self .async_trigger_sync_on_all ()
961
957
962
958
async def async_add_slave (self , slave_device ):
963
959
"""Add slave to master."""
960
+
961
+ _LOGGER .debug ("Master '%s' is adding slave '%s'." , self ._id , slave_device ._id )
962
+
964
963
result = await self .send_bluesound_command (
965
964
f"/AddSlave?slave={ slave_device .host } &port={ slave_device .port } "
966
965
)
967
966
968
- # the sleep is needed to make sure that the devices are synced
969
- await asyncio .sleep (1 )
967
+ _LOGGER .debug ("Syncing all devices." )
970
968
971
969
# rebuild ordered list of entity_ids that are in the group, master is first
972
970
await self .async_trigger_sync_on_all ()
@@ -975,12 +973,14 @@ async def async_add_slave(self, slave_device):
975
973
976
974
async def async_remove_slave (self , slave_device ):
977
975
"""Remove slave to master."""
976
+
977
+ _LOGGER .debug ("Master '%s' is removing slave '%s'." , self ._id , slave_device ._id )
978
+
978
979
result = await self .send_bluesound_command (
979
980
f"/RemoveSlave?slave={ slave_device .host } &port={ slave_device .port } "
980
981
)
981
982
982
- # the sleep is needed to make sure that the devices are synced
983
- await asyncio .sleep (1 )
983
+ _LOGGER .debug ("Syncing all devices." )
984
984
985
985
# rebuild ordered list of entity_ids that are in the group, master is first
986
986
await self .async_trigger_sync_on_all ()
0 commit comments