We have moved at community.getvera.com

Author Topic: Morphing the Sonos plugin into a Squeezebox plugin  (Read 12143 times)

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Morphing the Sonos plugin into a Squeezebox plugin
« on: February 18, 2012, 09:50:05 am »

Remaining problem:
LMS (as of 7.7.2) doesn't support application/x-www-form-urlencoded.

From SOAPserver.pm:
Code: [Select]
# We only handle text/xml content
if ( !$request->header('Content-Type') || $request->header('Content-Type') !~ m{^text/xml}i ) {
$log->warn( 'SOAPServer: Invalid content-type for request: ' . $request->header('Content-Type') );
fault( $httpClient, $response, 401 );
return;
}

Code: [Select]
[12-02-18 15:16:24.0796] Slim::Plugin::UPnP::SOAPServer::processControl (69) SOAPServer: Invalid content-type for request: application/x-www-form-urlencoded
[12-02-18 15:16:24.0830] Slim::Plugin::UPnP::SOAPServer::fault (227) UPnP fault: 401 / Invalid Action
« Last Edit: February 18, 2012, 09:52:07 am by Ap15e »

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Morphing the Sonos plugin into a Squeezebox plugin
« Reply #1 on: February 18, 2012, 01:51:05 pm »
@Ap15e,
Have you tried modding the Lua lib of the Sonos plugin to send the different content type? 

As long as it doesn't mind the actual POST body encoding used, and it's only whining about the Header sent, we can substitute/parametrize the Content-Type header to it can support both.

ie. an array parameter to the lib calls that represents any "additional or override" headers & values that the caller would like sent...

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: Morphing the Sonos plugin into a Squeezebox plugin
« Reply #2 on: February 18, 2012, 04:44:57 pm »
Quote
@Ap15e,
Have you tried modding the Lua lib of the Sonos plugin to send the different content type?

Yes, of course I've tried modding your Lua lib, modding some LMS Perl modules, using Wireshark to get an idea what the difference between the SOAP request used by Device Spy and the SOAP request issued by your Lua Lib is, ... - finally, I gave up for this time.

Device Spy is able to control LMS, so sniffing the SOAP requests from Device Spy seems to be the best approach to tackle the problem.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: Morphing the Sonos plugin into a Squeezebox plugin
« Reply #3 on: February 19, 2012, 10:12:24 am »
Success!

Wireshark captures attached (had to use a second PC because even RawCap wasn't able to capture local traffic on Windows XP ...).

Analysis:
Device Spy appends ?playerid=<MAC of player> to the Control URL - I've no idea where Device Spy gets this information from, but it totally makes sense, because otherwise the Control URL would be the same for all players.

To complete the morphing process (in addition to the modifications from post #1):
  • L_Sonos1.lua: replace ["Content-Type"] = "application/x-www-form-urlencoded" with ["Content-Type"] = "text/xml"
  • I_Sonos1.xml: append ?playerid=<MAC of player> to UPNP_AVTRANSPORT_URL and UPNP_RENDERING_CONTROL_URL

Offline trouty00

  • Full Member
  • ***
  • Posts: 207
  • Karma: +2/-1
Re: Morphing the Sonos plugin into a Squeezebox plugin
« Reply #4 on: March 18, 2012, 05:03:43 pm »
Hi,
    I'm a bit confused now with where everything is with the squeezebox plugin options and whether we now have any ultimate solution to get a great plugin,

seems like the standard one isn't even available in the app list to install now. does this sonos hack do everything you want?

Stu

Offline trouty00

  • Full Member
  • ***
  • Posts: 207
  • Karma: +2/-1
Re: Morphing the Sonos plugin into a Squeezebox plugin
« Reply #5 on: April 03, 2012, 03:23:15 am »
Hi Ap15e,
Any comments???

Ta
Stu

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: Morphing the Sonos plugin into a Squeezebox plugin
« Reply #6 on: April 03, 2012, 03:43:17 am »
IMHO, the somewhat inconsistent LMS CLI will be deprecated in favour of UPnP by Logitech. You wouldn't need a plugin at all if MiOS would properly import UPnP devices.

Offline trouty00

  • Full Member
  • ***
  • Posts: 207
  • Karma: +2/-1
Re: Morphing the Sonos plugin into a Squeezebox plugin
« Reply #7 on: April 03, 2012, 12:23:34 pm »
Hmm, and how lOng is that goin to take. I would have gone for home seer if I knew is have all this trouble.

Not very good really!

Offline aschwalb

  • Hero Member
  • *****
  • Posts: 590
  • Karma: +0/-1
Re: Morphing the Sonos plugin into a Squeezebox plugin
« Reply #8 on: April 03, 2012, 01:09:51 pm »
Hmm, and how lOng is that goin to take. I would have gone for home seer if I knew is have all this trouble.

Not very good really!

@trouty00

 Does homeseer support Squeezbox?

Offline trouty00

  • Full Member
  • ***
  • Posts: 207
  • Karma: +2/-1
Re: Morphing the Sonos plugin into a Squeezebox plugin
« Reply #9 on: April 03, 2012, 01:36:30 pm »
Quote

@trouty00

 Does homeseer support Squeezbox?

Yup and pretty well from what I remember doing my testing. You pay forit but it works.
« Last Edit: April 03, 2012, 02:03:44 pm by oTi@ »

Offline radarengineer

  • Moderator
  • Sr. Member
  • *****
  • Posts: 402
  • Karma: +4/-0
Re: Morphing the Sonos plugin into a Squeezebox plugin
« Reply #10 on: April 04, 2012, 10:33:41 am »
Hmm, and how lOng is that goin to take. I would have gone for home seer if I knew is have all this trouble.

Not very good really!

How long will what take? Logitech now supports both UPnP (as of server 7.6) and the older CLI. Homeseer supports Squeezebox using the CLI. So does Vera (via the original CLI plugin which I am supporting. If it isn't working for you I'm happy to debug it!).

@Ap15e thinks that in the future Logitech will be moving to UPnP, and is working on supporting that. It has only been supported by the Squeezebox since last November (and that was in Beta!).

You can either use the old plugin (CLI same as homeseer) or go the UPnP route as posted here by @Ap15e. It seems like the only trouble is figuring out which approach you like better... essentially you have more options on Vera. You can try both at the same time too.

Offline trouty00

  • Full Member
  • ***
  • Posts: 207
  • Karma: +2/-1
Re: Morphing the Sonos plugin into a Squeezebox plugin
« Reply #11 on: April 10, 2012, 07:33:15 am »
I attempted to do this at the weekend but didn't have a lot of success, When I created my new device it didn't seem to have any attributes, I wasn't very confident when editing the file as I'm sure there were many areas where I didn't enter the correct info as the terms detailed above come up quite often and im not sure where i should be replacing code.

Do you have an annotated version of your own files to help me out at all?

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: Morphing the Sonos plugin into a Squeezebox plugin
« Reply #12 on: April 10, 2012, 12:37:22 pm »
Please ask the author of the Sonos plugin to incorporate my changes into the Sonos plugin. The Sonos plugin should read the UPnP controlURLs from the device description. Currently, the controlURLs are hardcoded and have to be changed for Squeezebox support.

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Morphing the Sonos plugin into a Squeezebox plugin
« Reply #13 on: April 10, 2012, 11:08:56 pm »
@Ap15e,
Feel free to post the code-diffs you need directly to the Sonos thread.  You can use trunk as the baseline for any diffs that you'd like @anker or I to apply to the code, and we can take a look.

Using diffs against trunk will be the fastest way to get stuff reviewed/included without any ambiguity of what you're looking for.

Quote
The Sonos plugin should read the UPnP controlURLs from the device description. Currently, the controlURLs are hardcoded and have to be changed for Squeezebox support.

The Lib doesn't have any hardcoded controlURL's.  These are segmented correctly into the caller (the original Lib was written to be free-standing of Vera, before logging was added).

The controlURL's are all in the Sonos Device implementation file(s), where they belong.  If there's a supported API to get the details to be passed through, just let us know in the code diffs.

If I remember correctly, the Squeezebox has some extra query-string based parameters that might cause some problems and/or need for augmentation of the Lib.


... but I'm a little confused.  Your posting the other day implied you'd found the nirvana solution to UPnP in Vera.  If you've cracked that nut, why are you still going down this route?

Offline trouty00

  • Full Member
  • ***
  • Posts: 207
  • Karma: +2/-1
Re: Morphing the Sonos plugin into a Squeezebox plugin
« Reply #14 on: April 11, 2012, 11:42:32 am »
I'm also very confused by how many squeezebox plugins there are and what functions each one has. I did a quick search and found Ap15e's latest UPNP post and not sure what functionality that one offers compared to this sonos morph. Unfortunately I don't think I can use the new option posted by Ap15e as it has a dependency that it runs on windows and im running on Linux right now. If I have too I can run LMS on a windows VM I guess but not ideal.

All I really want to achieve (for now) is that a plugin is polling the media server to find out the player status so i can turn on an amp when a particular player is playing. This works when I use ipeng or web interface etc but doesnt work when i use the remote or touch screen.