Python plugin: Sonos [old version]

Python and python framework

Moderator: leecollings

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 »

G3rard wrote:
tester22 wrote: I have added some more error handeling.
Try to use the plugin with debug enabled.
The plugin is now working again. When listening to a radio station I get the following message in the log (debug enabled).

Code: Select all

2017-01-30 22:27:27.253 (Sonos kantoor) Calling message handler 'onHeartbeat'.
2017-01-30 22:27:27.274 (Sonos kantoor) Failed to parse data
2017-01-30 22:27:27.274 (Sonos kantoor) QMusic Nonstopobject.item.audioItem.audioBroadcastSA_RINCON65031_.

2017-01-30 22:38:29.071 (Sonos kantoor) Calling message handler 'onHeartbeat'.
2017-01-30 22:38:29.100 (Sonos kantoor) Failed to parse data
2017-01-30 22:38:29.100 (Sonos kantoor) 538object.item.audioItem.audioBroadcastSA_RINCON65031_.
Where QMusic Nonstop and 538 are the radio stations.
I have tried to recreate the issue on my Sonos5 but it works as expected so right now the only thing I can think of is that the radio is returning some invalid characters like "&" and that it is causing the error.

Code: Select all

2017-01-31 08:32:34.188 (Kontoret) Calling message handler 'onHeartbeat'.
2017-01-31 08:33:04.218 (Kontoret) Calling message handler 'onHeartbeat'.
2017-01-31 08:33:34.228 (Kontoret) Calling message handler 'onHeartbeat'.
2017-01-31 08:33:34.252 (Kontoret) Update 1:'' (Kontoret - Status)
2017-01-31 08:33:34.297 (Kontoret) Update 1:'Qmusic - Kumu - Mixed' (Kontoret - Status)
2017-01-31 08:33:34.305 (Kontoret) Update 1:'Qmusic - Paradise - COLDPLAY' (Kontoret - Status)
2017-01-31 08:33:34.329 (Kontoret) Update 2:'6' (Kontoret - Volume)
2017-01-31 08:34:04.242 (Kontoret) Calling message handler 'onHeartbeat'.
2017-01-31 08:34:34.215 (Kontoret) Calling message handler 'onHeartbeat'.
2017-01-31 08:34:34.277 (Kontoret) Update 1:'Qmusic - Sorry - KENSINGTON' (Kontoret - Status)
2017-01-31 08:35:04.226 (Kontoret) Calling message handler 'onHeartbeat'.
2017-01-31 08:35:34.251 (Kontoret) Calling message handler 'onHeartbeat'.
2017-01-31 08:35:34.327 (Kontoret) Update 1:'Radio 538 - Sorry - KENSINGTON' (Kontoret - Status)
2017-01-31 08:35:34.335 (Kontoret) Update 1:'Radio 538 - ' (Kontoret - Status)
2017-01-31 08:36:04.249 (Kontoret) Calling message handler 'onHeartbeat'.
2017-01-31 08:36:34.237 (Kontoret) Calling message handler 'onHeartbeat'.
2017-01-31 08:37:04.261 (Kontoret) Calling message handler 'onHeartbeat'.
2017-01-31 08:37:34.266 (Kontoret) Calling message handler 'onHeartbeat'.
2017-01-31 08:37:34.320 (Kontoret) Update 1:'538 Party - ' (Kontoret - Status)
2017-01-31 08:38:04.267 (Kontoret) Calling message handler 'onHeartbeat'.
2017-01-31 08:38:34.276 (Kontoret) Calling message handler 'onHeartbeat'.
2017-01-31 08:38:34.330 (Kontoret) Update 1:'538 Hitzone - ' (Kontoret - Status)
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 »

Version: 3.6568
Platform: Rpi 2

The Sonos hardware isn't visible in hardware menu.
What I did:

Created folder '/Domoticz/plugin'
Created folder '/plugin/sonos'
Created file 'plugin.py'
Copied scripttext from Github into the file
Changed 'Ip Address' into the ip address of one of my Sonos speakers
Saved file
Restarted Domoticz'

What am I doing wrong?
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 »

RayAmsterdam wrote:Version: 3.6568
Platform: Rpi 2

The Sonos hardware isn't visible in hardware menu.
What I did:

Created folder '/Domoticz/plugin'
Created folder '/plugin/sonos'
Created file 'plugin.py'
Copied scripttext from Github into the file
Changed 'Ip Address' into the ip address of one of my Sonos speakers
Saved file
Restarted Domoticz'

What am I doing wrong?
You shouldn't change anything in the files all config is done in hardware pane.
Are you on the latest beta version of domoticz?
Have you installed python3 manually?
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 »

I replaced the file, without changing.
Beta version 3.6568
Python 3 is installed (for a long time)

Still not working...
Is it normal you have to manualy create the plugin folder?
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 »

RayAmsterdam wrote:I replaced the file, without changing.
Beta version 3.6568
Python 3 is installed (for a long time)

Still not working...
Is it normal you have to manualy create the plugin folder?
Did have a look on my pi and it seems like you misspelled the folder.
mine is <domoticz>/plugins/Sonos/plugin.py
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 »

tester22 wrote:
RayAmsterdam wrote:I replaced the file, without changing.
Beta version 3.6568
Python 3 is installed (for a long time)

Still not working...
Is it normal you have to manualy create the plugin folder?
Did have a look on my pi and it seems like you misspelled the folder.
mine is <domoticz>/plugins/Sonos/plugin.py
I changed it. Seems like the misspel is also on the topicstart.
Mine now is /home/pi/domoticz/plugins/Sonos/plugin.py

Unfortunately still doesn't work...
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 »

RayAmsterdam wrote:
tester22 wrote:
RayAmsterdam wrote:I replaced the file, without changing.
Beta version 3.6568
Python 3 is installed (for a long time)

Still not working...
Is it normal you have to manualy create the plugin folder?
Did have a look on my pi and it seems like you misspelled the folder.
mine is <domoticz>/plugins/Sonos/plugin.py
I changed it. Seems like the misspel is also on the topicstart.
Mine now is /home/pi/domoticz/plugins/Sonos/plugin.py

Unfortunately still doesn't work...
Log in with ssh and go to /home/pi/domoticz/ and enter the following.
Make sure the bold line exists. If that doesn't work ask @Dnpwwo.

sudo /etc/init.d/domoticz.sh stop && ./domoticz -verbose 2

2017-01-31 20:44:19.597 Domoticz V3.6562 (c)2012-2017 GizMoCuz
2017-01-31 20:44:19.597 Build Hash: 974bc54, Date: 2017-01-30 00:43:50
2017-01-31 20:44:19.598 System: Raspberry Pi
2017-01-31 20:44:19.598 Startup Path: /home/pi/domoticz/
2017-01-31 20:44:19.667 Sunrise: 07:59:00 SunSet:16:03:00
2017-01-31 20:44:19.667 EventSystem: reset all events...
2017-01-31 20:44:20.096 PluginSystem: Started, Python version '3.5.1'.
2017-01-31 20:44:20.120 Active notification Subsystems: email, http, prowl (3/12)
2017-01-31 20:44:20.125 WebServer(HTTP) started on address: 0.0.0.0 with port 8080
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 »

tester22 wrote:
RayAmsterdam wrote:
tester22 wrote:
Did have a look on my pi and it seems like you misspelled the folder.
mine is <domoticz>/plugins/Sonos/plugin.py
I changed it. Seems like the misspel is also on the topicstart.
Mine now is /home/pi/domoticz/plugins/Sonos/plugin.py

Unfortunately still doesn't work...
Log in with ssh and go to /home/pi/domoticz/ and enter the following.
Make sure the bold line exists. If that doesn't work ask @Dnpwwo.

sudo /etc/init.d/domoticz.sh stop && ./domoticz -verbose 2

2017-01-31 20:44:19.597 Domoticz V3.6562 (c)2012-2017 GizMoCuz
2017-01-31 20:44:19.597 Build Hash: 974bc54, Date: 2017-01-30 00:43:50
2017-01-31 20:44:19.598 System: Raspberry Pi
2017-01-31 20:44:19.598 Startup Path: /home/pi/domoticz/
2017-01-31 20:44:19.667 Sunrise: 07:59:00 SunSet:16:03:00
2017-01-31 20:44:19.667 EventSystem: reset all events...
2017-01-31 20:44:20.096 PluginSystem: Started, Python version '3.5.1'.
2017-01-31 20:44:20.120 Active notification Subsystems: email, http, prowl (3/12)
2017-01-31 20:44:20.125 WebServer(HTTP) started on address: 0.0.0.0 with port 8080
I get this:
-bash: ./domoticz: Is a directory
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 »

RayAmsterdam wrote:
tester22 wrote:
RayAmsterdam wrote: I changed it. Seems like the misspel is also on the topicstart.
Mine now is /home/pi/domoticz/plugins/Sonos/plugin.py

Unfortunately still doesn't work...
Log in with ssh and go to /home/pi/domoticz/ and enter the following.
Make sure the bold line exists. If that doesn't work ask @Dnpwwo.

sudo /etc/init.d/domoticz.sh stop && ./domoticz -verbose 2

2017-01-31 20:44:19.597 Domoticz V3.6562 (c)2012-2017 GizMoCuz
2017-01-31 20:44:19.597 Build Hash: 974bc54, Date: 2017-01-30 00:43:50
2017-01-31 20:44:19.598 System: Raspberry Pi
2017-01-31 20:44:19.598 Startup Path: /home/pi/domoticz/
2017-01-31 20:44:19.667 Sunrise: 07:59:00 SunSet:16:03:00
2017-01-31 20:44:19.667 EventSystem: reset all events...
2017-01-31 20:44:20.096 PluginSystem: Started, Python version '3.5.1'.
2017-01-31 20:44:20.120 Active notification Subsystems: email, http, prowl (3/12)
2017-01-31 20:44:20.125 WebServer(HTTP) started on address: 0.0.0.0 with port 8080
I get this:
-bash: ./domoticz: Is a directory
You need to go to /home/pi/domoticz/. Right now you are in /home/pi/
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: Python plugin: Sonos

Post by G3rard »

tester22 wrote: I have tried to recreate the issue on my Sonos5 but it works as expected so right now the only thing I can think of is that the radio is returning some invalid characters like "&" and that it is causing the error.
It is working here right now as well :D
Problem was that I was using some PHP code for selecting a radio station using a Domoticz selector switch. That way the CurrentURIMetaData field in GetMediaInfo was filled with

Code: Select all

"Radio 538<\/dc:title>object.item.audioItem.audioBroadcast<\/upnp:class>SA_RINCON65031_<\/desc><\/item><\/DIDL-Lite>."
When I select the radio station with the Sonos app the CurrentURIMetaData field is

Code: Select all

"Radio 538<\/dc:title>object.item.audioItem.audioBroadcast<\/upnp:class>SA_RINCON65031_<\/desc><\/item><\/DIDL-Lite>"
Apparently the . at the end is causing the problem :?

I fixed this by removing the unintentional . in the PHPSonos.inc.php file which is used to select the radio station :P
Last edited by G3rard on Wednesday 01 February 2017 0:54, edited 3 times in total.
Not using Domoticz anymore
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 »

tester22 wrote:
RayAmsterdam wrote:
tester22 wrote:
Log in with ssh and go to /home/pi/domoticz/ and enter the following.
Make sure the bold line exists. If that doesn't work ask @Dnpwwo.

sudo /etc/init.d/domoticz.sh stop && ./domoticz -verbose 2

2017-01-31 20:44:19.597 Domoticz V3.6562 (c)2012-2017 GizMoCuz
2017-01-31 20:44:19.597 Build Hash: 974bc54, Date: 2017-01-30 00:43:50
2017-01-31 20:44:19.598 System: Raspberry Pi
2017-01-31 20:44:19.598 Startup Path: /home/pi/domoticz/
2017-01-31 20:44:19.667 Sunrise: 07:59:00 SunSet:16:03:00
2017-01-31 20:44:19.667 EventSystem: reset all events...
2017-01-31 20:44:20.096 PluginSystem: Started, Python version '3.5.1'.
2017-01-31 20:44:20.120 Active notification Subsystems: email, http, prowl (3/12)
2017-01-31 20:44:20.125 WebServer(HTTP) started on address: 0.0.0.0 with port 8080
I get this:
-bash: ./domoticz: Is a directory
You need to go to /home/pi/domoticz/. Right now you are in /home/pi/
Thanks, that worked. I now get this:
PluginSystem: Failed dynamic library load, install the latest libpython3.x library that is available for your platform.
Already had 3.2 installed. Just installed 3.6, but still no luck :-(

Tomorrow a new day. Thanks so far for the help.
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python plugin: Sonos

Post by Dnpwwo »

@RayAmsterdam,

Installing Python 3 is not what is required. You need to install libpython3.x instead, where 3.4 is the minimum supported.

Give that a go (or have a look at http://www.domoticz.com/wiki/Linux#Prob ... ing_Python)
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
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 »

Dnpwwo wrote:@RayAmsterdam,

Installing Python 3 is not what is required. You need to install libpython3.x instead, where 3.4 is the minimum supported.

Give that a go (or have a look at http://www.domoticz.com/wiki/Linux#Prob ... ing_Python)
This was the solution. Thanks!
julianmclean
Posts: 20
Joined: Wednesday 08 October 2014 21:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Sonos

Post by julianmclean »

Just came across this thread (and learned of the Python plugin system), and will definitely be trying this out int he next couple of days. It may be a bit premature to start asking questions/making suggestions before I've even tried the thing :roll: but anyway just a few thoughts:

[*] From a (very) brief look through the code, as I understand it, the plugin is conversing directly with the Sonos SOAP API? Just wondered if any consideration had been given to interfacing with the HTTP Sonos wrapper (https://github.com/jishi/node-sonos-http-api), which abstracts away much of the complexity into simple HTTP GET URLs. I appreciate that this then demands a "middle-man" (node server running this module), but it could allow for richer functionality and easier expansion to perform new functions. Actually, I guess the comms from Sonos->Domoticz (rather than control) may become trickier, although the wrapper does itself include webhooks for passing along Sonos state transitions. On the plus side, this wrapper has some neat functions for doing announcements/text-to-speech/interrupt - e.g. I use this in my system for things like doorbell integration which become trivial HTTP calls to interrupt all players, ring the doorbell and resume. At the moment, these are "external" to Domoticz, but if would be really nice if these became possible through the semi-native Sonos Domoticz devices.

[*] One thing that would be really good (from my perspective at least ;o) would be the ability for advanced control from the Domoticz environment. Referring back to the HTTP Sonos wrapper again, you can issue simple HTTP commands that cause a search of a given music service to find the closest match and start playback, for example: "http://<server>/Lounge/musicsearch/apple/album/i created disco" finds and plays the Calvin Harris album. Now, having not read the Sonos wrapper code yet, I'm not sure if this is done "through" Sonos, or direct the the music services and then handing off the URL to Sonos. But...back to this Domoticz Sonos plugin, it would be great if we could actually set one of the values for the device to a search term, which would then invoke a search and play. I sometimes use a similar approach when I want to pass arbitrary parameters "through" Domoticz using something like a Text dummy device - I can pass in arbitrary parameter(s) of my choosing (e.g. delimited with pipes) and have Domoticz react to the change, triggering an integrated decide to do something and/or feeding into other Domoticz logic at the same time. Not sure what is possible through the python plugin, but all that is really needed is a single text field to act as a place to put command inputs - a simple scheme can then be developed for that text field, to differentiate different types of command (e.g. "search:i created disco", "radio:kiss FM", "favourite:my hits", "interrupt:doorbell"), essentially allowing for fairly advance interaction with the Sonos through the Domoticz system.

Anyway, first I'll try and get it running as is!
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 »

julianmclean wrote:Just came across this thread (and learned of the Python plugin system), and will definitely be trying this out int he next couple of days. It may be a bit premature to start asking questions/making suggestions before I've even tried the thing :roll: but anyway just a few thoughts:

[*] From a (very) brief look through the code, as I understand it, the plugin is conversing directly with the Sonos SOAP API? Just wondered if any consideration had been given to interfacing with the HTTP Sonos wrapper (https://github.com/jishi/node-sonos-http-api), which abstracts away much of the complexity into simple HTTP GET URLs. I appreciate that this then demands a "middle-man" (node server running this module), but it could allow for richer functionality and easier expansion to perform new functions. Actually, I guess the comms from Sonos->Domoticz (rather than control) may become trickier, although the wrapper does itself include webhooks for passing along Sonos state transitions. On the plus side, this wrapper has some neat functions for doing announcements/text-to-speech/interrupt - e.g. I use this in my system for things like doorbell integration which become trivial HTTP calls to interrupt all players, ring the doorbell and resume. At the moment, these are "external" to Domoticz, but if would be really nice if these became possible through the semi-native Sonos Domoticz devices.

[*] One thing that would be really good (from my perspective at least ;o) would be the ability for advanced control from the Domoticz environment. Referring back to the HTTP Sonos wrapper again, you can issue simple HTTP commands that cause a search of a given music service to find the closest match and start playback, for example: "http://<server>/Lounge/musicsearch/apple/album/i created disco" finds and plays the Calvin Harris album. Now, having not read the Sonos wrapper code yet, I'm not sure if this is done "through" Sonos, or direct the the music services and then handing off the URL to Sonos. But...back to this Domoticz Sonos plugin, it would be great if we could actually set one of the values for the device to a search term, which would then invoke a search and play. I sometimes use a similar approach when I want to pass arbitrary parameters "through" Domoticz using something like a Text dummy device - I can pass in arbitrary parameter(s) of my choosing (e.g. delimited with pipes) and have Domoticz react to the change, triggering an integrated decide to do something and/or feeding into other Domoticz logic at the same time. Not sure what is possible through the python plugin, but all that is really needed is a single text field to act as a place to put command inputs - a simple scheme can then be developed for that text field, to differentiate different types of command (e.g. "search:i created disco", "radio:kiss FM", "favourite:my hits", "interrupt:doorbell"), essentially allowing for fairly advance interaction with the Sonos through the Domoticz system.

Anyway, first I'll try and get it running as is!
I had a look both at the node wrapper and the the Soco python class: https://github.com/SoCo/SoCo (I actually copied all the soap messges from there).
But for both those solutions the user would be required to install components other than just Domotics and the plugin.
In my point of view that pretty much ruins the purpose of the plugin and that is the reason why I even didn't use the Socos class even that it would be much easier from the developer perspective.

Also the plugin is currently designed to use the built in communication features of the Domoticz python plugin (when it is stable and I have time).

And yes I have considered TTS but in the implementations I have seen that requires an http server to publish the files so that sonos can read them and currently there is no such functionality in the python plugin framework.
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Python plugin: Sonos

Post by Dnpwwo »

@julianmclean,

I can't speak for the Sonos functionality but the plugin framework does allow arbitrary commands to be sent through to the plugin from the event system (lua scripts). This allows you to link devices like text or selector switches to actions. I have an internet radio select switch that sents playlist commands to a Kodi plugin:

Code: Select all

    if (deviceName=='Lounge Radio') then
        print ("Kodi event fired on '"..deviceName.."', value '"..deviceValue.."', Lounge Kodi state '"..otherdevices['Lounge Kodi'].."', Denon state '"..otherdevices['Denon'].."'");
        -- Need to synchronise radio event with Denon Amplifier and Lounge Kodi states
        -- URLs for streaming can be found here: http://streamlist.southerncrossaustereo.com.au/
        if (deviceValue == 'Off') then
            if (otherdevices['Lounge Kodi'] ~= 'On') then commandArray['Lounge Kodi'] = 'Stop' end
        elseif (deviceValue == '101.9 Fox FM') then
            commandArray['Lounge Kodi'] = 'Trigger Favorites 0'
        elseif (deviceValue == '104.3 Gold FM') then
            commandArray['Lounge Kodi'] = 'Trigger Favorites 1'
        elseif (deviceValue == '105.1 Triple M FM') then commandArray['Lounge Kodi'] = 'Trigger Favorites 2'
        end
    end
the commands are passed straight through to the plugin onCommand callback.

Obviously that callback needs to interpret the command and send the required message(s) to the external hardware with something like:

Code: Select all

        elif (action == 'Trigger'):
            Domoticz.Send('{"jsonrpc":"2.0","method":"Input.ExecuteAction","params":{"action":"stop"},"id":1006}')
            Domoticz.Send('{"jsonrpc":"2.0","method":"Playlist.Clear","params":{"playlistid":0},"id":2000}')
            Domoticz.Send('{"jsonrpc":"2.0","method":"Playlist.Clear","params":{"playlistid":1},"id":2000}')
            action, sep, params = params.partition(' ')
            action = action.capitalize()
            playlistName = ""
            playlistPos = 0
            if (action == 'Playlist'):
                # Command formats: 'Trigger Playlist ActionMovies',  'Trigger Playlist ActionMovies 15'
                playlistName, sep, params = params.partition(' ')
                if (params.isdigit()):
                    playlistPos = int(params)
                Domoticz.Send('{"jsonrpc":"2.0","method":"Playlist.Add","params":{"playlistid":0,"item":{"directory":"special://profile/playlists/music/'+playlistName+'.xsp\", "media":"music"}},"id":2002}')
            elif (action == 'Favorites') or (action == 'Favourites'):
                # Command formats: 'Trigger Favorites', 'Trigger Favorites 3'
                if (params.isdigit()):
                    playlistPos = int(params)
                Domoticz.Send('{"jsonrpc":"2.0","method":"Favourites.GetFavourites","params":{"properties":["path"]},"id":2100}')
            else:
                Domoticz.Error( "Trigger, Unknown target: "+str(action)+", expected Playlist/Favorites.")
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
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, I have the Sonos plugin running fine most of the time, but sometimes (maybe once a day) I get a whole bunch of error messages from it in the Domoticz log. Sometimes from one player, sometimes from more at the same time. I'm pretty sure they are caused by a temporary communication hiccup. That can of course happen once in a while with any plugin (it also happens sometimes with my Hue plugin for instance), but usually this is not causing such "explosions" in the log.
Is it possible to do silent retries in the background without immediately showing 5 error messages per player? Or just wait for the next update, and only show a single info message that the connection was lost? You can still show everything when debug mode is on, but I think most people don't want to be alarmed with a flooded error log by small glitches that occasionally happen.

P.S. I'm not a Python coder, but I can't seem to find anything on timeouts of the http request in your code. Maybe the problem can already be solved by waiting a bit longer for the player to respond?
Last edited by mvzut on Friday 03 February 2017 7:46, 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
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 »

My Sonos status devices are suddenly starting to get a battery level associated with them, which is reported as low. This morning for one player, a second one just a few minutes ago. That's not such a huge problem, unless you have configured battery low warnings. I keep getting those now. Is there something that can be done about this? Or is it a bug in the latest Domoticz beta version?
Last edited by mvzut on Friday 03 February 2017 10:03, edited 2 times 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
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 »

I've got my 3 Sonos speakers up and running now :-)
Since the 3 speakers are grouped only 1 (main) speaker is updated in Domoticz with the information. For the stations,songs, etc that is not a problem. The grouped speakers however do not change their state in Domoticz when turned off, only the main speaker. They stay 'On'. Is this a bug in the plugin, or is this the behaviour of the Sonos protocol?
julianmclean
Posts: 20
Joined: Wednesday 08 October 2014 21:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python plugin: Sonos

Post by julianmclean »

tester22 wrote:
I had a look both at the node wrapper and the the Soco python class: https://github.com/SoCo/SoCo (I actually copied all the soap messges from there).
But for both those solutions the user would be required to install components other than just Domotics and the plugin.
In my point of view that pretty much ruins the purpose of the plugin and that is the reason why I even didn't use the Socos class even that it would be much easier from the developer perspective.

Also the plugin is currently designed to use the built in communication features of the Domoticz python plugin (when it is stable and I have time).

And yes I have considered TTS but in the implementations I have seen that requires an http server to publish the files so that sonos can read them and currently there is no such functionality in the python plugin framework.
Understood, and you are probably right about the purpose of the plugin. I guess features from SoCo and node wrapper can always be "ported" across where considered useful, and if they fit within what is possible in the Domoticz framework. Regarding TTS and playing other "clips", it is also possible with just smb other shared drive (which many Sonos uses would generally already have for any locally-stored music).
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest