Hi all,
Have some experience in vbscript and turbo pascal, but new to Luup and Lua ![]()
Can read KWH from different device, but have to make my code more effective.
local varDeviceID = 8
local kw = luup.variable_get(“urn:schemas-upnp-org:device:BinaryLight:1”, “KWH”, varDeviceID )
luup.variable_set(“urn:schemas-upnp-org:device:BinaryLight:1”, “KWH24”, kw, varDeviceID)
local varDeviceID = 9
local kw = luup.variable_get(“urn:schemas-upnp-org:device:BinaryLight:1”, “KWH”, varDeviceID )
luup.variable_set(“urn:schemas-upnp-org:device:BinaryLight:1”, “KWH24”, kw, varDeviceID)
return true
If I have a lot of devices, can I change the code to use a while, repeat or for statement ?
I have try this.
local varDeviceID = 0
for varDeviceID = 8,9,10,12,14 do
local kw = luup.variable_get(“urn:schemas-upnp-org:device:BinaryLight:1”, “KWH”, varDeviceID )
luup.variable_set(“urn:schemas-upnp-org:device:BinaryLight:1”, “KWH24”, kw, varDeviceID)
end
return true
Thank you