Problem with lug_device [SOLVED]

Hi,

I just found code in Micasaverde wiki using lug_device but it doesn’t works :frowning:
From here : http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#variable:_devices)

for k, v in pairs(lug_device) do
    for k2, v2 in v do
        luup.log("Device #" .. k .. ":" .. k2 .. "=" .. "v2")
    end
end

When I run the code through the interface in the Apps Tab => Develop apps => Test Luup code (Lua),
I got a “Code failed” error message :frowning:

Have you an idea ?

Regards
David

I made a mistake when I wrote the Topic : I lock it :-[
Now it’s good …
Sorry again
David

Try [tt]luup.devices[/tt] instead of [tt]lug_devices[/tt]. I have a feeling the latter is a throwback to a time a long, long time ago and needs to be corrected.

You can see the original discussion here:
http://forum.micasaverde.com/index.php/topic,1561.msg5264.html#msg5264

I don’t have Vera handy right now, but once you confirm, the Wiki page can be corrected.

Same error :frowning:

Here is the log

08 03/23/12 9:51:33.890 JobHandler_LuaUPnP::HandleActionRequest argument Code=for k, v in pairs(luup.devices) do for k2, v2 in v do luup.log("Device #" .. k .. ":" .. k2 .. "=" .. "v2") end end <0x2d41f680> 01 03/23/12 9:51:33.891 LuaInterface::StartEngine failed run: 0 [string "for k, v in pairs(luup.devices) do..."]:2: attempt to call a table value <0x2d41f680> 01 03/23/12 9:51:33.891 JobHandler_LuaUPnP::RunLua failed: for k, v in pairs(luup.devices) do for k2, v2 in v do luup.log("Device #" .. k .. ":" .. k2 .. "=" .. "v2") end end <0x2d41f680>

Try this. I used pairs(v) instead of just v

for k, v in pairs(luup.devices) do for k2, v2 in pairs(v) do luup.log("Device #" .. k .. ":" .. k2 .. "=" .. "v2") end end

Good !

I try with pairs yesterday … but with lug_device :slight_smile:

Thanks a lot !