Sonos Python 3 Beta

Posted on
Fri Jun 02, 2023 7:48 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Sonos Python 3 Beta

ryanbuckner wrote:
Should I remove and re-add my Sonos devices? Error log is flooded.

I am still investigating this problem.

Is the error just occurring on two speakers i.e the ones at 192.168.1.175 and 192.168.1.177 as shown in your log extract?

Also, I note that you appear to have Pandora enabled - this won't work at the moment. So suggest you disable that in the plugin config.

When you say flooded, I guess you are getting repeat errors?

Not sure removing and re-adding speakers will help but maybe worth a try if it doesn't cause you any issues with Control Pages and Actions etc. If it would, I suggest not to remove them.

Posted on
Fri Jun 02, 2023 7:57 am
neilk offline
Posts: 722
Joined: Jul 13, 2015
Location: Reading, UK

Re: Sonos Python 3 Beta

Jon - it did fix the first one, but still an issue with Polly, but I took the liberty of fixing it, with the two changes below in Sonos.py which I think make sense (and I have tested and it does now work).

From

Code: Select all
2518                            f = open("announcement.mp3", "w+")
2519                            data = data_bytes.decode("utf-8")


to
Code: Select all
2518                            f = open("announcement.mp3", "wb+")
2519                            data = data_bytes

Posted on
Fri Jun 02, 2023 9:08 am
neilk offline
Posts: 722
Joined: Jul 13, 2015
Location: Reading, UK

Re: Sonos Python 3 Beta

Sorry found another one. I was testing playing a favourite and I get the following :-

Code: Select all
Action Group                    play bbc radio 5 live
   Sonos Error                     'module 'urllib' has no attribute 'quote'' in module 'Sonos.py', method 'actionDirect'
   Failing statement [line 2212]: 'self.SOAPSend (zoneIP, "/MediaRenderer", "/AVTransport", "SetAVTransportURI", "<CurrentURI>x-sonosapi-hls:" + urllib.quote(contentId) + "?sid=37&amp;flags=8480&amp;sn=8</CurrentURI><CurrentURIMetaData>&lt;DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\" xmlns:r=\"urn:schemas-rinconnetworks-com:metadata-1-0/\" xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"&gt;&lt;item id=\"" + contentId + "\" parentID=\"0\" restricted=\"true\"&gt;&lt;dc:title&gt;" + title +  "&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast&lt;/upnp:class&gt;&lt;desc id=\"cdudn\" nameSpace=\"urn:schemas-rinconnetworks-com:metadata-1-0/\"&gt;SA_RINCON6_&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData>")'


Which I think just needs to be updated to include "url lib.parse.quote" for python 3 but I am no expert

Code: Select all
2212                        self.SOAPSend (zoneIP, "/MediaRenderer", "/AVTransport", "SetAVTransportURI", "<CurrentURI>x-sonosapi-hls:" + urllib.parse.quote(contentId) + "?sid=37&amp;flags=8480&amp;sn=8</CurrentURI><CurrentURIMetaData>&lt;DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\" xmlns:r=\"urn:schemas-rinconnetworks-com:metadata-1-0/\" xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"&gt;&lt;item id=\"" + contentId + "\" parentID=\"0\" restricted=\"true\"&gt;&lt;dc:title&gt;" + title +  "&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast&lt;/upnp:class&gt;&lt;desc id=\"cdudn\" nameSpace=\"urn:schemas-rinconnetworks-com:metadata-1-0/\"&gt;SA_RINCON6_&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData>")


But when I do, I then get a different error

Code: Select all
Sonos Error                     'local variable 'title' referenced before assignment' in module 'Sonos.py', method 'actionDirect'
   Failing statement [line 2212]: 'self.SOAPSend (zoneIP, "/MediaRenderer", "/AVTransport", "SetAVTransportURI", "<CurrentURI>x-sonosapi-hls:" + urllib.parse.quote(contentId) + "?sid=37&amp;flags=8480&amp;sn=8</CurrentURI><CurrentURIMetaData>&lt;DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\" xmlns:r=\"urn:schemas-rinconnetworks-com:metadata-1-0/\" xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"&gt;&lt;item id=\"" + contentId + "\" parentID=\"0\" restricted=\"true\"&gt;&lt;dc:title&gt;" + title +  "&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast&lt;/upnp:class&gt;&lt;desc id=\"cdudn\" nameSpace=\"urn:schemas-rinconnetworks-com:metadata-1-0/\"&gt;SA_RINCON6_&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData>")'



So before I broke anything I thought I would raise it.

Neil

Posted on
Fri Jun 02, 2023 9:52 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Sonos Python 3 Beta

Hi Neil,
neilk wrote:
Jon - it did fix the first one, but still an issue with Polly, but I took the liberty of fixing it, with the two changes below in Sonos.py which I think make sense (and I have tested and it does now work). ...

Thanks for this, I will incorporate your changes into the next point release. :D

Posted on
Fri Jun 02, 2023 9:53 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Sonos Python 3 Beta

Hi Neil,
neilk wrote:
Sorry found another one.

OK - thanks for the report, I will add it to the investigation list! :)

Posted on
Fri Jun 02, 2023 10:44 am
ryanbuckner offline
Posts: 1081
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Sonos Python 3 Beta

autolog wrote:
ryanbuckner wrote:
Should I remove and re-add my Sonos devices? Error log is flooded.

I am still investigating this problem.

Is the error just occurring on two speakers i.e the ones at 192.168.1.175 and 192.168.1.177 as shown in your log extract?

Also, I note that you appear to have Pandora enabled - this won't work at the moment. So suggest you disable that in the plugin config.

When you say flooded, I guess you are getting repeat errors?

Not sure removing and re-adding speakers will help but maybe worth a try if it doesn't cause you any issues with Control Pages and Actions etc. If it would, I suggest not to remove them.


Correct, the errors repeat every few seconds. I do have Pandora disabled.

The two speakers that are listed in the error logs are Play 1s that have been paired together for surround sound.. I disabled those speakers and restarted. Most of the errors went away, and now I only see these :

Code: Select all
Jun 2, 2023 at 12:41:47 PM
   Enabling plugin "Sonos 2023.0.7" using API v3.1
   Starting plugin "Sonos 2023.0.7" (pid 72983)
   Started plugin "Sonos 2023.0.7"
   Sonos                           Loaded Sonos Favorites... [9]
   Sonos                           Loaded Playlists... [5]
   Sonos                           Loaded RadioTime Favorite Stations... [0]
   Sonos Error                     [Fri Jun  2 12:41:50 2023] SiriusXM SessionID communications error
   Sonos                           [Fri Jun  2 12:41:50 2023] Processed plugin preferences.
   Sonos                           Loaded Apple Voices.. [48]
   Sonos                           SSDP Listener Started...
   Sonos                           Serving HTTP Streamer on 127.0.0.1 [0.0.0.0], port 8888
   Sonos                           Adding ZonePlayer: 192.168.1.239, RINCON_542A1B8620EE01400, SONOS - Basement Beam
   Sonos                           Adding ZonePlayer: 192.168.1.243, RINCON_7828CA1451B601400, SONOS - Dining Room Speaker
   Sonos                           Adding ZonePlayer: 192.168.1.191, RINCON_5CAAFD5A966601400, SONOS - Family Room Speaker
   Sonos                           Adding ZonePlayer: 192.168.1.188, RINCON_7828CAABC54401400, SONOS - Kitchen Speaker
   Sonos                           Adding ZonePlayer: 192.168.1.193, RINCON_5CAAFDE8718C01400, SONOS - Patio Speakers
   Sonos                           SoCo Reactor Ignition...
   Sonos Error                     ''str' object has no attribute 'decode'' in module 'Sonos.py', method 'soco_event_audio_in'
   Failing statement [line 1304]: 'self.updateStateOnServer(dev, "ZP_AIName", val.decode('utf-8'))'
   Sonos                           Loaded Playlists... [5]
   Sonos                           Loaded Playlists... [5]


So while there are still some errors, paired speakers are definitely causing the larger problem.

Posted on
Fri Jun 02, 2023 11:40 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Sonos Python 3 Beta

ryanbuckner wrote:
... So while there are still some errors, paired speakers are definitely causing the larger problem.


Thanks for the continued testing and further feedback. :)

I hope to make more progress on resolving some of the issues you have identified tomorrow. Unfortunately, I wasn't able to devote as much time as I wanted to do on this today.

Posted on
Fri Jun 02, 2023 11:47 am
ryanbuckner offline
Posts: 1081
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Sonos Python 3 Beta

autolog wrote:
ryanbuckner wrote:
... So while there are still some errors, paired speakers are definitely causing the larger problem.


Thanks for the continued testing and further feedback. :)

I hope to make more progress on resolving some of the issues you have identified tomorrow. Unfortunately, I wasn't able to devote as much time as I wanted to do on this today.


Appreciate the time you're devoting. I'll continue to test

Posted on
Fri Jun 02, 2023 3:50 pm
Colly offline
Posts: 541
Joined: Jan 16, 2016
Location: Ireland

Re: Sonos Python 3 Beta

Hi Jon,
Went through the install process tonight and after following all of the recommended installations I ended up with this in the log
Code: Select all
    Sonos Error                     Error in plugin execution InitializeMain:

  File "plugin.py", line 34, in <module>
  File "/Library/Application Support/Perceptive Automation/Indigo 2022.2/Plugins/Sonos.indigoPlugin/Contents/Server Plugin/Sonos.py", line 80, in <module>
  File "/Library/Application Support/Perceptive Automation/Indigo 2022.2/Plugins/Sonos.indigoPlugin/Contents/Server Plugin/soco/__init__.py", line 11, in <module>
  File "/Library/Application Support/Perceptive Automation/Indigo 2022.2/Plugins/Sonos.indigoPlugin/Contents/Server Plugin/soco/core.py", line 14, in <module>
type: No module named 'xmltodict'

Ready when you are for some troubleshooting. :D
Colly

Posted on
Fri Jun 02, 2023 4:28 pm
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Sonos Python 3 Beta

Hi Colly,
Download the latest version 2023.0.7: Sonos Plugin

It will check for xmltodict and ask you to do a pip3.10 install xmltodict if not present.

This omission was corrected in version .6 :)

I will look at adding an announcement that is kept up-to-date with latest builds. :wink:

Posted on
Fri Jun 02, 2023 4:41 pm
Colly offline
Posts: 541
Joined: Jan 16, 2016
Location: Ireland

Re: Sonos Python 3 Beta

Upgraded to latest version, same error in log. It didn't prompt me to install anything, I did as suggested and now the plugin is running, Quick test and I'm able to play/pause.
Thanks for your efforts on getting this up and running.

Posted on
Sat Jun 03, 2023 2:49 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Sonos Python 3 Beta

Hi Neil,
neilk wrote:
Code: Select all
Action Group                    play bbc radio 5 live
   Sonos Error                     'module 'urllib' has no attribute 'quote'' in module 'Sonos.py', method 'actionDirect'
   Failing statement [line 2212]: 'self.SOAPSend (zoneIP, "/MediaRenderer", "/AVTransport", "SetAVTransportURI", "<CurrentURI>x-sonosapi-hls:" + urllib.quote(contentId) + "?sid=37&amp;flags=8480&amp;sn=8</CurrentURI><CurrentURIMetaData>&lt;DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\" xmlns:r=\"urn:schemas-rinconnetworks-com:metadata-1-0/\" xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"&gt;&lt;item id=\"" + contentId + "\" parentID=\"0\" restricted=\"true\"&gt;&lt;dc:title&gt;" + title +  "&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast&lt;/upnp:class&gt;&lt;desc id=\"cdudn\" nameSpace=\"urn:schemas-rinconnetworks-com:metadata-1-0/\"&gt;SA_RINCON6_&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData>")'


Which I think just needs to be updated to include "url lib.parse.quote" for python 3 but I am no expert

Code: Select all
2212                        self.SOAPSend (zoneIP, "/MediaRenderer", "/AVTransport", "SetAVTransportURI", "<CurrentURI>x-sonosapi-hls:" + urllib.parse.quote(contentId) + "?sid=37&amp;flags=8480&amp;sn=8</CurrentURI><CurrentURIMetaData>&lt;DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\" xmlns:r=\"urn:schemas-rinconnetworks-com:metadata-1-0/\" xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"&gt;&lt;item id=\"" + contentId + "\" parentID=\"0\" restricted=\"true\"&gt;&lt;dc:title&gt;" + title +  "&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast&lt;/upnp:class&gt;&lt;desc id=\"cdudn\" nameSpace=\"urn:schemas-rinconnetworks-com:metadata-1-0/\"&gt;SA_RINCON6_&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData>")


But when I do, I then get a different error

Code: Select all
Sonos Error                     'local variable 'title' referenced before assignment' in module 'Sonos.py', method 'actionDirect'
   Failing statement [line 2212]: 'self.SOAPSend (zoneIP, "/MediaRenderer", "/AVTransport", "SetAVTransportURI", "<CurrentURI>x-sonosapi-hls:" + urllib.parse.quote(contentId) + "?sid=37&amp;flags=8480&amp;sn=8</CurrentURI><CurrentURIMetaData>&lt;DIDL-Lite xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:upnp=\"urn:schemas-upnp-org:metadata-1-0/upnp/\" xmlns:r=\"urn:schemas-rinconnetworks-com:metadata-1-0/\" xmlns=\"urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/\"&gt;&lt;item id=\"" + contentId + "\" parentID=\"0\" restricted=\"true\"&gt;&lt;dc:title&gt;" + title +  "&lt;/dc:title&gt;&lt;upnp:class&gt;object.item.audioItem.audioBroadcast&lt;/upnp:class&gt;&lt;desc id=\"cdudn\" nameSpace=\"urn:schemas-rinconnetworks-com:metadata-1-0/\"&gt;SA_RINCON6_&lt;/desc&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;</CurrentURIMetaData>")'


Thanks for the url lib.parse.quote correction. :)

I can see why the title might be causing an issue. What I don't understand is why the SiriusXM logic which is failing is being executed?

What action is your Action Group play bbc radio 5 live performing?

Posted on
Sat Jun 03, 2023 3:14 am
neilk offline
Posts: 722
Joined: Jul 13, 2015
Location: Reading, UK

Re: Sonos Python 3 Beta

Sorry Jon, would have been helpful to state what it was

It is playing a favourite, and indeed I was confused about the SiriusXM thing as of course not relevant to my install or what I was trying.

It will teach me to think I am clever and had spotted the issue


The favourite works from the Sonos App

Thanks,

Neil

Posted on
Sat Jun 03, 2023 3:31 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Sonos Python 3 Beta

Hi Neil,
I am now more confused :? , :D

Is there a problem with favourites that I should be looking at?

You say it works from the Sonos App but not in the plugin?

Posted on
Sat Jun 03, 2023 3:38 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Sonos Python 3 Beta

Colly wrote:
Upgraded to latest version, same error in log. It didn't prompt me to install anything, ...

Thanks for the report. :)

Just retested this and indeed it didn't work!
I have found the error and it will be corrected in the .8 release.

Who is online

Users browsing this forum: No registered users and 3 guests