15.03.2021, 13:05
Then do it like this:
Code:
-- devices
devices = {
{'9d', 'SENSOR', '8/4/5', 'hum'},
{'9e', 'COMMON', '8/4/6', 'tst'}
}
-- data get from webservice
v = {hum=1, tst='abc'}
log(v.hum, v.tst)
-- print some data from v, based on data in devices
for k,k_items in pairs(devices) do
key = k_items[4]
val = v[ key ]
-- log variable name
log(val)
-- log the data in variable with name k_items[4], for example the data in v.hum or v.tst (1 or abc)
end