Morphing the Sonos plugin into a Squeezebox plugin

[ul][li]Install the latest LMS (>=7.7.2)[/li]
[li]If the LMS server log contains something like ‘Couldn’t call Slim::Plugin::UPnP::Plugin->initPlugin: Network::IPv4Addr: invalid netmask specification’, you’ll have to repair the LMS UPnP server: Patch [tt]Discovery.pm[/tt] (instructions: [tt]http://forums.slimdevices.com/archive/index.php/t-91315.html[/tt]) and restart the LMS.[/li]
[li]Download the Sonos plugin from [tt]http://forum.micasaverde.com/index.php/topic,8505.msg62780.html#msg62780[/tt] and patch [tt]I_Sonos1.xml[/tt]: [tt]ipPort[/tt] for LMS is [tt]9000[/tt], [tt]AVTransport[/tt] URL is [tt]http://%s:%s/plugins/UPnP/MediaRenderer/AVTransport/control[/tt], [tt]RenderingControl[/tt] URL is [tt]http://%s:%s/plugins/UPnP/MediaRenderer/RenderingControl/control[/tt] (please note the lower case ‘c’!).[/li]
[li]Install the modified Sonos plugin and set the IP address of your LMS.[/li]
[li]Optional: Install SoftSqueeze.[/li][/ul]

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

From [tt]SOAPserver.pm[/tt]:

	# 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;
	}
[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

@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 [tt]POST[/tt] 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…

@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.

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 [tt]?playerid=[/tt] 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):

[ul][li][tt]L_Sonos1.lua[/tt]: replace [tt][“Content-Type”] = “application/x-www-form-urlencoded”[/tt] with [tt][“Content-Type”] = “text/xml”[/tt][/li]
[li][tt]I_Sonos1.xml[/tt]: append [tt]?playerid=[/tt] to [tt]UPNP_AVTRANSPORT_URL[/tt] and [tt]UPNP_RENDERING_CONTROL_URL[/tt][/li][/ul]

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

Hi Ap15e,
Any comments???

Ta
Stu

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.

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!

[quote=“trouty00, post:8, topic:170577”]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![/quote]

@trouty00

Does homeseer support Squeezbox?

@trouty00

Does homeseer support Squeezbox?

Yup and pretty well from what I remember doing my testing. You pay forit but it works.

[quote=“trouty00, post:8, topic:170577”]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![/quote]

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.

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?

Please ask the author of the Sonos plugin to incorporate my changes into the Sonos plugin. The Sonos plugin should read the [tt]UPnP controlURL[/tt]s from the device description. Currently, the [tt]controlURL[/tt]s are hardcoded and have to be changed for Squeezebox support.

@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.

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?

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.

@trouty00,

Please find attached my modifications.
Set the MAC addresses in [tt]I_Sonos1.xml[/tt] to the MAC address of your player (IP address might work, too).

@guessed,

Yes, the ‘UPnP Lib’ is clean.

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.

No need to augment the lib, but we don’t need the lib anymore: we know how to fix [tt]UPnP[/tt] devices wrongly imported by MiOS.

... 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?

Yes, I’ve cracked the [tt]MiOS-UPnP[/tt] nut - and only [tt]GENA[/tt] separates me from [tt]MiOS-UPnP[/tt] nirvana. :slight_smile:

No, I won’t invest any more time in writing and modifying Luup device drivers for devices that are [tt]UPnP[/tt] compliant.

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.

That’s an very easy one:

Install LMS 7.7.2 or later version,
enable [tt]UPnP[/tt] support in LMS,
fix [tt]UPnP[/tt] support in LMS if necessary (see first message in this thread),
import your LMS player(s) as [tt]UPnP[/tt] devices via MiOS,
fix the player device(s) imported via MiOS using my instructions,
use [tt]luup.call_action[/tt] for [tt]urn:upnp-org:serviceId:AVTransport / GetTransportInfo[/tt],
the return argument you’re intested in is [tt]CurrentTransportState[/tt].

Edit:
Untested, but should work if the native [tt]UPnP[/tt] support in LMS is sufficiently mature.

@Ap15e,

ok so i found your fix thread over at http://forum.micasaverde.com/index.php/topic,10165.0.html but Im stuck at the point to download the SCPD manually, not sure how I go about doing this.

I have found the correct file and first had to unencrypt, I guess once i have the correct SCDP file I can then make the changes required and then i just need to figure out a way to re-encrypt otherwise I’m guessing vera will be confused!

I really appreciate your help with all of this but it shouldn’t have to be this complicated!

In situ download: use wget

… or use a web browser of your choice and upload the file to Vera.

I did try to pul the file down using a web browser but got page not found, I’m thing now that the code you provided probably needs to be tweaked and the bit before av transport needs to match the uid of the upnp device which I added. I have found the un in the device JSON file so Will try when I get home tonight. Feel a little stupid but all a learning excercise!

http://192.168.X.Y:31416/"change to udn of upnp device created"/AVTransport/scpd.xml

Upnp is definitely working as I can utilise it from the iPad and see it within windows media player.