15.03.2021, 13:00
i like to get data from a table, but the variable name is dynamic. See my example:
Code:
-- devices
devices = {
{'9d', 'SENSOR', '8/4/5', 'v.hum'},
{'9e', 'COMMON', '8/4/6', 'v.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
-- log variable name
log(k_items[4])
-- log the data in variable with name k_items[4], for example the data in v.hum or v.tst (1 or abc)
end