Sonos plugin

[quote=“guessed, post:278, topic:169644”]There are a lot of changes going in to trunk right now to reshape the Plugin. I’ve reset the download link to get the last stable/referenced version (18) for general use.

trunk itself is largely untested, so shouldn’t be the reference for general downloads (unless you can program/debug and/or like pain)[/quote]

@guessed, as it seems the next Sonos plugin will be an almost completely re-engineered version, can I propose that we start an entirely new thread for it e.g “Sonos Plugin XP” or something just to differentiate it from @ankers original (no idea why a suffix of ‘XP’ sprung to mind :wink: ) ?

A number of plugins here continue to use the same post yet have evolved far beyond their original post’s release details, meaning comments made on e.g page 1-10 are basically redundant, and as a user, you often get confused by the history.

So, in the absence of dedicated child pages (re: my recent poll) for plugins in this forum, I don’t think I would be alone in thinking that it would really help to have a significant release/update made to stand out on its own?

This particular thread could then be signed off/referenced and maybe even locked (if @anker agrees) thus focussing all efforts and attention on the new release.

[quote=“parkerc, post:281, topic:169644”][quote=“guessed, post:278, topic:169644”]There are a lot of changes going in to trunk right now to reshape the Plugin. I’ve reset the download link to get the last stable/referenced version (18) for general use.

trunk itself is largely untested, so shouldn’t be the reference for general downloads (unless you can program/debug and/or like pain)[/quote]

@guessed, as it seems the next Sonos plugin will be an almost completely re-engineered version, can I propose that we start an entirely new thread for it e.g “Sonos Plugin XP” or something just to differentiate it from @ankers original (no idea why a suffix of ‘XP’ sprung to mind :wink: ) ?

A number of plugins here continue to use the same post yet have evolved far beyond their original post’s release details, meaning comments made on e.g page 1-10 are basically redundant, and as a user, you often get confused by the history.

So, in the absence of dedicated child pages (re: my recent poll) for plugins in this forum, I don’t think I would be alone in thinking that it would really help to have a significant release/update made to stand out on its own?

This particular thread could then be signed off/referenced and maybe even locked (if @anker agrees) thus focussing all efforts and attention on the new release.[/quote]

I share the idea.

Looking forward for the new plug in!!!

And how to discover that ?
With appropriate tools, I imagine we can list all the callbacks available for this service ?

[quote=“guessed, post:279, topic:169644”]I looked at the JSON and it has a bunch of problems. I’ll try to get around to fixing that. Until then, folks should be using version 18, which was posted a few pages back and I’ve now linked from the Wiki page.

I was using version 18, but I re-upped the files anyway. I have the sonos device set with my zp IP and mac. I still don’t get the control options form scene advanced. I must be doing something wrong.

Ap15e sends me this URL: Blog - Mikula Beutl
I don’t know if it can help or if the link was already known.

The functions have fairly generic parameters (string) so you’ll actually need to see the calls in action, from a Sonos CP.

Easiest way to capture that data is Wireshark or tcpdump, using the Mac/Windows Sonos CP

[quote=“lolodomo, post:285, topic:169644”]Ap15e sends me this URL: Blog - Mikula Beutl
I don’t know if it can help or if the link was already known.[/quote]

[quote=“guessed, post:286, topic:169644”]The functions have fairly generic parameters (string) so you’ll actually need to see the calls in action, from a Sonos CP.

Easiest way to capture that data is Wireshark or tcpdump, using the Mac/Windows Sonos CP

[quote=“lolodomo, post:285, topic:169644”]Ap15e sends me this URL: Blog - Mikula Beutl
I don’t know if it can help or if the link was already known.[/quote][/quote]

Is it in your TODO list ? :wink:

The changes are either additive, or structural. So far it’s intended to keep the existing interfaces (up for discussion) to make it so people can get the extras without changing existing usages.

The best place for documentation is the Wiki associated with the code.mios.com space, not the forum. Similarly that should be the place people go to find out how to use it, set it up, APIs exposed, sample code, etc.

When changes are ready to be used they’ll be announced here, along with problems found as a result.

The changes so far are things like:
a) addition/exposure of a set of UPnP ACTION hooks
These are there, but not yet callable since I’m not yet including the S_ files that go with them. The intent is that you would use these to script in the UPnP manner, and there would be less need to use the custom methods. Then, if you saw a technique for controlling Sonos on another forum, it would be quick to translate it over since the calls would be consistent.

b) addition of [tt]Say[/tt] (custom) method for TTS
This is experimental, and defendant upon Google, but it’s intent is to have it speak the text specified. It still needs a lot of work to give it the right MetaDaa so it doesn’t play in a loop.

c) Periodic sampling of Various Sonos MetaData.
This is stuff that, in UPnP you’d normally SUBSCRIBE to, but I currently poll. This is done for scene scripting, but also to improve (eventually) the Dasboard display with what’s currently playing (etc)

d) eliminate redundant Tab sections from JSON file
There were 3x entire copies of the tab-sets defined in the file, so I reduced it down to what’s needed. Likely this is what was causing the problems for the user loading it. Not sure where they came from, but they’re a lot better now.

Right now these are largely inline in the I_ file, but they’ll eventually have their implementations moved to the L_ library file, leving only stubs in the Sonos I_ file. Then the lib can be used by others.

[quote=“parkerc, post:281, topic:169644”][quote=“guessed, post:278, topic:169644”]There are a lot of changes going in to trunk right now to reshape the Plugin. I’ve reset the download link to get the last stable/referenced version (18) for general use.

trunk itself is largely untested, so shouldn’t be the reference for general downloads (unless you can program/debug and/or like pain)[/quote]

@guessed, as it seems the next Sonos plugin will be an almost completely re-engineered version, can I propose that we start an entirely new thread for it e.g “Sonos Plugin XP” or something just to differentiate it from @ankers original (no idea why a suffix of ‘XP’ sprung to mind :wink: ) ?

A number of plugins here continue to use the same post yet have evolved far beyond their original post’s release details, meaning comments made on e.g page 1-10 are basically redundant, and as a user, you often get confused by the history.

So, in the absence of dedicated child pages (re: my recent poll) for plugins in this forum, I don’t think I would be alone in thinking that it would really help to have a significant release/update made to stand out on its own?

This particular thread could then be signed off/referenced and maybe even locked (if @anker agrees) thus focussing all efforts and attention on the new release.[/quote]

Not really. I’ll add the hooks so that people can make the calls, but it’ll be up to folks to, over time, work out what to pass.

BTW: there is another way to do it by telling the Sonos to play a Specific URI, but I don’t have the link handy.

There are all sorts on interesting info in this thread
http://forums.sonos.com/showthread.php?t=7718&page=4

[quote=“lolodomo, post:287, topic:169644”][quote=“guessed, post:286, topic:169644”]The functions have fairly generic parameters (string) so you’ll actually need to see the calls in action, from a Sonos CP.

Easiest way to capture that data is Wireshark or tcpdump, using the Mac/Windows Sonos CP

[quote=“lolodomo, post:285, topic:169644”]Ap15e sends me this URL: Blog - Mikula Beutl
I don’t know if it can help or if the link was already known.[/quote][/quote]

Is it in your TODO list ? ;-)[/quote]

@Intrepid,
This typically occurs when the Service File ([tt]S_Sonos1.xml[/tt]) is either missing or damaged. Vera “skips over” these in this case, and the result is that they’re missing from the selection lists (and you also cannot programmatically call the actions either)

[quote=“Intrepid, post:284, topic:169644”][quote=“guessed, post:279, topic:169644”]I looked at the JSON and it has a bunch of problems. I’ll try to get around to fixing that. Until then, folks should be using version 18, which was posted a few pages back and I’ve now linked from the Wiki page.

I was using version 18, but I re-upped the files anyway. I have the sonos device set with my zp IP and mac. I still don’t get the control options form scene advanced. I must be doing something wrong.[/quote]

@lolodomo,
You can open a URL of the form, using SetURIToPlay, to something like:
[tt]x-rincon-stream:RINCON_1400[/tt]

Where is the MAC address of your Sonos, like [tt]0005AE…[/tt] Etc

When you do that, it’ll stream the LineIn. I believe this also works across Sonos units.

Trying to create a scene with the Sonos Device using the version 18 files that @guessed referred to earlier, I still get no commands in the drop down list. The screen shot is attached.

Also - I noticed that after uploading the 4 sonos files, checking the restart box and restarting Luup, the D_, I_, L_, S_ sonos files are not in the list of Luup Files. Shouldn’t they be there? I am able to create a Sonos device though.

@bobemorgan

I had the same thing a while back, and it turned out (i think) to be due to the fact I was downloading the files individually rather than as the available zip file with them all in. Once I used the zip file I could see the other services.

For those wanting to live a little on the wild side, I’ve wrapped up an initial set of modifications. These should work equally on UI4 and UI5.

The changes include:
a) A Rudimentary “Current Status” display on the Dashboard of UI4 and UI5.
This currently attempts to determine the MP3 and/or Radio station you’re playing, and puts it into the State variable “[tt]CurrentStatus[/tt]” which is displayed on the Dashboard. The mechanism to determine this isn’t perfect, so sometimes it’ll display “No Title”, “Unknown Title”, “Unknown Artist” or “No information”.

If these occur, please provide a copy of the log lines containing the string “[tt]DIDL-Lite[/tt]”.

b) Many more Service Actions implemented from [tt]urn:upnp-org:serviceId:AVTransport[/tt]
These will show up under Scene actions. There’s a lot of them and there’s not a lot of doc as to what they all do, feel free to experiment away…

c) Integration of the [tt]Say[/tt] method for TTS
This has been discussed in another thread, so I won’t cover it all here. It will, however, “repeat” the text over and over again, as I haven’t worked out a [clean] mechanism to get the Sonos to only play it once.
Since it uses Google services, there’s no guarantee it won’t simply be shutdown like other services recently. When that happens, it’s likely this method will be changed to be a no-op.

d) A large internals redo, to make it easier to add new services.
The library [tt]L_Sonos1.lua[/tt] got a slight overhaul so that it can dynamically instantiate UPnP Action handlers for a given service. This library isn’t ready for others to use just yet, but it meant that the internals of [tt]I_Sonos1.xml[/tt] are now a lot cleaner to read… and it’s a ton easier to write new handlers.

We now make calls like:

AVTransport = upnp.service(ip, ipPort, UPNP_AVTRANSPORT) ... status, tmp = AVTransport.GetTransportSettings({InstanceID="0"})

and the [tt]L_Sonos1.xml[/tt] library will now dynamically materialize a “[tt]GetTransportSettings[/tt]” function to handle it, without having to code them one-by-one. Once the return parameter mechanism can be better formalized, this will make it a LOT easier for people to write Lua Scene scripts that perform compound UPnP steps on the Sonos.

Since they’re not “formal” yet, I’m publishing them here (for feedback). Once enough time has passed for feedback, I’ll make the necessary changes, and change the code.mios.com Wiki page.

I’ve left Debug mode on, so you’ll get a lot of output in [tt]/var/log/cmh/LuaUPnP.log[/tt]. Feel free to peruse.

Anyhow, for those wanting to try the new build, you can download it from here:
0.21 in tags – Sonos Wireless HiFi Music Systems

Screenshots for the basic Dashboard displays (UI4/UI5) attached for those interested.

I am impatient to test that 8)
I should receive my first Sonos during the coming week.

Awesome progress!

… one more thing…

e) Greatly extend the properties that are retrieved from the Sonos, as service variables for scripting.
You can see in the attached screenshots that we now fetch a whole bunch of state from the running Sonos device. This includes stuff like what state it’s currently in (“PLAYING”, etc), the URI being used, the name of the Device, Playing time (for local MP3’s, etc)

These are all being fetched into their standard UPnP ServiceId’s, every 30 seconds if they exist. If we can exert enough pressure to address Bug 2529 addressed, then we can have “live” updates, similar to how the Sonos control panels work.

Here’s an example of a service variable that’s fetched.
[tt] urn:upnp-org:AVTransport[/tt] → [tt]RelativeTimePosition[/tt]

@anker: In some cases, there were overlaps with the ones you’ve already done. In these cases, I’ve used the UPnP-standard naming model, but left the original ones in place for backwards compatibility. Over time, I think we should ween out the non-standard service-names – at least in the case where a standardized UPnP serviceId already exists.

Either way, some corrections were needed since the serviceId’s should have [tt]:serviceId:[/tt] in the middle of them.

[tt]urn:schemas-micasaverde-com:device:avmisc:1[/tt] → [tt]ZoneName[/tt]
[tt]upnp-org:serviceId:DeviceProperties[/tt] → [tt]ZoneName[/tt]

Anyhow, right now we have both.

How best do we do we ‘exert pressure’?

The updated plugin looks really good, I’ll be updating later on tonight.

That bug was filed as a result of some research that @Ap15e did on UPnP in Vera. There’s a long list of items it doesn’t do from a UPnP standpoint, but there’s a relatively short list of items that (if fixed) would mean that we could write it… without further dependancies on MCV (albeit at somewhat of a coding burden on us)

This specific bug is one of those items. If they fix that bug we can go a very long way to being able to build a control point, which is basically what the Sonos Plugin is doing, but with “live” updates.

This can be extended to most of the other AV Gear plugins (Onkyo, Denon, etc) for similar effect.

ie. a Scene that activates the moment your AV Receiver is turned on, or when you “UnMute” your Sonos, or start playing something.

For, for a start, we’d need folks to keep this post “fresh” with updates from community members that support the fix:
http://forum.micasaverde.com/index.php/topic,10182.0.html

The more members that support it, the higher likelyhood this [very specific] issue will be addressed. Given that it’s about 5 lines of code, across two files, it’s a very scoped change.

… but it needs visibility to get scheduled by @mcvflorin.