Python plugin: Sonos [new version]

Python and python framework
mvzut
Posts: 280
Joined: Thursday 12 November 2015 11:55
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Marum, The Netherlands
Contact:

Re: Python plugin: Sonos [new version]

Post by mvzut » Sunday 17 September 2017 12:32

Hi G3erard,

Thanks for all your effort, this new implementation works great for me!
One thing annoyed me though:
If you stop playback, either via the plugin or via another controller, it actually pauses. There's nothing you can do about that, that is just how Sonos is designed. However, in the paused state, the plugin keeps flooding the log with "Paused" messages, every update interval (which is 5 seconds in my case). The log page of the Sonos state device is also many pages long, almost completely filled with "Paused" states. This makes the Domoticz database unnecessarily large.
I also start a timer after I stop (pause) my Sonos Connect, which switches off the amplifier after a few minutes. But this timer was restarted every 5 seconds, because the paused state was constantly updated.

I now created a workaround, by changing a few lines in your Python code starting from line 392:

Code: Select all

#                if CurrentTransportState  == 'PAUSED_PLAYBACK':
#                    self.playerState = 2
#                    self.mediaDescription = 'Paused'
#                    UpdateDevice(1, 1, self.mediaDescription)
                if CurrentTransportState  == 'STOPPED' or CurrentTransportState  == 'PAUSED_PLAYBACK':
In this way I make the plugin treats the PAUSED state as if it was the STOPPED state (I think...). Maybe it's not a very elegant solution, but it works for me. It would obviously be nicer if the paused state is only updated once. I'll see if I can figure out how to achieve this, but if you have a good idea for this please feel free to help me (us) out!
Raspberry Pi 2B - RFXtrx433 - Aeon Z-Stick gen5 - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - Sonos Connect & PLAY:1 - Kodi - Wall mounted tablet + Imperihome - MANY switches/sensors

User avatar
G3rard
Posts: 824
Joined: Wednesday 04 March 2015 23:15
Target OS: Linux
Domoticz version: V3.8153
Location: The Netherlands
Contact:

Re: Python plugin: Sonos [new version]

Post by G3rard » Monday 18 September 2017 22:45

Hi @mvzut,
Thanks for your post! I have fixed the Paused issue in the new v0.91 release which is on Github.
https://github.com/gerard33/sonos
Just tested it and it now works as it should :)
Ubuntu Server 14.04 | Domoticz v3.8153 | RFXtrx433E | Z-Wave Aeotec Z-Stick S2
Frontpage | Sonos PHP | Dark th3me | Sony Bravia Python plugin | Sonos Python plugin

josimd
Posts: 51
Joined: Saturday 09 January 2016 20:47
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Sonos [new version]

Post by josimd » Friday 22 September 2017 22:18

installed the python plugin on my Synology NAS, but received error after starting the script....anyone? Thanks!!

[email protected]_NAS:/volume1/appstore/domoticz/plugins/sonos$ python plugin.py
Traceback (most recent call last):
File "plugin.py", line 41, in <module>
import Domoticz
ImportError: No module named Domoticz

User avatar
G3rard
Posts: 824
Joined: Wednesday 04 March 2015 23:15
Target OS: Linux
Domoticz version: V3.8153
Location: The Netherlands
Contact:

Re: Python plugin: Sonos [new version]

Post by G3rard » Saturday 23 September 2017 0:33

josimd wrote:
Friday 22 September 2017 22:18
installed the python plugin on my Synology NAS, but received error after starting the script....anyone? Thanks!!

[email protected]_NAS:/volume1/appstore/domoticz/plugins/sonos$ python plugin.py
Traceback (most recent call last):
File "plugin.py", line 41, in <module>
import Domoticz
ImportError: No module named Domoticz
Are you starting the script from the command line? That won't work, it needs to be enabled in Domoticz.
Check the Github page for the instructions.
Ubuntu Server 14.04 | Domoticz v3.8153 | RFXtrx433E | Z-Wave Aeotec Z-Stick S2
Frontpage | Sonos PHP | Dark th3me | Sony Bravia Python plugin | Sonos Python plugin

josimd
Posts: 51
Joined: Saturday 09 January 2016 20:47
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Sonos [new version]

Post by josimd » Saturday 23 September 2017 20:06

G3rard wrote:
Saturday 23 September 2017 0:33
josimd wrote:
Friday 22 September 2017 22:18
installed the python plugin on my Synology NAS, but received error after starting the script....anyone? Thanks!!

[email protected]_NAS:/volume1/appstore/domoticz/plugins/sonos$ python plugin.py
Traceback (most recent call last):
File "plugin.py", line 41, in <module>
import Domoticz
ImportError: No module named Domoticz
Are you starting the script from the command line? That won't work, it needs to be enabled in Domoticz.
Check the Github page for the instructions.
Hi Gerard, just checked it, I have domoticz running on a Synology NAS, Python 3 package is installed, also the domoticz version has the Python plugin included... but still no Sonos in the hardware tab... hope you can direct me in the right way ;-)

florisi
Posts: 8
Joined: Saturday 30 July 2016 10:14
Target OS: NAS (Synology & others)
Domoticz version: v3.8153
Location: Arnhem
Contact:

Re: Python plugin: Sonos [new version]

Post by florisi » Saturday 23 September 2017 20:37

I have the same issue.
Installed on a Synology.
No errors, and in the plugin directory there was created a Sonos-dir with plugin.py and a couple of zip-files.
Rebooted the Synology bu still no Sonos hardware.

niclasc
Posts: 55
Joined: Wednesday 09 December 2015 18:04
Target OS: OS X
Domoticz version: 3.5582
Location: Sweden
Contact:

Re: Python plugin: Sonos [new version]

Post by niclasc » Sunday 24 September 2017 10:50

Cant find Sonos Players under hardware. I have python3 and python3-dev installed and have restarted Domoticz

rathmannm
Posts: 16
Joined: Sunday 10 January 2016 19:56
Target OS: Raspberry Pi
Domoticz version: 3.8153
Contact:

Re: Python plugin: Sonos [new version]

Post by rathmannm » Thursday 28 September 2017 19:04

Hi,

it's great to see the plugin continues to be developed. I have an issue however - if I stream from Spotify directly to Sonos it shows up as "Grouped" even though it is technically not. This means none of the controls work. I understand grouping control as such is not supported but any chance to address this bug?

Thanks,
Manuel

josimd
Posts: 51
Joined: Saturday 09 January 2016 20:47
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Sonos [new version]

Post by josimd » Saturday 30 September 2017 21:43

josimd wrote:
Saturday 23 September 2017 20:06
G3rard wrote:
Saturday 23 September 2017 0:33
josimd wrote:
Friday 22 September 2017 22:18
installed the python plugin on my Synology NAS, but received error after starting the script....anyone? Thanks!!

[email protected]_NAS:/volume1/appstore/domoticz/plugins/sonos$ python plugin.py
Traceback (most recent call last):
File "plugin.py", line 41, in <module>
import Domoticz
ImportError: No module named Domoticz
Are you starting the script from the command line? That won't work, it needs to be enabled in Domoticz.
Check the Github page for the instructions.
Hi Gerard, just checked it, I have domoticz running on a Synology NAS, Python 3 package is installed, also the domoticz version has the Python plugin included... but still no Sonos in the hardware tab... hope you can direct me in the right way ;-)
Anyone solved this issue?

josimd
Posts: 51
Joined: Saturday 09 January 2016 20:47
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Sonos [new version]

Post by josimd » Sunday 08 October 2017 18:05

josimd wrote:
Saturday 30 September 2017 21:43
josimd wrote:
Saturday 23 September 2017 20:06
G3rard wrote:
Saturday 23 September 2017 0:33

Are you starting the script from the command line? That won't work, it needs to be enabled in Domoticz.
Check the Github page for the instructions.
Hi Gerard, just checked it, I have domoticz running on a Synology NAS, Python 3 package is installed, also the domoticz version has the Python plugin included... but still no Sonos in the hardware tab... hope you can direct me in the right way ;-)
Anyone solved this issue?
Issue resolved, installed the wrong domoticz version, updated with the python plugin... works like a charm... :D

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests