Creating UI5 dashboard control panels for UPnP devices: A worked example

Goals:

[ul][li]Import an [tt]UPnP[/tt] compliant device into MiOS.[/li]
[li]Create an UI5 dashboard control panel for the new Luup device.[/li][/ul]

Requirements:

[ul][li]Logitech Media Server (LMS) 6.7.2 (or later version) ([tt]My Media - Welcome to mysqueezebox.com!, http://downloads.slimdevices.com/nightly/[/tt])[/li]
[li]SqueezePlay (SP) ([tt]http://downloads.slimdevices.com/nightly/[/tt])[/li]
[li]Whitebear Media Server (WMS) ([tt]http://www.whitebear.ch/mediaserver[/tt])[/li]
[li]Developer Tools for UPnP Technology/Device Spy (DS) ([tt]Blog - Mikula Beutl)[/li]
[li]MiOS 1.5.x (recommendation: latest stable version)[/li]
[li][tt]UPnP[/tt] GUI Compiler (UGC) ([tt]http://forum.micasaverde.com/index.php/topic,10178.0.html[/tt])[/li][/ul]

Step-by-step instructions:

[ul][li]1. Install and start LMS (don’t forget to point LMS to your music directory; check that scanning has taken place).[/li]
[li]2. Install and start SP (My Music → Albums → → ; selected track should be playing now).[/li]
[li]3. Install and start WMS (make sure that there are no errors shown on the ‘Status’ tab and that the Whitebear icon in the status line is white).[/li]
[li]4. Install and start DS (make sure that DS lists ‘SqueezePlay (by Whitebear)’ as an UPnP device).[/li]
[li]5. Test the installation:
[list]
[li]DS: expand the line ‘SqueezePlay (by Whitebear)’,[/li]
[li]expand the line ‘urn:schemas-upnp-org:service:AVTransport:1’,[/li]
[li]double-click on ‘Pause’,[/li]
[li]press ‘Invoke’ (music should have stopped; restart the music via SP).[/li]
[/list]
[/li]
[li]6. Import ‘SqueezePlay (by Whitebear)’ into MiOS: Devices → Add Devices → Scan → Next → ‘SqueezePlay (by Whitebear)’ Add[/li]
[li]7. Reload MiOS; Devices → All: ‘SqueezePlay (by Whitebear)’ should appear as a new device.[/li]
[li]8. Unfortunately, the new Luup device is a zombie due to bug #1473 ([tt]http://bugs.micasaverde.com/view.php?id=1473[/tt]) - but there is a workaround: [tt]http://forum.micasaverde.com/index.php/topic,10165.0.html[/tt][/li]
[list]
[li]Download Apps → Develop Apps → Luup files → [tt]D_FUP_uuid%20…xml[/tt] (actual name may differ; make sure you’re downloading the right file …) (FUP=Foreign UPnP?).[/li]
[li]If the [tt]SCPDURL[/tt] or [tt]controlURL[/tt] or [tt]eventSubURL[/tt] in [tt]D_FUP_uuid%20…xml[/tt] contain relative [tt]URLs[/tt] (e.g., [tt]/upnp/scpd.xml[/tt]), use Device Spy to identify the Base [tt]URL[/tt] of your [tt]UPnP[/tt] compliant device and prepend it to relative [tt]URLs[/tt] (e.g., [tt]http://192.168.178.111:49000/upnp/scpd.xml[/tt]).[/li]
[li]Search for [tt]SCPDURL[/tt] in [tt]D_FUP_uuid%20…xml[/tt], download all remote [tt]SCPD[/tt] manually and upload them to MiOS using a unique name (e.g., [tt]D_FUP_uuid%20….xml[/tt]).[/li]
[li]Replace all [tt]SCPDURLs[/tt] in [tt]D_FUP_uuid%20…xml[/tt] with the names of the corresponding [tt]SCPD[/tt] files just uploaded to MiOS.[/li]
[li]Re-upload the modified [tt]D_FUP_uuid%20…xml[/tt] to MiOS and Reload MiOS.[/li]
[li]Note: It might be easier to use [tt]pluto-lzo[/tt] to modify the file in situ … - see [tt]http://forum.micasaverde.com/index.php/topic,10282.0.html[/tt] for a Luup script that semi-automates step 8.[/li]
[/list]
[li]9. Test the new Luup device: Automation → New scene → ‘Advanced’ → Pick a device → ‘SqueezePlay’ Add → Please select: Pause / InstanceID 0; SAVE, run the scene: SP should pause.[/li]
[li]10. Paste [tt]UGC[/tt] into the Apps → Develop Apps → Test Luup code (Lua) window, adjust [tt]UPnP_device_id[/tt] to the device number (‘Advanced’ tab: id) of the [tt]UPnP[/tt] device imported into MiOS, press ‘Go’.[/li]
[li]11. Install the device created by [tt]UGC[/tt]: Apps → Develop Apps → Create device: Description: [tt]SqueezePlay[/tt], Upnp Device Filename: [tt]D_Squeezebox_GUI.xml[/tt] → Create device[/li]
[li]12. Reload MiOS several times.[/li]
[li]13. Press the ‘Play’ button of the ‘SqueezePlay’ device on the dashboard: SP should resume playing.[/li][/ul]

continued

continued

A Luup script that implements step 8 is available at [tt]http://forum.micasaverde.com/index.php/topic,10282.0.html[/tt].

Thank you @Ap15e !!

This opens a whole new world to Vera and AV control! (I’m able to control Windows Media Player from scenes :)) )
But to take it a bit further, is it possible to execute these UPnP actions from Luup instead of creating scenes for them ?

I tried but got an error: No Foreign Control URLs for Device.

PS: I was writing a plugin to control DLNA media servers/renderers with complete SOAP Messages creation until I saw your post. This changes things a lot!

Roy.

I tried but got an error: No Foreign Control URLs for Device.

If you can call foreign UPnP actions from Vera’s scene, calling the same foreign actions via Luup should work, too.

Would you mind posting your Luup code snippet?

I tried both luup web request and luup code from the Test Luup Code window:

http://192.168.1.107/port_3480/data_request?id=lu_action&serviceId=urn:schemas-upnp-org:serviceId:AVTransport1&action=Pause&DeviceNum=32&InstanceID=0

local lul_arguments = {} lul_arguments["InstanceID"] = 0 lul_resultcode, lul_resultstring, lul_job, lul_returnarguments = luup.call_action("urn:upnp-org:serviceId:AVTransport1", "Pause", lul_arguments,32)

The message in the log was:

JobHandler_LuaUPnP::ForwardUPnPAction no control/service URL’s for 32 (nil)/(nil)

The scene was created as per the attached picture

Roy

The parameter [tt]Speed[/tt] is missing from your calls (but I doubt that adding [tt]Speed[/tt] will solve your problem).

The Pause action has only 1 parameter (InstanceID). Speed is used in the Play action.

You’re right, my mistake.

Could you post or PM all Luup device files for device 32, please?

I just noticed I was using a wrong serviceId in the Luup call :o
It’s working perfectly now!

I guess I was so overexcited by your post that I didn’t really pay attention to my code :-[

Congratulation - and thanks for following my lengthy instructions. :slight_smile:

MCV should fix the bug ASAP.

I’ve just updated the instructions for [tt]D_FUP*.xml[/tt] files that don’t contain absolute [tt]URLs[/tt] for [tt]SCPDURL, controlURL, eventSubURL[/tt] (e.g., /upnp/scpd.xml instead of http://192.168.178.111:49000/upnp/scpd.xml):

If the [tt]SCPDURL[/tt] or [tt]controlURL[/tt] or [tt]eventSubURL[/tt] in [tt]D_FUP*.xml[/tt] contain relative [tt]URLs[/tt] (e.g., [tt]/upnp/scpd.xml[/tt]), use Device Spy (see attachement) to identify the Base [tt]URL[/tt] of your [tt]UPnP[/tt] compliant device and prepend it to relative [tt]URLs[/tt] (e.g., [tt]http://192.168.178.111:49000/upnp/scpd.xml[/tt]).

In addition, I’ve generalized the Luup script for fixing defective [tt]D_FUP*.xml[/tt] files ([tt]http://forum.micasaverde.com/index.php/topic,10220.msg70052.html#msg70052[/tt]):

[ul][li]Support for (almost?) all [tt]UPnP[/tt] compliant devices (please report [tt]UPnP[/tt] devices for which the script doesn’t work).[/li]
[li]Fix [tt]D_FUP*.xml[/tt] files that don’t contain absolute [tt]SCPDURLs, controlURLs, eventSubURLs[/tt].[/li][/ul]

The generalized Luup script is available at [tt]http://forum.micasaverde.com/index.php/topic,10282.0.html[/tt].

This really helped!!! I have my upnp device imported and it works :slight_smile:

I know Ap15e has unfortunately left the building, so I am hoping somehow else can answer this question:
I don’t like to use the absolute IP address somewhere “hidden” inside the xml file. Can I use this instead:

http://luup.devices[lul_device].ip:49000/upnp/scpd.xml

instead of this: http://192.168.178.111:49000/upnp/scpd.xml
in the initial D_FUP…xml file or is it only for use in lua code?

Also I tried downloading the UPnP GUI Compiler (UGC) from google with my google account, but it seems someone needs to grant me permission. Can somebody upload this code? I would like to implement step 9/10/11 aswell (knowing of course it is unsupported :wink: )

Thanks!

Okay, tested it and it works . . . but only for a short time . .

Somehow I can’t upload a file with a name that contains a character, and the upnp device filenames generated by the vera contain a . So I worked around it by renaming the file to a short name, upload and then changing the device file name in the advanced setting of the device. Unfortunately after a while the device_file gets set back to the original filename (D_FUP_uuid 44xxxx.xml) automatically. Strange :frowning: !

@Vera1234

This is another one of Vera’s annoying quirks.

Upload your file using a short file name (without spaces) then paste and run the code below in the Test Luup code window.
Don’t forget to replace the file names strings in the code (without the .xml.lzo extension)

[code]local shortname=“shortfilename_replace”
local longname=“D_FUP_xxxx”

os.execute( ‘mv /etc/cmh-ludl/’…shortname…‘.xml.lzo "/etc/cmh-ludl/’…longname…‘.xml.lzo"’ )[/code]

Cheers,

Roy.

Thanks Roy S, that worked.

Do you by any change have the “UPnP GUI Compiler (UGC)” code?
My next step is to create some buttons, instead of creating an “advanced scene”. And I am looking for ways to do this.

I found the attached file in my downloads folder. I haven’t tried it though.
I hope it helps.

I think the spaces problem is not a Vera problem but a URL problem. As stated at: Programming in Lua : 20.3 spaces need to be escaped to either ‘+’ or %20 to be legal in a URL.

If you escape the spaces, and any other problematic characters for HTTP, then you may be able to handle the original filenames without having to modify them. Worth a shot.

Hi all,

I imported a Network binary switch light (Upnp Network light) to Vera (UI5).
after importation, I did exactly the steps mentioned in point 8 of the this post.

  • I downloaded the scpd file (related to the service). I renamed it to S_DoorBellService.xml than I uploaded it.
  • I downloaded the D_FUP_UIID…xml. I modified it like the following:

<?xml version="1.0"?>
10
urn:schemas-upnp-org:device:BinaryLight:1
DoorBell


Software Emulated DoorBell Bulb
Network DoorBell Bulb
XPC-DB1
uuid:1b8962fb-9201-4033-ac89-3329dbf464ed


urn:schemas-upnp-org:service:SwitchPower:1
urn:upnp-org:serviceId:SwitchPower.0001
VeraIPAddress:3480/S_DoorBellService.xml
VeraIPAddress:3480/_urn-upnp-org-serviceId-SwitchPower.0001_control
VeraIPAddress:3480/_urn-upnp-org-serviceId-SwitchPower.0001_event



The GUI control have two buttons (On, Off). when pressing on ON the bellow message appears:

No Foreign Control URLs for Device

Could you please explain to me: the Control URL is used for what?
and what to do to make the device function properly?
any help will be appreciated. Thanks in advance.