SoCo: Group broken by Sonos version 10.1

I updated my Sonos to version 10.1 today and noticed that some of my scripts that rely on SoCo seem to have broken.

Seems to be a problem with groups. When trying to find coordinator of a group with

device.group.coordinator.player_name

I get error:

Traceback (most recent call last): File "./test", line 7, in <module> print(device.group.coordinator.player_name) AttributeError: 'NoneType' object has no attribute 'coordinator'

and print(device.group) just gives output of:

None

I’m assuming this is the 10.1 upgrade. Does anybody else see this, and know if it is fixable?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 46 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I found a fix that work in my small network sonos system.

--- soco/core.py	(revision 671937e07d7973b78c0cbee153d4f3ad68ec48c6)
+++ soco/core.py	(date 1554404884029)
@@ -949,7 +949,7 @@
         self._all_zones.clear()
         self._visible_zones.clear()
         # Loop over each ZoneGroup Element
-        for group_element in tree.findall('ZoneGroup'):
+        for group_element in tree.find('ZoneGroups').findall('ZoneGroup'):
             coordinator_uid = group_element.attrib['Coordinator']
             group_uid = group_element.attrib['ID']
             group_coordinator = None

I’m not sure if the ZoneGroups is not multiple.

Same here. soco.discover() returns the empty set.

It looks like the information is still there. Doing a tcpdump whilst running soco.discover() on my 4 speaker system shows this:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
  <s:Body>
    <u:GetZoneGroupStateResponse xmlns:u="urn:schemas-upnp-org:service:ZoneGroupTopology:1">
      <ZoneGroupState>
        <ZoneGroupState>
          <ZoneGroups>
            <ZoneGroup Coordinator='RINCON_347E5C19199001400' ID='RINCON_B8E93799BB7A01400:3441'>
              <ZoneGroupMember UUID='RINCON_B8E93799BB7A01400' Location='http://192.168.0.66:1400/xml/device_description.xml' ZoneName='Living Room' Icon='x-rincon-roomicon:living' Configuration='1' SoftwareVersion='49.2-63270' MinCompatibleVersion='48.0-00000' LegacyCom
patibleVersion='36.0-00000' BootSeq='152' TVConfigurationError='0' HdmiCecAvailable='0' WirelessMode='1' WirelessLeafOnly='0' HasConfiguredSSID='1' ChannelFreq='2452' BehindWifiExtender='0' WifiEnabled='1' Orientation='0' RoomCalibrationState='4' SecureRegState='3' Voice
ConfigState='0' MicEnabled='0' AirPlayEnabled='0' IdleState='0' MoreInfo=''/>
              <ZoneGroupMember UUID='RINCON_949F3E154D0001400' Location='http://192.168.0.70:1400/xml/device_description.xml' ZoneName='Bathroom' Icon='x-rincon-roomicon:bathroom' Configuration='1' SoftwareVersion='49.2-63270' MinCompatibleVersion='48.0-00000' LegacyComp
atibleVersion='36.0-00000' BootSeq='131' TVConfigurationError='0' HdmiCecAvailable='0' WirelessMode='1' WirelessLeafOnly='0' HasConfiguredSSID='1' ChannelFreq='2452' BehindWifiExtender='0' WifiEnabled='1' Orientation='0' RoomCalibrationState='1' SecureRegState='3' VoiceC
onfigState='0' MicEnabled='0' AirPlayEnabled='0' IdleState='0' MoreInfo=''/>
              <ZoneGroupMember UUID='RINCON_5CAAFD432E9401400' Location='http://192.168.0.69:1400/xml/device_description.xml' ZoneName='Bedroom' Icon='x-rincon-roomicon:bedroom' Configuration='1' SoftwareVersion='49.2-63270' MinCompatibleVersion='48.0-00000' LegacyCompat
ibleVersion='36.0-00000' BootSeq='197' TVConfigurationError='0' HdmiCecAvailable='0' WirelessMode='1' WirelessLeafOnly='0' HasConfiguredSSID='1' ChannelFreq='2452' BehindWifiExtender='0' WifiEnabled='1' Orientation='0' RoomCalibrationState='1' SecureRegState='3' VoiceCon
figState='0' MicEnabled='0' AirPlayEnabled='0' IdleState='0' MoreInfo=''/>
              <ZoneGroupMember UUID='RINCON_347E5C19199001400' Location='http://192.168.0.71:1400/xml/device_description.xml' ZoneName='Kitchen' Icon='x-rincon-roomicon:kitchen' Configuration='1' SoftwareVersion='49.2-63270' MinCompatibleVersion='48.0-00000' LegacyCompat
ibleVersion='36.0-00000' BootSeq='24' TVConfigurationError='0' HdmiCecAvailable='0' WirelessMode='1' WirelessLeafOnly='0' HasConfiguredSSID='1' ChannelFreq='2452' BehindWifiExtender='0' WifiEnabled='1' Orientation='0' RoomCalibrationState='4' SecureRegState='3' VoiceConf
igState='0' MicEnabled='0' AirPlayEnabled='0' IdleState='0' MoreInfo=''/>
            </ZoneGroup>
          </ZoneGroups>
          <VanishedDevices></VanishedDevices>
        </ZoneGroupState>
      </ZoneGroupState>
    </u:GetZoneGroupStateResponse>
  </s:Body>
</s:Envelope>

I’m guessing the format has changed? Unfortunately my python coding is very poor so looking at the code is not helping me figure this out.

I had to install pip in the normal python terminal and after that i could install soco. Now i can run the python file. (: It will alsow run on my computer startup now. Thank you soo much for the Help!

I merged the fix as applied in #662. I will see about doing a release fast.

@jnth - great, your fix works for me - thanks

@DrKeks - yes, this is part of the soco files. Find where your installation is. Mine is in /usr/lib/python3.6/site-packages/soco, but yours might vary depending on python version and general set-up. You are specifically looking for a file called core.py. Copy the patch code from @jnth’s post above and paste it in a file called patch.txt in the directory you’ve just found. Then run:

patch < patch.txt