Getting a device's UPnP uuid in Lua

How do I get a device’s UPnP unique ID (udn) in Luup code? It’s clearly available to the JavaScript, as shown in the screenshot.

This doesn’t work, because contrary to the documentation, there is no udn member on devices[n].

local udn = luup.devices[222].udn -- always nil

Iterating over the keys in devices[n] never lists the purported udn member.

This also doesn’t work, producing a “can’t find device type” error in the log:

local udn = luup.attr_get("udn", 222)

(I don’t believe that luup.attr_get with a number as the second parameter ever worked. It seems to want to stringify the number. No attribute, even the suggested “id” and “name” produce the same error.)

Edit: luup.attr_get() does seem to work on devices I created myself. It produces the error message only on the devices that Vera created itself from scanning the network for UPnP devices.

Edit 2: I added in a bogus device_file field and now luup.attr_get(“udn”, 222) works. Apparently Vera doesn’t approve of devices with an empty device_file, though it happily created one.

Now I do not feel so bad about not understanding this behavior. One would assume that all device params would be accessible via luup.devices[222].XXX or luup.attr_get(“XXX”, 222)

It’s in the JSON file sent to the Web … that’s why the Web has access.
I guess the code that sends/receives JSON in vera is NOT similar to the luup.attr_get/luup.attr_set code. Or maybe it is, but has a filter on the set of attributes.

I could never figure out why I could get some info and not other when I was testing String templates!

If you do not know … who would ? There are times I would really luv to be able to access the source code … It sure would be nice if a few power programmers on the forum would have a non disclosure agreement with MCV so they could peek at the source code to answer questions about the obscure behavior. They could also propose fixes to MCV team.

I personally have sent some fixes to MCV about the Java Script code and their handling of triggers (there are other bugs I saw … but did not want to make drastic changes to the code). I sent to MCFlorin … but I have no feedback about if/when they would do anything with these.