Helper modules, device list?

I’ve decided that I’d like a little more control over the execution of my scenes. Primarily because I’ve found that depending on how they execute, some lights/devices don’t get updated for up to 10 seconds. So I’m working on switching over to luup code.

I’m planning on creating a module with some helper functions that make it a little easier less verbose to perform some common actions (similar to as discussed here and in other threads: http://forum.micasaverde.com/index.php/topic,24728.msg172068.html#msg172068)

I had two questions…

  1. It’s clear that others have done this. Has anybody shared their work? I don’t necessarily see the point in reinventing the wheel if there is something out there that I could use/contribute to.

  2. Is there anywhere (in the vera interface or elsewhere) where I can just get a simple list of my devices with their id number? The only way I’ve found this is by clicking into device settings, and going to the settings tab. It’d be great if I could get get a simple list of device/id pairs that I could reference when developing.

Thanks!

Run the following code in APPS → Develop Apps → Test Luup code (Lua). You can see the result from a browser at /devlist.txt.

[code]local file = io.open(“/www/devlist.txt”, “w”)
file:write("Device List on " … os.date() … “\n\n”)
file:write(“Num Id Parent Device Type Device Name\n\n”)

for deviceNo,d in pairs(luup.devices) do
if d.id ~= “” then
if #d.id > 3 then node = " " else node = d.id end
s, e, dtype = string.find(d.device_type,“:(%w*):1$”)
if dtype == nil then dtype = “” end
if #dtype > 20 then dtype = string.sub(dtype,1,20) end
if #dtype < 20 then dtype = dtype … string.rep(" ",(20 - #dtype)) end
file:write(string.format(‘%03d %3s %03d %s %s \n’, deviceNo, node, d.device_num_parent, dtype, d.description))
end
end

file:close()
[/code]