Python plugin: Sonos [old version]

Python and python framework

Moderator: leecollings

DomoRies
Posts: 14
Joined: Friday 25 November 2016 22:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Python plugin: Sonos

Post by DomoRies »

mvzut wrote:
DomoRies wrote:Nice plugin, but what do you need to fill in at ip-adres in Domoticz? Now it's for default 127.0.0.1
You must fill in the IP address of the Sonos player you want to add. Easiest way to find this is via the Sonos app, under Settings > About my Sonos System.
Thanks! It's working great now!
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Python plugin: Sonos

Post by mvzut »

The plugin is giving errors like these since the last few beta updates:

Code: Select all

2017-02-19 22:30:02.957 Error: (Sonos Laura) 'onNotification' failed 'TypeError':'onNotification() takes 1 positional argument but 7 were given'.
Some searching revealed that the onNotification implementation in the Python plugin framework was changed recently:
http://www.domoticz.com/forum/viewtopic.php?t=16151

I now changed these lines in the Sonos plugin.py (lines 194-196)

Code: Select all

def onNotification(Data):
    Domoticz.Log("Notification: " + str(Data))
    return
into

Code: Select all

def onNotification(name, subject, text, status, priority, sound, image_file):
    Domoticz.Log("Notification: " + str(name) + ", subject: " + str(subject) + ", text: " + str(text) + ", status: " + str(status))
    return
No idea what info from the 7 arguments I should copy to the log, I copied the first 4 for now.

@tester22, maybe you can change this in the GitHub repository?
Last edited by mvzut on Monday 20 February 2017 11:18, edited 1 time in total.
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
tester22
Posts: 49
Joined: Tuesday 20 December 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Sweden
Contact:

Re: Python plugin: Sonos

Post by tester22 »

mvzut wrote:The plugin is giving errors like these since the last few beta updates:

Code: Select all

2017-02-19 22:30:02.957 Error: (Sonos Laura) 'onNotification' failed 'TypeError':'onNotification() takes 1 positional argument but 7 were given'.
Some searching revealed that the onNotification implementation in the Python plugin framework was changed recently:
http://www.domoticz.com/forum/viewtopic.php?t=16151

I now changed these lines in the Sonos plugin.py (lines 194-196)

Code: Select all

def onNotification(Data):
    Domoticz.Log("Notification: " + str(Data))
    return
into

Code: Select all

def onNotification(name, subject, text, status, priority, sound, image_file):
    Domoticz.Log("Notification: " + str(name) + ", subject: " + str(subject) + ", text: " + str(text) + ", status: " + str(status))
    return
No idea what info from the 7 arguments I should copy to the log, I copied the first 4 for now.

@Tester22, maybe you can change this in the GitHub repository?
Done
l00pz
Posts: 42
Joined: Wednesday 01 April 2015 11:52
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Python plugin: Sonos

Post by l00pz »

Anyone else having a problem with the Volume Switch of the Sonos Plugin with the latest Beta and Plugin? Or is there something wrong with my configuration :D
Pino112
Posts: 3
Joined: Wednesday 20 January 2016 16:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Sonos

Post by Pino112 »

l00pz wrote:Anyone else having a problem with the Volume Switch of the Sonos Plugin with the latest Beta and Plugin? Or is there something wrong with my configuration :D
It doesnt updates the Sonos volume indeed

Also I miss the timer functionality to switch off my Play 1 automatically. Is that not possible with switch type media player?
tester22
Posts: 49
Joined: Tuesday 20 December 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Sweden
Contact:

Re: Python plugin: Sonos

Post by tester22 »

Pino112 wrote:
l00pz wrote:Anyone else having a problem with the Volume Switch of the Sonos Plugin with the latest Beta and Plugin? Or is there something wrong with my configuration :D
It doesnt updates the Sonos volume indeed

Also I miss the timer functionality to switch off my Play 1 automatically. Is that not possible with switch type media player?
Strange. Volume is working on my play5 players and on my Sonos connect. Could you enable debug and add the log output to this thread.

Not sure what automatic shutdown means. As soon as the plugin detects that the player is stopped it will change status to off.
Pino112
Posts: 3
Joined: Wednesday 20 January 2016 16:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Sonos

Post by Pino112 »

tester22 wrote:
Pino112 wrote:
l00pz wrote:Anyone else having a problem with the Volume Switch of the Sonos Plugin with the latest Beta and Plugin? Or is there something wrong with my configuration :D
It doesnt updates the Sonos volume indeed

Also I miss the timer functionality to switch off my Play 1 automatically. Is that not possible with switch type media player?
Strange. Volume is working on my play5 players and on my Sonos connect. Could you enable debug and add the log output to this thread.

Not sure what automatic shutdown means. As soon as the plugin detects that the player is stopped it will change status to off.
I updated to the latest beta version and it works now. Thanks.
HomeAutomation
Posts: 9
Joined: Saturday 28 February 2015 19:52
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6838
Location: The Netherlands
Contact:

Re: Python plugin: Sonos

Post by HomeAutomation »

Not be able to add Sonos Player in Hardware

When selecting the Sonos pluging from the Pulldown box and pressing "Add" it's not updated in the hardware overview.
What can be wrong?

***** 2017-03-03 Problem caused by browser Chrome (Versie 56.0.2924.87)

When trying to add the pluging with my Android tablet all worked well.
Difference is that in Chrome the fields for filling in the IP adres etc. were not visible

In Edge there's also no problem to add the plugin in the hardware

......



Domoticz V3.6838 (c)2012-2017 GizMoCuz Build Hash: 895a33a
Startup Path: /home/pi/domoticz/
PluginSystem: Started, Python version '3.4.2'.

Jan
Last edited by HomeAutomation on Saturday 04 March 2017 9:17, edited 1 time in total.
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Python plugin: Sonos

Post by mvzut »

HomeAutomation wrote:Not be able to add Sonos Player in Hardware

When selecting the Sonos pluging from the Pulldown box and pressing "Add" it's not updated in the hardware overview.
What can be wrong?

Domoticz V3.6838 (c)2012-2017 GizMoCuz Build Hash: 895a33a
Startup Path: /home/pi/domoticz/
PluginSystem: Started, Python version '3.4.2'.

Jan
Did you fill in the IP address of your Sonos?
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
HomeAutomation
Posts: 9
Joined: Saturday 28 February 2015 19:52
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6838
Location: The Netherlands
Contact:

Re: Python plugin: Sonos

Post by HomeAutomation »

mvzut wrote:
HomeAutomation wrote:Not be able to add Sonos Player in Hardware

When selecting the Sonos pluging from the Pulldown box and pressing "Add" it's not updated in the hardware overview.
What can be wrong?

Domoticz V3.6838 (c)2012-2017 GizMoCuz Build Hash: 895a33a
Startup Path: /home/pi/domoticz/
PluginSystem: Started, Python version '3.4.2'.

Jan
Did you fill in the IP address of your Sonos?

No, I did not, because these fields were not visible :( .
I normaly work with Chrome. When I tried it on my Android tablet and later in Edge these fields were visble and it all worked well.

Jan
HomeAutomation
Posts: 9
Joined: Saturday 28 February 2015 19:52
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6838
Location: The Netherlands
Contact:

Re: Python plugin: Sonos

Post by HomeAutomation »

How to control Sonos by LUA script

Does anybody have a example how to control the Sonos plugin with a LUA script?

Jan
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Python plugin: Sonos

Post by mvzut »

HomeAutomation wrote:How to control Sonos by LUA script

Does anybody have a example how to control the Sonos plugin with a LUA script?

Jan
It's just as if you are controlling a lamp: You can use LUA on/off commands (commandArray['<status device name>'] = 'On') to start/pause a player with the current playlist, and you can use the volume device as if it was a dimmer (using e.g. commandArray['<volume device name>']= 'Set Level 30').
As far as I know the plugin can't be used to e.g. skip to the next song or to start a particular playlist. The virtual remote doesn't work (yet).
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
HomeAutomation
Posts: 9
Joined: Saturday 28 February 2015 19:52
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6838
Location: The Netherlands
Contact:

Re: Python plugin: Sonos

Post by HomeAutomation »

mvzut wrote:
HomeAutomation wrote:How to control Sonos by LUA script

Does anybody have a example how to control the Sonos plugin with a LUA script?

Jan
It's just as if you are controlling a lamp: You can use LUA on/off commands (commandArray['<status device name>'] = 'On') to start/pause a player with the current playlist, and you can use the volume device as if it was a dimmer (using e.g. commandArray['<volume device name>']= 'Set Level 30').
As far as I know the plugin can't be used to e.g. skip to the next song or to start a particular playlist. The virtual remote doesn't work (yet).
Is it really that simple? :o
Thanks, I'll give it a try.

Jan
tester22
Posts: 49
Joined: Tuesday 20 December 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Sweden
Contact:

Re: Python plugin: Sonos

Post by tester22 »

mvzut wrote:
HomeAutomation wrote:Jan
As far as I know the plugin can't be used to e.g. skip to the next song or to start a particular playlist. The virtual remote doesn't work (yet).
Does anyone want features like skip track? My idea have been to use this for automation for example switch on the amplifier when Sonos connect is starting. I have used the Sonos app for everything else.

The only remaining feature I am planning is TTS as soon as the plugin have support for providing an url that Sonos players can conect to so they can download data.
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Python plugin: Sonos

Post by mvzut »

tester22 wrote:
mvzut wrote:
HomeAutomation wrote:Jan
As far as I know the plugin can't be used to e.g. skip to the next song or to start a particular playlist. The virtual remote doesn't work (yet).
Does anyone want features like skip track? My idea have been to use this for automation for example switch on the amplifier when Sonos connect is starting. I have used the Sonos app for everything else.

The only remaining feature I am planning is TTS as soon as the plugin have support for providing an url that Sonos players can conect to so they can download data.
Skipping tracks etc. is not needed for my purposes. I also primarily use the plugin to activate a Harmony scene (switching on my amp) when my Sonos Connect starts playing. What could be interesting is the ability to start a specific playlist or favourite or radio station. That would enable me to couple e.g. a radio station to a button on my wall mounted tablet running Imperihome, without the need to start the Sonos app.
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
tester22
Posts: 49
Joined: Tuesday 20 December 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Sweden
Contact:

Re: Python plugin: Sonos

Post by tester22 »

mvzut wrote:
tester22 wrote:
mvzut wrote: As far as I know the plugin can't be used to e.g. skip to the next song or to start a particular playlist. The virtual remote doesn't work (yet).
Does anyone want features like skip track? My idea have been to use this for automation for example switch on the amplifier when Sonos connect is starting. I have used the Sonos app for everything else.

The only remaining feature I am planning is TTS as soon as the plugin have support for providing an url that Sonos players can conect to so they can download data.
Skipping tracks etc. is not needed for my purposes. I also primarily use the plugin to activate a Harmony scene (switching on my amp) when my Sonos Connect starts playing. What could be interesting is the ability to start a specific playlist or favourite or radio station. That would enable me to couple e.g. a radio station to a button on my wall mounted tablet running Imperihome, without the need to start the Sonos app.
How should that be implemented on in the ui?
A combo button that the user can add Sonos uri (separated by comma) to under preferences or an notification type that can be triggered by scripts?
RayAmsterdam
Posts: 115
Joined: Sunday 11 January 2015 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Sonos

Post by RayAmsterdam »

TTS would be great!
HomeAutomation
Posts: 9
Joined: Saturday 28 February 2015 19:52
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6838
Location: The Netherlands
Contact:

Re: Python plugin: Sonos

Post by HomeAutomation »

RayAmsterdam wrote:TTS would be great!
I agree.
Just bought my first Sonos Play 1 and allready experience a lot of opportunities for my HomeAutomation 8-)

Jan
tester22
Posts: 49
Joined: Tuesday 20 December 2016 17:43
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Sweden
Contact:

Re: Python plugin: Sonos

Post by tester22 »

HomeAutomation wrote:
RayAmsterdam wrote:TTS would be great!
I agree.
Just bought my first Sonos Play 1 and allready experience a lot of opportunities for my HomeAutomation 8-)

Jan
Yes, but the options I have seen so far requires the script to download the file and than expose it over http so Sonos can download it and that is not currently possible.
Also my plan was to use tha asynchronous built in communication layer (haven't been able to get it working thou) and then it is harder to actually know when the player is done playing the message.
HomeAutomation
Posts: 9
Joined: Saturday 28 February 2015 19:52
Target OS: Raspberry Pi / ODroid
Domoticz version: V3.6838
Location: The Netherlands
Contact:

Re: Python plugin: Sonos

Post by HomeAutomation »

mvzut wrote:
HomeAutomation wrote:How to control Sonos by LUA script

Does anybody have a example how to control the Sonos plugin with a LUA script?

Jan
It's just as if you are controlling a lamp: You can use LUA on/off commands (commandArray['<status device name>'] = 'On') to start/pause a player with the current playlist, and you can use the volume device as if it was a dimmer (using e.g. commandArray['<volume device name>']= 'Set Level 30').
As far as I know the plugin can't be used to e.g. skip to the next song or to start a particular playlist. The virtual remote doesn't work (yet).
Works perfect.
Integreated Sonos in my WakeUp alarm.
Now, based on one time setting, I'm able to control my bedroom light (WakeUp), central heating and Sonos.
Still looking for a Alarm clock pluging however. :idea: ?
Last edited by HomeAutomation on Sunday 05 March 2017 13:56, edited 1 time in total.
Post Reply

Who is online

Users browsing this forum: madpatrick and 1 guest