Python plugin: Sonos [new version]

Python and python framework
mvzut
Posts: 295
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: 826
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: 826
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: 17
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

vgr2
Posts: 89
Joined: Monday 29 August 2016 12:02
Target OS: -
Domoticz version:
Contact:

Re: Python plugin: Sonos [new version]

Post by vgr2 » Friday 27 October 2017 17:13

Hi, plugin is working with my new Sonos one, but how can I get my Radio favorites from Sonos?

Mdieli
Posts: 8
Joined: Saturday 14 February 2015 12:18
Target OS: Raspberry Pi
Domoticz version: BETA
Location: The Netherlands
Contact:

Re: Python plugin: Sonos [new version]

Post by Mdieli » Sunday 19 November 2017 10:26

For some reason, I can't get the plugin visable from the drop-down in the Hardware menu.

System: RPi 3
Domoticz: V3.8742
Python3: 3.5.3
Installed in the "~/domoticz/plugins/sonos" folder.
Restarted Domoticz from the commandline but the plugin is nowhere to be found.
Also, no errors are shown in the Domoticz log.

The funny thing is, I reinstalled the Pi a week or 2 ago, and on the previous installation, it worked like a charm.

EDIT: /Facepalm.... I forget to install python3-dev...
For future persons with similar issues: "sudo apt-get install python3-dev" and afterwards restart Domoticz.

mvzut
Posts: 295
Joined: Thursday 12 November 2015 11:55
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Marum, The Netherlands
Contact:

Python plugin: Sonos [new version]

Post by mvzut » Tuesday 21 November 2017 9:02

Plugin works great, using it for a few months now. I just started to use the notification system as well, this is working perfectly too.

I had one problem with notifications though: I have programmed a lot of generic notifications in LUA scripts (using the commandArray['SendNotification'] command). This gave errors, since these notifications are normally sent to all notification systems, and the Sonos notification system doesn't know what to do with a simple text notification.

The answer turned out to be pretty simple, see viewtopic.php?p=116009#p116009
Since one of the recent beta versions, it is possible to indicate which notification systems to use in LUA. This solved it for me. Maybe others with similar problems can be helped with this information too.
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
BakSeeDaa
Posts: 513
Joined: Thursday 17 September 2015 10:13
Target OS: Raspberry Pi
Domoticz version: beta
Contact:

Re: Python plugin: Sonos [new version]

Post by BakSeeDaa » Wednesday 06 December 2017 20:26

Hi all!

Since I bought a couple of Sonos One I've been experimenting with a Node-js project based on the great Node.js work node-sonos-http-api. I get all player state changes and tracks information pushed into Domoticz and it's updating lighting fast.There is no need for making Domoticz constantly pulling for any data changes. I also use it also for speaking TTS messages in different languages.

Initially I experienced some problems with that Domoticz sent multiple TTS messages and state request changes in a very short time and some of them were never carried out resulting in unpredictable results. I solved that with a task spooler so that every command is executed one by one. I don't know how this plugin has addressed such a scenario.

I sent a pm to @G3rard about if using based on the great Node.js work node-sonos-http-api would be an interesting approach for this Sonos Python Plugin but I haven't had any reply until now.

So to summarize, I've created yet another Sonos Integration project for Domoticz and maybe it doesn't introduce anything new that isn't already available. In such a case there would be no idea for me to share the work. :D

Cheers
Best wishes

// บักสีดา

Kurtsejr
Posts: 1
Joined: Tuesday 05 December 2017 0:01
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Python plugin: Sonos [new version]

Post by Kurtsejr » Friday 15 December 2017 21:20

It does not work for me, sorry - cant fint Sonos in the drop-down menu

System: RPi 3
Domoticz: V3.8789
Installed in the "~/domoticz/plugins/sonos" folder.
Restarted Domoticz from the commandline
no errors in the Domoticz log.
And I do have the python3-dev installed too
the plugin.py are owned by user pi, but has "755" rights

Any idear?

br Kurt

hvoordes
Posts: 1
Joined: Saturday 16 December 2017 15:58
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Python plugin: Sonos [new version]

Post by hvoordes » Saturday 16 December 2017 16:09

Hello,

I'm having the same problem. None of the plugins is shown in the pull down under hardware.

System: Synlogy DS216j
Domoticz: 3.8770

Where can I find the path for the plugins in the source code? Just to check if I placed the plugins in the right location.
Current location: /usr/local/domoticz/plugins

btw: Trying to get the Sonos plugin visible under hardware.

Post Reply

Who is online

Users browsing this forum: sirjohn78 and 3 guests