15.03.2021, 13:09
(This post was last modified: 15.03.2021, 14:06 by gjniewenhuijse.)
yeah.. thanks
i need the value 'attributes.soilHumidity.value'
how to do this in a nested table?
here my new example code
i need the value 'attributes.soilHumidity.value'
how to do this in a nested table?
Code:
["type"]
* string: SENSOR
["attributes"]
* table:
["soilTemperature"]
* table:
["timestamp"]
* string: 2020-10-31T14:49:03.034+0000
["value"]
* number: 13
["lightIntensity"]
* table:
["timestamp"]
* string: 2020-10-31T14:49:16.260+0000
["value"]
* number: 7
["soilHumidity"]
* table:
["timestamp"]
* string: 2020-10-31T14:49:03.004+0000
["value"]
* number: 100
["ambientTemperature"]
* table:
["timestamp"]
* string: 2020-10-31T14:49:17.023+0000
["value"]
* number: 16
["relationships"]
* table:
["device"]
* table:
["data"]
* table:
["type"]
* string: DEVICE
["id"]
* string: 40940964969046840
["id"]
* string: 5647657567567567567
here my new example code
Code:
-- devices
devices = {
{'9d', 'SENSOR', '8/4/5', 'attributes.soilHumidity.value'},
{'9e', 'COMMON', '8/4/6', 'attributes.batteryLevel.value'}
}
-- data get from webservice
v = { attributes= { soilHumidity={value=1},batteryLevel={value=100} } }
log(v)
log(v.attributes.soilHumidity.value)
log(v.attributes.batteryLevel.value)
-- print some data from v, based on data in devices (dynamic)
for k,k_items in pairs(devices) do
key = k_items[4]
val = v[ key ]
log(key, val)
end