Device List Showing Both Parent and Child Device ID's

On an older thread “akbooer” was kind enough to provide the code to produce a device list sorted by device number as follows:


local file = io.open("/www/devlist.txt", "w")
file:write("[DeviceNo / id] device names on " .. os.date() .. "\n")
local idx = {}
for deviceNo in pairs(luup.devices) do
    idx[#idx+1] = deviceNo
end
table.sort (idx)
for _,deviceNo in ipairs(idx) do
    d = luup.devices[deviceNo]
    file:write(string.format('[%03d / %s] %s \n', deviceNo, d.id, d.description))
end
file:close()

Would anyone be able to modify the code to provide the Device ID of both the device as well as its “parent” if any?

Well, I can do that:

local file = io.open("/www/devlist.txt", "w")
file:write("[DeviceNo / id / parent] device names on " .. os.date() .. "\n")
local idx = {}
for deviceNo in pairs(luup.devices) do
    idx[#idx+1] = deviceNo
end
table.sort (idx)
for _,deviceNo in ipairs(idx) do
    d = luup.devices[deviceNo]
    file:write(string.format('[%03d / %s / %s] %s \n', deviceNo, d.device_num_parent, d.id, d.description))
end
file:close()

I am starting from scratch. I can somewhat follow the code, but how do I implement it with my Vera Plus? Do I copy and paste? Paste where? Any guidance on where and how to run code on the Vera Plus? I’m not looking for hand holding, but am looking for some kind of resource to help me run routines like the one above. luup? lua? I don’t know the difference???

Copy the above code then on your Vera Plus go to Apps - Develop Apps - Test Luup code (Lua)

Paste it in there and run the code.

Alternatively you can just enter this URL into a browser.

http://VERA-IP:3480/data_request?id=invoke

Best Home Automation shopping experience. Shop at getvera!

© 2020 Vera Control Ltd., All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules