Hey AK,
I searched quite a bit for this topic with no real results. Here’s what I’m after.
I want to save the on/off state of my Zwave devices to a table, so that after a given event (that will change multiple device states), I can poll the table and restore the overall state of my zwave devices to what they were prior to the event. To do so, I’m thinking that I would iterate through the device table, and using the obtained device number, retrieve the status of the device using variable_get. However, programmatically getting the service IDs of devices is proving to be difficult. I imagine this is easy, but I’m not seeing it. Here is the code I have so far which gets me most of the way there:
[code]local idx = {}
for openLuupNo in pairs(luup.devices) do
if openLuupNo > 10000 then
idx[#idx+1] = openLuupNo
end
end
table.sort (idx)
for _, openLuupNo in ipairs(idx) do
local d = luup.devices[openLuupNo]
local devType = d.device_type
local devDescription = d.description
local devNodeID = d.id
local devString = (string.format(‘[%03d / %s] %s %s’, openLuupNo, devNodeID, devDescription, devType))
local devServiceID = "Some sort of transform of devType to devServiceID"
local w = luup.variable_get(devServiceID, "Status", openLuupNo)
if d.id > "1" then
– print (w)
print (devString)
end
end[/code]
As always, any help greatly appreciated.