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 »

Dnpwwo wrote:@rathmannm,

I'm not sure this is a Python plugin issue because the log shows that the plugin is not loaded.

Code: Select all

2017-06-24 08:44:26.347 Error: (Sonos) failed to load 'plugin.py', Python Path used was ':/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
2017-06-24 08:44:26.347 Error: (Sonos Livingroom) Module Import failed, exception: 'ImportError'
2017-06-24 08:44:26.348 Error: (Sonos Livingroom) Module Import failed: ' Name: plugin'
2017-06-24 08:44:26.525 Error: (Sonos) failed to load 'plugin.py', Python Path used was ':/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
2017-06-24 08:44:26.526 Error: (Sonos Kitchen) Module Import failed, exception: 'ImportError'
2017-06-24 08:44:26.526 Error: (Sonos Kitchen) Module Import failed: ' Name: plugin'
but if you post the exact plugin.py file I can try and 'not load it' as well to see if I can reproduce the issue. I haven't seen import failure cause stability issues previously though.

You could try removing the '_pycache_' folder in the Sonos plugins folder if you have one. I have had issues when upgrading a plugin where Python got a little confused.
Still same issue:

Code: Select all

2017-06-27 12:50:55.630  (Veras rum) Debug log level set to: 'true'.
2017-06-27 12:50:55.631  (Veras rum) 'Mode3':'Sonos'
2017-06-27 12:50:55.631  (Veras rum) 'Author':'tester22'
2017-06-27 12:50:55.631  (Veras rum) 'Key':'Sonos'
2017-06-27 12:50:55.631  (Veras rum) 'Mode6':'Debug'
2017-06-27 12:50:55.631  (Veras rum) 'Address':'10.0.1.14'
2017-06-27 12:50:55.631  (Veras rum) 'Port':'0'
2017-06-27 12:50:55.632  (Veras rum) 'HardwareID':'15'
2017-06-27 12:50:55.632  (Veras rum) 'HomeFolder':'/home/pi/domoticz/plugins/Sonos/'
2017-06-27 12:50:55.632  (Veras rum) 'Mode1':'30'
2017-06-27 12:50:55.632  (Veras rum) 'Version':'2.0'
2017-06-27 12:50:55.632  (Veras rum) 'Mode2':'Volume'
2017-06-27 12:50:55.632  (Veras rum) 'Name':'Veras rum'
2017-06-27 12:50:55.632  (Veras rum) Device count: 2
2017-06-27 12:50:55.632  (Veras rum) Device:           1 - ID: 131, Name: 'Sonos Veras rum', nValue: 0, sValue: ''
2017-06-27 12:50:55.633  (Veras rum) Internal ID:     '131'
2017-06-27 12:50:55.633  (Veras rum) External ID:     '000000F'
2017-06-27 12:50:55.633  (Veras rum) Device Name:     'Sonos Veras rum'
2017-06-27 12:50:55.633  (Veras rum) Device nValue:    0
2017-06-27 12:50:55.633  (Veras rum) Device sValue:   ''
2017-06-27 12:50:55.633  (Veras rum) Device LastLevel: 0
2017-06-27 12:50:55.633  (Veras rum) Device:           2 - ID: 134, Name: 'Veras rum - Volume', nValue: 2, sValue: '2'
2017-06-27 12:50:55.633  (Veras rum) Internal ID:     '134'
2017-06-27 12:50:55.634  (Veras rum) External ID:     '000000F'
2017-06-27 12:50:55.634  (Veras rum) Device Name:     'Veras rum - Volume'
2017-06-27 12:50:55.634  (Veras rum) Device nValue:    2
2017-06-27 12:50:55.634  (Veras rum) Device sValue:   '2'
2017-06-27 12:50:55.634  (Veras rum) Device LastLevel: 2
2017-06-27 12:50:55.642  (Hjalmars rum) Debug log level set to: 'true'.
2017-06-27 12:50:55.643  (Hjalmars rum) 'Author':'tester22'
2017-06-27 12:50:55.643  (Hjalmars rum) 'Key':'Sonos'
2017-06-27 12:50:55.643  (Hjalmars rum) 'Mode6':'Debug'
2017-06-27 12:50:55.643  (Hjalmars rum) 'Address':'10.0.1.11'
2017-06-27 12:50:55.643  (Hjalmars rum) 'Port':'0'
2017-06-27 12:50:55.643  (Hjalmars rum) 'HardwareID':'16'
2017-06-27 12:50:55.643  (Hjalmars rum) 'HomeFolder':'/home/pi/domoticz/plugins/Sonos/'
2017-06-27 12:50:55.643  (Hjalmars rum) 'Mode1':'30'
2017-06-27 12:50:55.644  (Hjalmars rum) 'Version':'2.0'
2017-06-27 12:50:55.644  (Hjalmars rum) 'Mode2':'Volume'
2017-06-27 12:50:55.644  (Hjalmars rum) 'Name':'Hjalmars rum'
2017-06-27 12:50:55.644  (Hjalmars rum) Device count: 2
2017-06-27 12:50:55.644  (Hjalmars rum) Device:           1 - ID: 132, Name: 'Hjalmar rum - Status', nValue: 0, sValue: ''
2017-06-27 12:50:55.644  (Hjalmars rum) Internal ID:     '132'
2017-06-27 12:50:55.645  (Hjalmars rum) External ID:     '0000010'
2017-06-27 12:50:55.645  (Hjalmars rum) Device Name:     'Hjalmar rum - Status'
2017-06-27 12:50:55.645  (Hjalmars rum) Device nValue:    0
2017-06-27 12:50:55.645  (Hjalmars rum) Device sValue:   ''
2017-06-27 12:50:55.645  (Hjalmars rum) Device LastLevel: 0
2017-06-27 12:50:55.645  (Hjalmars rum) Device:           2 - ID: 133, Name: 'Hjalmars rum - Volume', nValue: 0, sValue: '25'
2017-06-27 12:50:55.645  (Hjalmars rum) Internal ID:     '133'
2017-06-27 12:50:55.645  (Hjalmars rum) External ID:     '0000010'
2017-06-27 12:50:55.646  (Hjalmars rum) Device Name:     'Hjalmars rum - Volume'
2017-06-27 12:50:55.646  (Hjalmars rum) Device nValue:    0
2017-06-27 12:50:55.646  (Hjalmars rum) Device sValue:   '25'
2017-06-27 12:50:55.646  (Hjalmars rum) Device LastLevel: 15
2017-06-27 12:50:55.646  (Veras rum) Heartbeat interval set to: 30.
2017-06-27 12:50:55.646  (Hjalmars rum) Heartbeat interval set to: 30.
2017-06-27 12:50:57.717  Incoming connection from: 127.0.0.1
2017-06-27 12:50:57.787  (RFLink) Temp + Humidity (Sovrum)
2017-06-27 12:51:02.805  (Vardagsrummet) Update 1:'' (Sonos Vardagsrummet)
2017-06-27 12:51:02.916  (Vardagsrummet) Update 1:'Fatboy Slim - Gangster Trippin' (Sonos Vardagsrummet)
2017-06-27 12:51:03.718  (Veras rum) Calling message handler 'onHeartbeat'.
2017-06-27 12:51:04.713  (Hjalmars rum) Calling message handler 'onHeartbeat'.
2017-06-27 12:51:08.291  Incoming connection from: 10.0.1.252
2017-06-27 12:51:23.673  (MySensors) Temp (Kontoret)
2017-06-27 12:51:24.353  (RFLink) Temp + Humidity (Köket)
2017-06-27 12:51:27.536  (MySensors) Temp + Humidity + Baro (TempHumBaro)
2017-06-27 12:51:27.561  (MySensors) General/Barometer (Baro)
2017-06-27 12:51:32.695  (RFLink) Temp + Humidity (Sovrum)
2017-06-27 12:51:33.689  (Veras rum) Calling message handler 'onHeartbeat'.
2017-06-27 12:51:34.736  (Hjalmars rum) Calling message handler 'onHeartbeat'.
2017-06-27 12:51:40.853  (RFLink) Temp + Humidity (Vinden)
2017-06-27 12:51:55.236  (MySensors) Temp (Kontoret)
2017-06-27 12:51:55.299  (MySensors) Temp (Ute)
2017-06-27 12:51:59.355  (RFLink) Temp + Humidity (Köket)
2017-06-27 12:52:00.668  (MySensors) Temp + Humidity + Baro (TempHumBaro)
2017-06-27 12:52:00.962  Error: TV hardware (17) thread seems to have ended unexpectedly
2017-06-27 12:52:03.713  (Veras rum) Calling message handler 'onHeartbeat'.
2017-06-27 12:52:04.803  (Hjalmars rum) Calling message handler 'onHeartbeat'.
2017-06-27 12:52:07.697  (RFLink) Temp + Humidity (Sovrum)
2017-06-27 12:52:26.837  (MySensors) Temp (Kontoret)
2017-06-27 12:52:26.887  (MySensors) Temp (Ute)
2017-06-27 12:52:33.733  (Veras rum) Calling message handler 'onHeartbeat'.
2017-06-27 12:52:33.819  (MySensors) Temp + Humidity + Baro (TempHumBaro)
2017-06-27 12:52:33.839  (MySensors) Temp + Humidity + Baro (TempHumBaro)
2017-06-27 12:52:33.856  (MySensors) General/Barometer (Baro)
2017-06-27 12:52:34.357  (RFLink) Temp + Humidity (Köket)
2017-06-27 12:52:34.731  (Hjalmars rum) Calling message handler 'onHeartbeat'.
2017-06-27 12:52:42.698  (RFLink) Temp + Humidity (Sovrum)
2017-06-27 12:52:58.434  (MySensors) Temp (Kontoret)
2017-06-27 12:52:58.489  (MySensors) Temp (Ute)
2017-06-27 12:53:00.976  Error: TV hardware (17) thread seems to have ended unexpectedly
2017-06-27 12:53:03.729  (Veras rum) Calling message handler 'onHeartbeat'.
2017-06-27 12:53:04.728  (Hjalmars rum) Calling message handler 'onHeartbeat'.
2017-06-27 12:53:06.961  (MySensors) Temp + Humidity + Baro (TempHumBaro)
2017-06-27 12:53:09.363  (RFLink) Temp + Humidity (Köket)
2017-06-27 12:53:17.694  Error: Domoticz received fatal signal 11 !...
2017-06-27 12:53:17.705  Error:   /home/pi/domoticz/domoticz() [0x1ccd84]
2017-06-27 12:53:17.706  Error:   /home/pi/domoticz/domoticz(_Z14signal_handleri+0x58) [0x1cce3c]
2017-06-27 12:53:17.706  Error:   /lib/arm-linux-gnueabihf/libc.so.6(__default_sa_restorer_v2+0) [0x76ac8160]

rathmannm
Posts: 15
Joined: Sunday 10 January 2016 18:56
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Contact:

Re: Python plugin: Sonos

Post by rathmannm »

Thanks for looking into this. I have removed the '_pycache_' folder but that didn't make any difference. It's interesting that tester22 has got the exact same error in the log. Also as soon as I remove the Sonos script Domoticz starts without any issues so it really seems the culprit to me.

If you want to try for yourself I am using the latest version of the plugin:

https://github.com/tester22/Domoticz-So ... ster/Sonos

Cheers,
Manuel
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 »

mvzut wrote:
mvzut wrote:
tester22 wrote:Managed to get the built in xml parser to work.
Currently only player state and title.

Volume and mute is not loaded nor radio stations.
Works, thanks! You say that (only) radio stations are not shown, but when I play something from a streaming service like Spotify it also doesn't show the title.
Hmmm, looks like I was too optimistic, Domoticz froze after a few minutes. Can't seem to get it running stable. Is it working reliable at your side?
Tried it again today, there have been a few beta updates of Domoticz since the last time I tried. I removed the __pycache__ folder first. It seems to work again for me! Song names are also shown. I only added one player this time, I will add some more when this continues to run stable.
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
droop7
Posts: 2
Joined: Monday 03 July 2017 14:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Belgium
Contact:

Re: Python plugin: Sonos

Post by droop7 »

Hi Everybody,

I'm not very new by domoticz using (since 3 years now)... but its the first time i use python.

I installed plugin on my rasp but i can't see where i can add my sonos devices after reboot.

Maybe it's a dummy question but i'm not english spoken normally... so i searched but didn't fin any post that can help me.

Anyone an idée??

Regards,
rathmannm
Posts: 15
Joined: Sunday 10 January 2016 18:56
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Contact:

Re: Python plugin: Sonos

Post by rathmannm »

mvzut wrote:
mvzut wrote:
mvzut wrote: Works, thanks! You say that (only) radio stations are not shown, but when I play something from a streaming service like Spotify it also doesn't show the title.
Hmmm, looks like I was too optimistic, Domoticz froze after a few minutes. Can't seem to get it running stable. Is it working reliable at your side?
Tried it again today, there have been a few beta updates of Domoticz since the last time I tried. I removed the __pycache__ folder first. It seems to work again for me! Song names are also shown. I only added one player this time, I will add some more when this continues to run stable.
Actually did you remove all the Sonos setup within Domoticz, then remove the __pycache__ folder and then re-add the plugin and manually setup all of the configuration? So far I only deleted the __pycache__ folder with leaving everything else in place and got nowhere...

Thanks,
Manuel
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Python plugin: Sonos

Post by G3rard »

Unfortunately tester22 is no longer maintaining the code for this plugin.
But I agreed with him that I will continue developing and maintaining the code for the Sonos plugin.

I am currently working on a new version which also shows the radio station and the volume again and has an option to go to the previous or next song. Will see if I can add some more options to the Control switch. Any ideas are welcome.
Next to that I will also have a look if I can load the favorites so they (at least the first 10 due to the limit of the items in the selector switch) can be operated from Domoticz.
screenprint.png
screenprint.png (89.44 KiB) Viewed 3550 times
When I have the new version ready for testing, I will post that here.
Not using Domoticz anymore
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Python plugin: Sonos

Post by leecollings »

Hey Gerard,

That looks pretty cool. I had to switch back from Beta to Stable so for now don't have any native SOnos control from Domoticz, but I'm using jishi's node script, which works pretty good for now.

Would it be possible to build something similar to how his 'clipall' command works, as a native Notification in Domoticz?

https://github.com/jishi/node-sonos-http-api
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 »

The test version of the new plugin is nearly ready.
It will have on option to play a file on the Sonos via the notification system in Domoticz :D

That way a file can be played from any other switch or LUA by sending it as a notification to the Sonos.
The Sonos will then play that file and after that continue playing the song (on the same position) or radio station it was playing before the notification.

I aim to have the test version ready this weekend so you can also try it yourself.
screenprint_notification.png
screenprint_notification.png (218.87 KiB) Viewed 3420 times
Not using Domoticz anymore
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Python plugin: Sonos

Post by leecollings »

This looks brilliant! Does this single notification get played to all sonos speakers in the system, or is there any control over which ones can be applied?

Is there any idea, on how long the process usually takes to go from this stage to appearing in the stable release?

WHilst on that subject, is there any updated roadmap or schedule for the next stable release?
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 »

The notification will get played on the Sonos you choose in the overview with the checkboxes. So if you have for example 2 Sonos, you can both select them and the message will be played on both.

The beauty of the Python plugins is that is independent from the Domoticz releases (except for breaking changes in the Python framework in Domoticz of course).
So I am currently working on the plugin with the latest Domoticz stable version from 30th July.
Once the plugin is ready, you can just add the plugin to Domoticz and it will be available for you. No need to wait for a Domoticz release, assuming you have the latest stable version in use.

Currently working on a way to show your favorite TuneIn radio stations in a Domoticz selector switch. Once that is added I need to do some code cleanup and after that the plugin is ready for testing.
Not using Domoticz anymore
Skippiemanz
Posts: 230
Joined: Sunday 14 July 2013 20:21
Target OS: Linux
Domoticz version: 4.10233
Location: Alkmaar, The Netherlands
Contact:

Re: Python plugin: Sonos

Post by Skippiemanz »

Wow! Great updates! Can't wait to test your plugin!
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Python plugin: Sonos

Post by leecollings »

G3rard wrote:The notification will get played on the Sonos you choose in the overview with the checkboxes. So if you have for example 2 Sonos, you can both select them and the message will be played on both.

The beauty of the Python plugins is that is independent from the Domoticz releases (except for breaking changes in the Python framework in Domoticz of course).
So I am currently working on the plugin with the latest Domoticz stable version from 30th July.
Once the plugin is ready, you can just add the plugin to Domoticz and it will be available for you. No need to wait for a Domoticz release, assuming you have the latest stable version in use.

Currently working on a way to show your favorite TuneIn radio stations in a Domoticz selector switch. Once that is added I need to do some code cleanup and after that the plugin is ready for testing.
Sounds pretty awesome. I'm hoping this plugin will have the ability to instantly play stored MP3 messages for notifications, with minimal delay. I'm currently using the Node Sonos http api for a doorbell, but there's anywhere between 5 - 15 seconds of delay between the button push and the audio played, which isn't ideal.

One last thing, where can I find your plugin? Is it currently on GH?
User avatar
Dynamic
Posts: 109
Joined: Friday 12 July 2013 14:50
Target OS: -
Domoticz version:
Location: Enschede
Contact:

Re: Python plugin: Sonos

Post by Dynamic »

Looks awesome... Can't wait to try it out!
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Python plugin: Sonos

Post by leecollings »

Hey Gerard,

Looking at your forked GH repo (https://github.com/gerard33/sonos-php), and just want to ask a question.

Do 'zones' have to be single players via IP, or can you also create zones that feature an array of IPs?
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 »

That is a php Sonos solution, it is not the Python script I am working on now.

The Python script is not yet on Github. Will place it there asap and post it there. But I still need some time to finish the radio station favorites and clean up the code.
Not using Domoticz anymore
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 »

The new version of the Sonos Python plugin is ready for testing.
See this topic viewtopic.php?f=65&t=18710#p144455.

For any questions/discussions please make a post in that topic.
Not using Domoticz anymore
junr
Posts: 6
Joined: Tuesday 07 June 2016 23:02
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Python plugin: Sonos [old version]

Post by junr »

Thanks!!!

The testing has started ;-)
RFXcom | Toon | Zware | Sonos |
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Python plugin: Sonos [old version]

Post by leecollings »

Hey,

What's the update to this? Nearly a year ago, is the plugin ready for stable release yet?

I'm itching to integrate this into my system!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest