Sonos Python 3 Beta

Posted on
Thu Jun 01, 2023 10:16 am
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Sonos Python 3 Beta

Please post questions | feedback on the Sonos Python 3 beta to this thread. :)

Posted on
Thu Jun 01, 2023 11:02 am
Colly offline
Posts: 535
Joined: Jan 16, 2016
Location: Ireland

Re: Sonos Python 3 Beta

Yippee. Will try later tonight.


Sent from my iPhone using Tapatalk

Posted on
Thu Jun 01, 2023 12:26 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Sonos Python 3 Beta

Indigo version: Indigo 2022.2.2

Here are the packages I was prompted to install:

Code: Select all
pip3.10 install boto3
pip3.10 install gTTS
pip3.10 install pyvona
pip3.10 install Twisted

Upon installation of each of these I reloaded the plugin and received this error:
Code: Select all
Jun 1, 2023 at 2:25:42 PM
   Reloading plugin "Sonos 2023.0.5" using API v3.1
   Starting plugin "Sonos 2023.0.5" (pid 62928)
   Sonos Error                     Error in plugin execution InitializeMain:

  File "plugin.py", line 23, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twisted/internet/reactor.py", line 38, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twisted/internet/default.py", line 55, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twisted/internet/default.py", line 49, in _getInstallFunction
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twisted/internet/selectreactor.py", line 18, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twisted/internet/posixbase.py", line 16, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twisted/internet/tcp.py", line 38, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twisted/internet/_newtls.py", line 18, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/twisted/protocols/tls.py", line 42, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/OpenSSL/__init__.py", line 8, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/OpenSSL/crypto.py", line 3268, in <module>
type: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'

   Stopping plugin "Sonos 2023.0.5" (pid 62928)
   Stopped plugin "Sonos 2023.0.5"


Posted on
Thu Jun 01, 2023 1:21 pm
neilk offline
Posts: 715
Joined: Jul 13, 2015
Location: Reading, UK

Re: Sonos Python 3 Beta

That is great timing, I spent a couple of hours this afternoon looking at this, as this (and evohome) are the last two laggard plugins I have. I will try this tonight.

Posted on
Thu Jun 01, 2023 1:37 pm
neilk offline
Posts: 715
Joined: Jul 13, 2015
Location: Reading, UK

Re: Sonos Python 3 Beta

I have all of the modules sorted, and the pause/ play actions work but I am not getting any updates of the device states (playing, paused etc is blank).

Posted on
Thu Jun 01, 2023 1:42 pm
neilk offline
Posts: 715
Joined: Jul 13, 2015
Location: Reading, UK

Re: Sonos Python 3 Beta

@Ryanbuckner https://levelup.gitconnected.com/fix-attributeerror-module-lib-has-no-attribute-openssl-521a35d83769 looks like it may be (one) of the issues you
are seeing and a resolution.

Neil

Posted on
Thu Jun 01, 2023 2:06 pm
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Sonos Python 3 Beta

Hi Neil,
neilk wrote:
I have all of the modules sorted, and the pause/ play actions work but I am not getting any updates of the device states (playing, paused etc is blank).


Thanks for the feedback :)

Try setting the Event Listener IP address in the plugin config, if not already set?

Posted on
Thu Jun 01, 2023 2:09 pm
neilk offline
Posts: 715
Joined: Jul 13, 2015
Location: Reading, UK

Re: Sonos Python 3 Beta

Sorry - spot on, I had set it but realised my development machine also had wifi active and I had the wrong IP added! I will dig some more. Sorry for the terse earlier message, I think that was premature submission !

Neil

Posted on
Thu Jun 01, 2023 2:14 pm
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 - spot on, I had set it but realised my development machine also had wifi active and I had the wrong IP added! I will dig some more. Sorry for the terse earlier message, I think that was premature submission !

Neil


No problem: I am closing down for this evening; back on the case tomorrow. :D

Posted on
Thu Jun 01, 2023 2:17 pm
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Sonos Python 3 Beta

Hi @ryanbuckner,
neilk wrote:
@Ryanbuckner https://levelup.gitconnected.com/fix-attributeerror-module-lib-has-no-attribute-openssl-521a35d83769 looks like it may be (one) of the issues you are seeing and a resolution.


Thanks for the error report. :)

If Neil's suggestion doesn't resolve the issue, I will follow it up tomorrow morning (UK time) :)

Posted on
Thu Jun 01, 2023 2:26 pm
autolog offline
Posts: 3991
Joined: Sep 10, 2013
Location: West Sussex, UK [GMT aka UTC]

Re: Sonos Python 3 Beta

Just posted a minor fix (2023.0.6) that updates the required packages list and is not related to problems previously reported.: Add Additional Package Requirements

Posted on
Thu Jun 01, 2023 2:46 pm
neilk offline
Posts: 715
Joined: Jul 13, 2015
Location: Reading, UK

Re: Sonos Python 3 Beta

I am trying to get across most of the functionality (at least that I use on my production machine). I did get the issue with the plugin being quarantined when I tested announcements but not before, but the following fixed that

Code: Select all
sudo xattr -rd com.apple.quarantine /Library/Application\ Support/Perceptive\ Automation/Indigo\ 2022.2/Plugins


I also had to add the Streaming IP address as auto did not work for me (the same on my other instance to be fair)

MP3 playback and Apple Text to speech work fine. I also tried my polly key and get the following when trying an announcement

Code: Select all
Sonos Error                     'write() argument must be str, not bytes' in module 'Sonos.py', method 'actionAnnouncement'
   Failing statement [line 2519]: 'f.write(data)'


Which looks like a conversion issue (having chased many similar ones myself)

Thanks so much for picking this one up.

Neil

Posted on
Thu Jun 01, 2023 4:34 pm
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Sonos Python 3 Beta

autolog wrote:
Hi @ryanbuckner,
neilk wrote:
@Ryanbuckner https://levelup.gitconnected.com/fix-attributeerror-module-lib-has-no-attribute-openssl-521a35d83769 looks like it may be (one) of the issues you are seeing and a resolution.


Thanks for the error report. :)

If Neil's suggestion doesn't resolve the issue, I will follow it up tomorrow morning (UK time) :)


Thank you. I followed that path and everything was reported as already fulfilled until I got to this:
Code: Select all
python3 -m pip install cryptography==38.0.4


Now I have a new error
Code: Select all
Jun 1, 2023 at 6:24:28 PM
   Reloading plugin "Sonos 2023.0.5" using API v3.1
   Starting plugin "Sonos 2023.0.5" (pid 64710)
   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'


I installed xmltodict (I'm only listing these steps to help others troubleshoot) and then got this error which may be specific to my SONOS account configuration:
Code: Select all
========> Run 'pip3.10 install pandora' in Terminal window, then reload plugin. <========


Restart:

Code: Select all
Jun 1, 2023 at 6:33:25 PM
   Reloading plugin "Sonos 2023.0.5" using API v3.1
   Starting plugin "Sonos 2023.0.5" (pid 64781)
   Started plugin "Sonos 2023.0.5"
   Sonos                           Loaded Sonos Favorites... [9]
   Sonos                           Loaded Playlists... [5]
   Sonos                           Loaded RadioTime Favorite Stations... [0]
   Sonos Error                     'User not yet authenticated' in module 'pandora.py', method 'check_authentication'
   Failing statement [line 12]: 'raise ValueError("User not yet authenticated")'
   Sonos                           Serving HTTP Streamer on 192.168.1.6 [0.0.0.0], port 8888
   Sonos Error                     [Thu Jun  1 18:33:29 2023] SiriusXM SessionID communications error
   Sonos                           [Thu Jun  1 18:33:29 2023] Processed plugin preferences.
   Sonos                           Loaded Apple Voices.. [48]
   Sonos                           SSDP Listener Started...
   Sonos                           Adding ZonePlayer: 192.168.1.177, RINCON_347E5C12EA7201400, SONOS - Basement (left)
   Sonos                           Adding ZonePlayer: 192.168.1.175, RINCON_347E5C13253401400, SONOS - Basement (right)
   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                     UPNP Error: 500
   Sonos Error                     Offending Command -> zoneIP: 192.168.1.177, soapRoot: /MediaServer, soapBranch: /ContentDirectory, soapAction: Browse
   Sonos Error                     'invalid literal for int() with base 10: ''' in module 'Sonos.py', method 'actionDirect'
   Failing statement [line 1921]: 'if int(ZP) > 0:'
   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 Error                     UPNP Error: 500
   Sonos Error                     Offending Command -> zoneIP: 192.168.1.175, soapRoot: /MediaServer, soapBranch: /ContentDirectory, soapAction: Browse
   Sonos Error                     'invalid literal for int() with base 10: ''' in module 'Sonos.py', method 'actionDirect'
   Failing statement [line 1921]: 'if int(ZP) > 0:'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos                           Loaded Playlists... [5]
   Sonos Error                     UPNP Error: 500
   Sonos Error                     Offending Command -> zoneIP: 192.168.1.177, soapRoot: /MediaServer, soapBranch: /ContentDirectory, soapAction: Browse
   Sonos Error                     'invalid literal for int() with base 10: ''' in module 'Sonos.py', method 'actionDirect'
   Failing statement [line 1921]: 'if int(ZP) > 0:'
   Sonos Error                     UPNP Error: 500
   Sonos Error                     Offending Command -> zoneIP: 192.168.1.175, soapRoot: /MediaServer, soapBranch: /ContentDirectory, soapAction: Browse
   Sonos Error                     'invalid literal for int() with base 10: ''' in module 'Sonos.py', method 'actionDirect'
   Failing statement [line 1921]: 'if int(ZP) > 0:'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos Error                     UPNP Error: 500
   Sonos Error                     Offending Command -> zoneIP: 192.168.1.177, soapRoot: /MediaServer, soapBranch: /ContentDirectory, soapAction: Browse
   Sonos Error                     'invalid literal for int() with base 10: ''' in module 'Sonos.py', method 'actionDirect'
   Failing statement [line 1921]: 'if int(ZP) > 0:'
   Sonos Error                     UPNP Error: 500
   Sonos Error                     Offending Command -> zoneIP: 192.168.1.175, soapRoot: /MediaServer, soapBranch: /ContentDirectory, soapAction: Browse
   Sonos Error                     'invalid literal for int() with base 10: ''' in module 'Sonos.py', method 'actionDirect'
   Failing statement [line 1921]: 'if int(ZP) > 0:'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos Error                     SOAPSend Error: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
   Sonos Error                     'local variable 'response' referenced before assignment' in module 'Sonos.py', method 'SOAPSend'
   Failing statement [line 926]: 'res_bytes = response.text.encode("utf-8")'
   Sonos Error                     'invalid literal for int() with base 10: ''' in module 'Sonos.py', method 'actionDirect'
   Failing statement [line 1921]: 'if int(ZP) > 0:'
   Sonos Error                     UPNP Error: 500
   Sonos Error                     Offending Command -> zoneIP: 192.168.1.175, soapRoot: /MediaServer, soapBranch: /ContentDirectory, soapAction: Browse
   Sonos Error                     'invalid literal for int() with base 10: ''' in module 'Sonos.py', method 'actionDirect'
   Failing statement [line 1921]: 'if int(ZP) > 0:'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'
   Sonos Error                     'not enough values to unpack (expected 2, got 1)' in module 'Sonos.py', method 'copyStateFromMaster'
   Failing statement [line 3346]: '(MasterUID,x) = dev.states['GROUP_Name'].split(":")'


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

Re: Sonos Python 3 Beta

neilk wrote:
... I also tried my polly key and get the following when trying an announcement
Code: Select all
Sonos Error                     'write() argument must be str, not bytes' in module 'Sonos.py', method 'actionAnnouncement'
   Failing statement [line 2519]: 'f.write(data)'

I have uploaded a fix (hopefully) for this: Fix for Polly announcement

Posted on
Fri Jun 02, 2023 7:36 am
ryanbuckner offline
Posts: 1080
Joined: Oct 08, 2011
Location: Northern Virginia

Re: Sonos Python 3 Beta

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

Who is online

Users browsing this forum: No registered users and 11 guests