Page 1 of 4
Python plugin: Sonos [new version]
Posted: Saturday 05 August 2017 0:05
by G3rard
Tester22 has written a Python plugin for Sonos, but his plugin is no longer
maintained. I agreed with him that I would continue developing and maintaining the plugin. The first version of this new plugin is now available for testing
You can download the plugin on
https://github.com/gerard33/sonos. Instructions on how to setup and use the plugin are also there.
Short overview of the functions:
* Shows the [artist] - [song] or [radiostation] - [song] being played
* Change the volume or (un)mute
* You can choose between the following icons: Sonos logo, Sonos 1, Sonos 5
* You can send notifications to the Sonos which will trigger an mp3 file to be played on the Sonos, after that the Sonos will continue playing the song/radio station which was played before that notification
* A selector switch with a maximum of 10 radio favorites from your Sonos (from the My Radio Stations of Radio by TuneIn) is available. When a radio station from this list, which is not selected this Domoticz switch (e.g. from your Sonos app), is playing then this switch will be updated with that radio station.
* On/off, previous/next and pause buttons.
There are still some things I need to do (replace the sleep solution in the onNotification function with another solution, some code cleanup), but the plugin is ready for testing.
I have tested this plugin succesfully with the latest Domoticz stable v3.8153 on Ubuntu Server 14.04.
Nevertheless there still seem to be some issues with Python plugins which run on precompiled Raspberry Pi versions of Domoticz. See this topic.
If you have an error message like in that topic (Error: Domoticz received fatal signal...) then there is nothing I can do about that in the plugin.
Please let me know if you have any issues (other then the issue mentioned above) with the plugin or any features you would like to add.
If you use the plugin satisfactorily then please let me know that by making a short post in this topic.
It's always good to know that there are happy users
Many thanks to tester22 for developing the first version of the plugin! Without his work I would have never been able to make this updated version of the plugin.
Re: Python plugin: Sonos [new version]
Posted: Saturday 05 August 2017 22:19
by DomoRies
Thanks for taking over this great plugin! Installed and it works but i get the following error in my domoticz logs:
Code: Select all
2017-08-05 22:11:28.605 Error: (Sonos Badkamer) ----> Line 97 in /home/pi/domoticz/plugins/sonos/plugin.py, function onStart
2017-08-05 22:11:28.605 Error: (Sonos Badkamer) ----> Line 576 in /home/pi/domoticz/plugins/sonos/plugin.py, function sonos_GetFavorites
2017-08-05 22:11:28.605 Error: (Sonos Badkamer) ----> Line 355 in /home/pi/domoticz/plugins/sonos/plugin.py, function sendMessage
2017-08-05 22:11:28.605 Error: (Sonos Badkamer) ----> Line 1090 in /usr/lib/python3.4/http/client.py, function request
2017-08-05 22:11:28.605 Error: (Sonos Badkamer) ----> Line 1128 in /usr/lib/python3.4/http/client.py, function _send_request
2017-08-05 22:11:28.605 Error: (Sonos Badkamer) ----> Line 1086 in /usr/lib/python3.4/http/client.py, function endheaders
2017-08-05 22:11:28.605 Error: (Sonos Badkamer) ----> Line 924 in /usr/lib/python3.4/http/client.py, function _send_output
2017-08-05 22:11:28.605 Error: (Sonos Badkamer) ----> Line 859 in /usr/lib/python3.4/http/client.py, function send
2017-08-05 22:11:28.605 Error: (Sonos Badkamer) ----> Line 836 in /usr/lib/python3.4/http/client.py, function connect
2017-08-05 22:11:28.605 Error: (Sonos Badkamer) ----> Line 509 in /usr/lib/python3.4/socket.py, function create_connection
2017-08-05 22:11:28.605 Error: (Sonos Badkamer) ----> Line 509 in /usr/lib/python3.4/socket.py, function create_connection
2017-08-05 22:11:38.070 Error: (Sonos Studeerkamer) 'onStart' failed 'OSError'.
2017-08-05 22:11:38.071 Error: (Sonos Studeerkamer) ----> Line 676 in /home/pi/domoticz/plugins/sonos/plugin.py, function onStart
2017-08-05 22:11:38.071 Error: (Sonos Studeerkamer) ----> Line 97 in /home/pi/domoticz/plugins/sonos/plugin.py, function onStart
2017-08-05 22:11:38.071 Error: (Sonos Studeerkamer) ----> Line 576 in /home/pi/domoticz/plugins/sonos/plugin.py, function sonos_GetFavorites
2017-08-05 22:11:38.071 Error: (Sonos Studeerkamer) ----> Line 355 in /home/pi/domoticz/plugins/sonos/plugin.py, function sendMessage
2017-08-05 22:11:38.071 Error: (Sonos Studeerkamer) ----> Line 1090 in /usr/lib/python3.4/http/client.py, function request
2017-08-05 22:11:38.071 Error: (Sonos Studeerkamer) ----> Line 1128 in /usr/lib/python3.4/http/client.py, function _send_request
2017-08-05 22:11:38.071 Error: (Sonos Studeerkamer) ----> Line 1086 in /usr/lib/python3.4/http/client.py, function endheaders
2017-08-05 22:11:38.071 Error: (Sonos Studeerkamer) ----> Line 924 in /usr/lib/python3.4/http/client.py, function _send_output
2017-08-05 22:11:38.071 Error: (Sonos Studeerkamer) ----> Line 859 in /usr/lib/python3.4/http/client.py, function send
2017-08-05 22:11:38.071 Error: (Sonos Studeerkamer) ----> Line 836 in /usr/lib/python3.4/http/client.py, function connect
2017-08-05 22:11:38.071 Error: (Sonos Studeerkamer) ----> Line 509 in /usr/lib/python3.4/socket.py, function create_connection
2017-08-05 22:11:38.071 Error: (Sonos Studeerkamer) ----> Line 509 in /usr/lib/python3.4/socket.py, function create_connection
2017-08-05 22:11:41.270 Error: (Sonos Slaapkamer) 'onStart' failed 'OSError'.
2017-08-05 22:11:41.270 Error: (Sonos Slaapkamer) ----> Line 676 in /home/pi/domoticz/plugins/sonos/plugin.py, function onStart
2017-08-05 22:11:41.270 Error: (Sonos Slaapkamer) ----> Line 97 in /home/pi/domoticz/plugins/sonos/plugin.py, function onStart
2017-08-05 22:11:41.271 Error: (Sonos Slaapkamer) ----> Line 576 in /home/pi/domoticz/plugins/sonos/plugin.py, function sonos_GetFavorites
2017-08-05 22:11:41.271 Error: (Sonos Slaapkamer) ----> Line 355 in /home/pi/domoticz/plugins/sonos/plugin.py, function sendMessage
2017-08-05 22:11:41.271 Error: (Sonos Slaapkamer) ----> Line 1090 in /usr/lib/python3.4/http/client.py, function request
2017-08-05 22:11:41.271 Error: (Sonos Slaapkamer) ----> Line 1128 in /usr/lib/python3.4/http/client.py, function _send_request
2017-08-05 22:11:41.271 Error: (Sonos Slaapkamer) ----> Line 1086 in /usr/lib/python3.4/http/client.py, function endheaders
2017-08-05 22:11:41.271 Error: (Sonos Slaapkamer) ----> Line 924 in /usr/lib/python3.4/http/client.py, function _send_output
2017-08-05 22:11:41.271 Error: (Sonos Slaapkamer) ----> Line 859 in /usr/lib/python3.4/http/client.py, function send
2017-08-05 22:11:41.271 Error: (Sonos Slaapkamer) ----> Line 836 in /usr/lib/python3.4/http/client.py, function connect
2017-08-05 22:11:41.271 Error: (Sonos Slaapkamer) ----> Line 509 in /usr/lib/python3.4/socket.py, function create_connection
2017-08-05 22:11:41.271 Error: (Sonos Slaapkamer) ----> Line 509 in /usr/lib/python3.4/socket.py, function create_connection
2017-08-05 22:11:44.550 Error: (Sonos Studeerkamer) 'onHeartbeat' failed 'OSError'.
2017-08-05 22:11:44.550 Error: (Sonos Studeerkamer) ----> Line 685 in /home/pi/domoticz/plugins/sonos/plugin.py, function onHeartbeat
2017-08-05 22:11:44.550 Error: (Sonos Studeerkamer) ----> Line 328 in /home/pi/domoticz/plugins/sonos/plugin.py, function onHeartbeat
2017-08-05 22:11:44.550 Error: (Sonos Studeerkamer) ----> Line 500 in /home/pi/domoticz/plugins/sonos/plugin.py, function sonos_GetTransportInfo
2017-08-05 22:11:44.551 Error: (Sonos Studeerkamer) ----> Line 355 in /home/pi/domoticz/plugins/sonos/plugin.py, function sendMessage
2017-08-05 22:11:44.551 Error: (Sonos Studeerkamer) ----> Line 1090 in /usr/lib/python3.4/http/client.py, function request
2017-08-05 22:11:44.551 Error: (Sonos Studeerkamer) ----> Line 1128 in /usr/lib/python3.4/http/client.py, function _send_request
2017-08-05 22:11:44.551 Error: (Sonos Studeerkamer) ----> Line 1086 in /usr/lib/python3.4/http/client.py, function endheaders
2017-08-05 22:11:44.551 Error: (Sonos Studeerkamer) ----> Line 924 in /usr/lib/python3.4/http/client.py, function _send_output
2017-08-05 22:11:44.551 Error: (Sonos Studeerkamer) ----> Line 859 in /usr/lib/python3.4/http/client.py, function send
2017-08-05 22:11:44.551 Error: (Sonos Studeerkamer) ----> Line 836 in /usr/lib/python3.4/http/client.py, function connect
2017-08-05 22:11:44.551 Error: (Sonos Studeerkamer) ----> Line 509 in /usr/lib/python3.4/socket.py, function create_connection
2017-08-05 22:11:44.551 Error: (Sonos Studeerkamer) ----> Line 509 in /usr/lib/python3.4/socket.py, function create_connection
Sometimes the error is gone when the player is playing a song.
Any ideas whats wrong? I have the latest beta of Domoticz Version: 3.8224
Python plugin: Sonos [new version]
Posted: Saturday 05 August 2017 22:41
by G3rard
@DomoRies, can you set the Debug level of the plugin (in Settings-Hardware) to Logging, press Update and wait for ~1 minute. Then please send the plugin.log file from the sonos plugin directory to me (can be as attachment in this topic or via PM).
After that you can set Debug to False again.
Then I can have a look at the detailled log.
Re: Python plugin: Sonos [new version]
Posted: Saturday 05 August 2017 23:14
by DomoRies
Sure, here it is! Now Domoticz is crasing after i use the plugin for play, pauze or something and go to the devices tab. Very strange. Hope you can find something in the log that wil help.
Re: Python plugin: Sonos [new version]
Posted: Saturday 05 August 2017 23:43
by G3rard
I see you have multiple Sonos players. Can you activate only one and see if that still gives issues?
Edit: I have checked the log file and can't find anything strange. If you can try the suggestion above, I will update my test system to latest beta and see if that gives any issues.
Re: Python plugin: Sonos [new version]
Posted: Monday 07 August 2017 16:25
by DomoRies
G3rard wrote:I see you have multiple Sonos players. Can you activate only one and see if that still gives issues?
Edit: I have checked the log file and can't find anything strange. If you can try the suggestion above, I will update my test system to latest beta and see if that gives any issues.
I've tried today en put a new log file as attachment. For now its working with only my Sonos Connect (Woonkamer) connected to Domoticz. So i think it has to do with my Sonos setup in the house? Maybe wifi signal?
Re: Python plugin: Sonos [new version]
Posted: Monday 07 August 2017 16:44
by G3rard
Are the other Sonos players grouped? Because I don't have that config and therefore not tested that.
Re: Python plugin: Sonos [new version]
Posted: Monday 07 August 2017 17:13
by DomoRies
Yes the other speakers are grouped so maybe that's the problem
Re: Python plugin: Sonos [new version]
Posted: Monday 07 August 2017 18:10
by G3rard
Can you ungroup one to see if that player then works?
Edit: See also this post regarding grouped speakers
viewtopic.php?f=65&t=15543&p=117998&hil ... ed#p117998.
Can you share some more information on the group behaviour? For example, what are the 2 speakers which are not the main speaker, showing when something is played? Are these set to off?
And is the only thing that can be different in a group the volume/mute of each speaker?
Re: Python plugin: Sonos [new version]
Posted: Tuesday 08 August 2017 20:32
by junr
after the python install it works fine.
When the tv is on all four switches do not work.
Version: 3.8153
Platform: raspberry 2
Re: Python plugin: Sonos [new version]
Posted: Tuesday 08 August 2017 22:13
by RayAmsterdam
I installed the new plugin. Unfortunately it makes Domoticz randomly crash (like the old version did). The dev tools are installed.
Sometimes after restarting Domoticz I can make the Sonos play, but after a few seconds Domoticz hangs again.
Attached the log file.
What can be wrong?
Re: Python plugin: Sonos [new version]
Posted: Tuesday 08 August 2017 22:55
by G3rard
The plugin is running fine here now for days on a Raspberry Pi 3 and Ubuntu Server 14.04. It's annoying that on some hardware the plugins still causes issues.
What is the Domoticz log showing when it hangs? And which Domoticz version do you use?
And do you have a file with PIR in the name in the domoticz/scripts/python folder? If so, please delete that file as it is known to cause crashes.
Python plugin: Sonos [new version]
Posted: Tuesday 08 August 2017 22:57
by G3rard
junr wrote:after the python install it works fine.
When the tv is on all four switches do not work.
Version: 3.8153
Platform: raspberry 2
Can you elaborate a bit more on what is not working and the relationship with the tv being on?
Re: Python plugin: Sonos [new version]
Posted: Tuesday 08 August 2017 23:16
by RayAmsterdam
G3rard wrote:
And do you have a file with PIR in the name in the domoticz/scripts/python folder? If so, please delete that file as it is known to cause crashes.
Hoi Gerard, this looks like the solution.
Thanks for the help and de plugin!
Re: Python plugin: Sonos [new version]
Posted: Thursday 10 August 2017 17:02
by RayAmsterdam
Is it correct the notification system cannot be used in blockly?
Re: Python plugin: Sonos [new version]
Posted: Friday 11 August 2017 0:14
by G3rard
I hadn't tested the notifications from Blockly until now, and it indeed doesn't show up there.
So you could either use LUA or ask the Domoticz dev's to add this feature (no c++ knowledge here).
Re: Python plugin: Sonos [new version]
Posted: Wednesday 16 August 2017 8:15
by Dynamic
I've installed your plugin (there is a folder 'sonos' under domoticz/plugins), but I can't find 'sonos players' under the hardware-tab.
I did a reboot of the Domoticz-service and tried to empty my brower cache, but that didn't help. Any idea how to solve this?
Edit:
*bumps head on desk*
I forgot I re-installed my Raspberry Pi and did forgot to install Python.
Re: Python plugin: Sonos [new version]
Posted: Thursday 24 August 2017 22:13
by StanHD
Hi,
I am trying to install the Sonos Plugin to my Synology.
I used the Gerard33 instructions:- git clone
https://github.com/gerard33/sonos.git
To this directory:- /volume1/@appstore/domoticz/var/plugins/Sonos/
Files installed without error.
When I re-start Domoticz package I get the following log messages:-
2017-08-24 20:44:27.887 Python EventSystem: Module not found - Trying to initialize.
2017-08-24 20:44:27.888 Python EventSystem: Initalizing event module.
2017-08-24 20:44:27.888 EventSystem: Started
2017-08-24 20:44:28.297 PluginSystem: Entering work loop.
The hardware list does not show the Sonos Hardware in the pull down.
I have tried using incognito mode in case of cache problems but no difference
Any ideas anyone? Am I close
Thank you,
Stan
Edit:- Sorry should have advised:- Domoticz 3.8153 stable for DSM6.1 With Python PluginManager
Re: Python plugin: Sonos [new version]
Posted: Friday 25 August 2017 17:36
by StanHD
Replying to myself. A really basic error on my part
I created "Sonos" sub directory and I think the installation created another (or I did), anyway, as soon as I moved the files back to their correct location and re-started the package, everything now works. My bad
I really like the Radio implementation and the Control selector. Great job @G3rard, thank you very much.
Re: Python plugin: Sonos [new version]
Posted: Monday 28 August 2017 22:50
by G3rard
Thanks @StanHD and good to see you have the Sonos plugin working.