Python plugin: Sonos [new version]
Moderator: leecollings
- G3rard
- Posts: 669
- Joined: Wednesday 04 March 2015 22:15
- Target OS: -
- Domoticz version: No
- Location: The Netherlands
- Contact:
Python plugin: Sonos [new version]
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.
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.
Last edited by G3rard on Saturday 05 August 2017 0:05, edited 1 time in total.
Not using Domoticz anymore
-
- Posts: 14
- Joined: Friday 25 November 2016 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Python plugin: Sonos [new version]
Thanks for taking over this great plugin! Installed and it works but i get the following error in my domoticz logs:
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
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
Any ideas whats wrong? I have the latest beta of Domoticz Version: 3.8224
- G3rard
- Posts: 669
- Joined: Wednesday 04 March 2015 22:15
- Target OS: -
- Domoticz version: No
- Location: The Netherlands
- Contact:
Python plugin: Sonos [new version]
@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.
After that you can set Debug to False again.
Then I can have a look at the detailled log.
Not using Domoticz anymore
-
- Posts: 14
- Joined: Friday 25 November 2016 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Python plugin: Sonos [new version]
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.
- G3rard
- Posts: 669
- Joined: Wednesday 04 March 2015 22:15
- Target OS: -
- Domoticz version: No
- Location: The Netherlands
- Contact:
Re: Python plugin: Sonos [new version]
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.
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.
Not using Domoticz anymore
-
- Posts: 14
- Joined: Friday 25 November 2016 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Python plugin: Sonos [new version]
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?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.
- G3rard
- Posts: 669
- Joined: Wednesday 04 March 2015 22:15
- Target OS: -
- Domoticz version: No
- Location: The Netherlands
- Contact:
Re: Python plugin: Sonos [new version]
Are the other Sonos players grouped? Because I don't have that config and therefore not tested that.
Not using Domoticz anymore
-
- Posts: 14
- Joined: Friday 25 November 2016 22:46
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Python plugin: Sonos [new version]
Yes the other speakers are grouped so maybe that's the problem
- G3rard
- Posts: 669
- Joined: Wednesday 04 March 2015 22:15
- Target OS: -
- Domoticz version: No
- Location: The Netherlands
- Contact:
Re: Python plugin: Sonos [new version]
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?
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?
Not using Domoticz anymore
-
- Posts: 6
- Joined: Tuesday 07 June 2016 23:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Netherlands
- Contact:
Re: Python plugin: Sonos [new version]
after the python install it works fine.
When the tv is on all four switches do not work.
Version: 3.8153
Platform: raspberry 2
When the tv is on all four switches do not work.
Version: 3.8153
Platform: raspberry 2
RFXcom | Toon | Zware | Sonos |
-
- Posts: 115
- Joined: Sunday 11 January 2015 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Sonos [new version]
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?
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?
- Attachments
-
- plugin.log
- (77.22 KiB) Downloaded 157 times
- G3rard
- Posts: 669
- Joined: Wednesday 04 March 2015 22:15
- Target OS: -
- Domoticz version: No
- Location: The Netherlands
- Contact:
Re: Python plugin: Sonos [new version]
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.
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.
Not using Domoticz anymore
- G3rard
- Posts: 669
- Joined: Wednesday 04 March 2015 22:15
- Target OS: -
- Domoticz version: No
- Location: The Netherlands
- Contact:
Python plugin: Sonos [new version]
Can you elaborate a bit more on what is not working and the relationship with the tv being on?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
Not using Domoticz anymore
-
- Posts: 115
- Joined: Sunday 11 January 2015 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Sonos [new version]
Hoi Gerard, this looks like the solution.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.
Thanks for the help and de plugin!
-
- Posts: 115
- Joined: Sunday 11 January 2015 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Python plugin: Sonos [new version]
Is it correct the notification system cannot be used in blockly?
- G3rard
- Posts: 669
- Joined: Wednesday 04 March 2015 22:15
- Target OS: -
- Domoticz version: No
- Location: The Netherlands
- Contact:
Re: Python plugin: Sonos [new version]
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).
So you could either use LUA or ask the Domoticz dev's to add this feature (no c++ knowledge here).
Not using Domoticz anymore
- Dynamic
- Posts: 109
- Joined: Friday 12 July 2013 14:50
- Target OS: -
- Domoticz version:
- Location: Enschede
- Contact:
Re: Python plugin: Sonos [new version]
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.
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.
- StanHD
- Posts: 347
- Joined: Friday 12 July 2013 16:09
- Target OS: Windows
- Domoticz version:
- Location: East Sussex, UK
- Contact:
Re: Python plugin: Sonos [new version]
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
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
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
- StanHD
- Posts: 347
- Joined: Friday 12 July 2013 16:09
- Target OS: Windows
- Domoticz version:
- Location: East Sussex, UK
- Contact:
Re: Python plugin: Sonos [new version]
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.
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.
Domoticz Main - Intel nuc, Windows, RFXTRX433E. Lan Relay Boards, Aeon Z-Stick Gen 5, Evohome HGI80, Milight WiFi, MySensors Ethernet Gateway, Harmony Hub
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
Python:- Broadlink RM2, Sonos
HA-Bridge - Amazon Echo / Alexa
- G3rard
- Posts: 669
- Joined: Wednesday 04 March 2015 22:15
- Target OS: -
- Domoticz version: No
- Location: The Netherlands
- Contact:
Re: Python plugin: Sonos [new version]
Thanks @StanHD and good to see you have the Sonos plugin working.
Not using Domoticz anymore
Who is online
Users browsing this forum: No registered users and 1 guest