We have moved at community.getvera.com

Author Topic: Device List Showing Both Parent and Child Device ID's  (Read 240 times)

Offline mpress

  • Newbie
  • *
  • Posts: 3
  • Karma: +0/-0
Device List Showing Both Parent and Child Device ID's
« on: February 01, 2019, 12:14:03 pm »
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?

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: Device List Showing Both Parent and Child Device ID's
« Reply #1 on: February 01, 2019, 12:21:56 pm »
Well, I can do that:

Code: [Select]
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()
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.