Skip to content

Commit 9cd7ed1

Browse files
committed
Merge pull request SoCo#166 from lawrenceakka/is_coordinator
is_coordinator added
2 parents 445b36b + c24391c commit 9cd7ed1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

soco/core.py

+18
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ def __init__(self, ip_address):
232232
self._all_zones = set()
233233
self._groups = set()
234234
self._is_bridge = None
235+
self._is_coordinator = False
235236
self._player_name = None
236237
self._uid = None
237238
self._visible_zones = set()
@@ -314,6 +315,20 @@ def is_bridge(self):
314315
self._parse_zone_group_state()
315316
return self._is_bridge
316317

318+
@property
319+
def is_coordinator(self):
320+
""" Return True if this zone is a group coordinator, otherwise False.
321+
322+
return True or False
323+
324+
"""
325+
# We could do this:
326+
# invisible = self.deviceProperties.GetInvisible()['CurrentInvisible']
327+
# but it is better to do it in the following way, which uses the
328+
# zone group topology, to capitalise on any caching.
329+
self._parse_zone_group_state()
330+
return self._is_coordinator
331+
317332
@property
318333
def play_mode(self):
319334
""" The queue's play mode. Case-insensitive options are::
@@ -721,6 +736,9 @@ def _parse_zone_group_state(self):
721736
# the coordinator
722737
if zone._uid == coordinator_uid:
723738
group_coordinator = zone
739+
zone._is_coordinator = True
740+
else:
741+
zone._is_coordinator = False
724742
zone._player_name = member_attribs['ZoneName']
725743
# uid and is_bridge do not change, but it does no real harm to
726744
# set/reset them here, just in case the zone has not been seen

0 commit comments

Comments
 (0)