soco.groups module

This module contains classes and functionality relating to Sonos Groups.

class soco.groups.ZoneGroup(uid, coordinator, members=None)[source]

A class representing a Sonos Group. It looks like this:

ZoneGroup(
    uid='RINCON_000FD584236D01400:58',
    coordinator=SoCo("192.168.1.101"),
    members=set([SoCo("192.168.1.101"), SoCo("192.168.1.102")])
)

Any SoCo instance can tell you what group it is in:

>>> device = soco.discovery.any_soco()
>>> device.group
ZoneGroup(
    uid='RINCON_000FD584236D01400:58',
    coordinator=SoCo("192.168.1.101"),
    members=set([SoCo("192.168.1.101"), SoCo("192.168.1.102")])
)

From there, you can find the coordinator for the current group:

>>> device.group.coordinator
SoCo("192.168.1.101")

or, for example, its name:

>>> device.group.coordinator.player_name
Kitchen

or a set of the members:

>>> device.group.members
{SoCo("192.168.1.101"), SoCo("192.168.1.102")}

For convenience, ZoneGroup is also a container:

>>> for player in device.group:
...   print player.player_name
Living Room
Kitchen

If you need it, you can get an iterator over all groups on the network:

>>> device.all_groups
<generator object all_groups at 0x108cf0c30>

A consistent readable label for the group members can be returned with the label and short_label properties.

Parameters:
  • uid (str) – The unique Sonos ID for this group, eg RINCON_000FD584236D01400:5.
  • coordinator (SoCo) – The SoCo instance representing the coordinator of this group.
  • members (Iterable[SoCo]) – An iterable containing SoCo instances which represent the members of this group.
uid = None

The unique Sonos ID for this group

coordinator = None

The SoCo instance which coordinates this group

members = None

A set of SoCo instances which are members of the group

label

str – A description of the group.

>>> device.group.label
'Kitchen, Living Room'
short_label

str – A short description of the group.

>>> device.group.short_label
'Kitchen + 1'