Sonos plugin

[quote=“JV, post:40, topic:169644”]Just wanted to say: Thanks a lot for the Sonos plugin! I can now add the ‘stop’ command to my ‘go to bed scene’s’ etc and issue the play command at 7:15h so I don’t have to find my remote control anymore when I am still half asleep.

Brilliant work![/quote]

@anker did a great job of knocking it out, it was great to see folks getting creative on this stuff.

He has a much-improved Mute-Toggle implementation, so I’m keen to see him add TortoiseSVN and take it for a spin (hint, hint) 8)

:slight_smile: hint okay - I just need the time some time to do this. Hopefully during Xmas.

/anker

Thanks @anker!

One you get to know me, you’ll know I rib everyone at some time or another (and can readily take being ribbed back, it’s customary where I’m from)…

No rush, just impressed with what you’d managed to pull together from bits and pieces, and keen to see what you can achieve next :wink:

First of all I am very happy that you guys are working on Sonos Support!!

Unfortunately I can’t get it to work…

In below stated logging I tried to mute my living room sonos (192.168.1.108), device Id = 16. I tried:

http://192.168.1.100:49451/data_request?id=lu_action&DeviceNum=16&serviceId=urn:micasaverde-com:serviceId:Volume1&action=Mute
http://192.168.1.100:49451/data_request?id=lu_action&DeviceNum=16&serviceId=urn:micasaverde-com:serviceId:Sonos1&action=Mute
SQrmote

Vera 2
UI5
log: http://pastebin.com/3LvDKwS2

Any one have an idea?

Thnx,

Mark

This is not compatible at the moment with UI5.

I can confirm it works after downgrading to UI4.

This plugins works in version 1.5.252 (V2) , 1.5.249 (V3).

@mcvflorin,

You keep referencing version 1.5.252 for V2 in this and a few other posts, but I can’t upgrade to it. When will it be available?

This week, probably on Friday.

Note that we won’t be able to put this into the app store until bug 2000 is addressed. It should be possible to side load it though.

We need the bug fix for Clean dual-mode UI4-UI5 support

FYI this is not working under 1.5.249 which I am testing currently. Below are the errors from the log.

01 12/22/11 22:39:35.133 luup_device_supports_service interface 0xfbfd80 args 2 <0x2c22d680>
01 12/22/11 22:39:35.133 GetLuaInterface can’t find device type: 3/0xfccc e0 str: 105 <0x2c22d680>
01 12/22/11 22:39:35.133 luup_device_supports_service interface 0xfbfd80 args 2 <0x2c22d680>
50 12/22/11 22:41:20.993 luup_log:163: SONOS action: Play <0x2e02d680>
50 12/22/11 22:41:20.994 luup_log:163: SONOS SOAP request: <?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s=“http://schemas.xmlsoap.org/soap/envelope/” s:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding/”><s:Body><u:Play xmlns:u=“urn:schemas-upnp-org:service:AVTransport:1”>0,1</u:Play></s:Body></s:Envelope> <0x2e02d680>

I have three Sonos players in my house right now (ZP90 and two S3’s) and want more! Great product!
I’d try this out with my V3 if I can help since I have the equipment.
I know UI5 is the priority so I’m hangin there but this is the the kind implementation I’d love to see.
Just be gentle…I’m learning as I go here :wink:

@Guessed… I can’t believe you haven’t bought a Sonos controller yet ??? ;D

[quote=“guessed, post:39, topic:169644”]I checked in a new version this morning, and it’s in trunk in code.mios.com.

This version moves to using a library ([tt]L_Sonos1.lua[/tt]) to contain all the generic UPnP bits, and moves to using structured Lua Tables for the named function/action parameters to the UPnP calls… Internally it converts them to the necessary XML to send over the wire.

Sending data is handled, but I’m not post-processing the receipt yet, as I’m still working out how I want the results to look (as a Lua Table structure).

You should go ahead and get yourself setup with a Windows SVN client install (like http://tortoisesvn.net/, no affiliation etc) so you can make localized tweaks as needed.

Things that are UPnP-generic will go into the [tt]L_Sonos1.lua[/tt], and the rest (calls, etc) go into [tt]I_Sonos1.xml[/tt]

I have some fairly large improvements to make to the calling model, after the XML response stuff is sorted out, but these might have to wait until CY12.

Thankyou, you saved me from having to go out and buy a Sonos (I’ve been following a bunch of them on eBay)[/quote]

@guessed

I cannot get this to work - here is my finding:

I get an error on the sonosStartup function statement: “upnp = require(“L_Sonos1”)”

The log shows: function sonosStartup failed [string “…”]:32: attempt to index upvalue ‘upnp’ (a boolean value)

I have checked that the upload of the lua file is correct (so I believe anyway)

/anker

btw: I have now the svn installed… :wink:

ok, that’s really odd.

I did make a mistake in the [tt]L_Sonos1.lua[/tt] file, which I’ve now fixed/checked-in, but it wouldn’t have caused that type of error.

Whilst making the fix I made, I also added a little extra logging so it’s easier to debug once it is working, but it your case you’re not even getting that far into that code (the library isn’t loading)

I’m running UI4 1.1.1337 on my Vera2, and the log snippet of the Mute request is below (I have a slightly different URL since I’m running against my Onkyo instead of a Sonos). In your case, it’s like the [tt]require[/tt] call is failing for some reason, which would imply that either the Lua upload had problems (HTML version instead of Original version from Trunk) or that the [tt]I_Sonos1.xml[/tt] was out of date somehow.

12 01/02/12 1:31:13.672 luvd_get_info_data_request starting /data_request?id=lu_action&DeviceNum=295&serviceId=urn:micasaverde-com:serviceId:Volume1&action=Mute pMem 0x10a6000/17457152 diff: 9818112 <0x300d> 10 01/02/12 1:31:13.673 JobHandler_LuaUPnP::HandleRequest id lu_action request pMem 0x10a6000/17457152 diff: 9818112 <0x300d> 10 01/02/12 1:31:13.675 sbrk JobHandler_LuaUPnP::HandleActionRequest from IP:0.0.0.0 pMem 0x10a6000/17457152 diff: 9818112 <0x300d> 08 01/02/12 1:31:13.675 JobHandler_LuaUPnP::HandleActionRequest device: 295 service: urn:micasaverde-com:serviceId:Volume1 action: Mute <0x300d> 08 01/02/12 1:31:13.676 JobHandler_LuaUPnP::HandleActionRequest argument DeviceNum=295 <0x300d> 08 01/02/12 1:31:13.677 JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:Volume1 <0x300d> 08 01/02/12 1:31:13.678 JobHandler_LuaUPnP::HandleActionRequest argument action=Mute <0x300d> 01 01/02/12 1:31:13.681 luup_log:295: Sonos: debug UPnP_request: url=[http://192.168.x.xxx:8888/upnp_control_0], body=[<?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <s:Body> <u:SetMute xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><DesiredMute>1</DesiredMute><Channel>Master</Channel></u:SetMute> </s:Body> </s:Envelope>] <0x300d> 01 01/02/12 1:31:13.700 luup_log:295: Sonos: debug UPnP_request: status=1 statusMsg=200 result=[<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetMuteResponse xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"></u:SetMuteResponse></s:Body></s:Envelope>] <0x300d>

hi guessed,

I am running UI4 on vera 2 with 1.1.1250 (or 1.1.1256) as I recall it. Maybe this could cause the trouble?

I will check when I get home today and I will check the content of the lua file to make sure that the file is not corrupted.

/anker

Maybe. I don’t remember when they introduced support for Lua Libraries. Part of the overall solution was to not compress [tt].lua[/tt] files upon upload. If you find that you’ve got a [tt]L_Sonos1.lua.lzo[/tt] file instead of a [tt]L_Sonos1.lua[/tt], in the [tt]/etc/cmh-ludl/[/tt] directory then that could cause it.

This is what mine looks like:

[tt]root@MiOS_xxxxx:/etc/cmh-ludl# ls -l Sonos
-rw-r–r-- 1 root root 567 Jan 1 18:06 D_Sonos1.xml.lzo
-rw-r–r-- 1 root root 1253 Jan 1 18:06 I_Sonos1.xml.lzo
-rw-r–r-- 1 root root 4462 Jan 1 18:05 L_Sonos1.lua
-rw-r–r-- 1 root root 214 Jan 1 18:06 S_Sonos1.xml.lzo
[/tt]

@guessed:

Thanks! My lua file seemed corrupted and I just replaced it manually with the latest trunk version and now all actions are working perfectly. I cannot see this mentioned as a fix in the latter released fw versions though.

I will however need to have a look if an upgrade will help me out here. I was under the impression that my version 1.1.1245 was the latest stable release, but maybe I lost track of this? :wink:

What is the latest version you would recommend for Vera 1?

/anker

@guessed:

I have made a new revision (11) trying to add some logic for a upnp DeviceProperties call. The upnp call is succesfull from the logs and returns XML that is usefull. I however cannot find out your table code and find out what the UPnP_request function returns.

Can you help me out on examles on how I should read the data ???

Here is my code snip that I have added:

[code]-- Get Device info and populate variables
local l_DeviceInfo = upnp.UPnP_request(luup.devices[lul_device].ip, ipPort, UPNP_DEVICE_PROPERTIES_URL,
“GetZoneAttributes”, upnp.UPNP_DEVICE_PROPERTIES_SID,
{CurrentZoneName=“”, CurrentIcon=“”})

– The following fails as Deviceinfo is nil… what am I doing wrong? (The UPnP call is successfull)
– log("DeviceInfo: " … DeviceInfo)[/code]

i have commented my trouble out, so that the files are operational.

/anker

I read the whole thread with bated breath. I was looking for something like this.
But unfortunately this plugin doesn’t work or I can’t set it up.
I did everything as it was written: ataching luup files, creating the device and when I wanted to set up a scene I simply couldn’t do it. There was no device to choose when I wanted to create the scene.
And it didn’t matter if I had the first files or the latest with diffs.
I have Sonos ZP 100 and Vera 2 (UI 4).
Any idea what could go wrong?

@Peraverde

You need to create a new scene and choose the ‘advance’ tab and ‘Pick a device’. Here you will find the device just created and can use the actions currently defined.

Pls let me know how it goes.

/anker