Not sure what i’m doing wrong, as I’ve tried things a number of different ways - but please could someone have a look at the following and let me know why I’m not returning the values when using a table to populate the luup.variable_get information ? (See below)
local mytable = {
{"urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature",44},
{"urn:micasaverde-com:serviceId:LightSensor1","CurrentLevel",45}
}
--confirm the variable_get requests work..
local temp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature",44)
local light = luup.variable_get("urn:micasaverde-com:serviceId:LightSensor1","CurrentLevel",45)
print("temp = ", temp)
print("light = ", light)
print("")
--now use the table to construct the variable_get request--
for k, v in pairs( mytable ) do
local value1 = luup.variable_get('"'..v[1]..'","'..v[2]..'",'..v[3])
print(value1)
local value2 = luup.variable_get(v[1]..','..v[2]..','..v[3])
print(value2)
end
I’m sure it’s something obvious but I’m just not seeing it…
Thanks @akbooer, now that you put it that way, it makes perfect sense - I don’t know why I didn’t get that, I was scratching my head why only the first one was returned (I think pulling from an array/table threw me)
Quick question regarding this…
I assume the above pulls each ‘v’ in order, so in this case, if the table rows were ordered in another way it wouldn’t work.