With the following script, I want to read data from this address https://api.opensensemap.org/boxes/5968 ... d1/sensors
Code: Select all
commandArray = {}
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")() -- For Linux
local config=assert(io.popen('curl https://api.opensensemap.org/boxes/5968f05d1900bf0011ffb0d1/sensors' ))
local location = config:read('*all')
config:close()
local jsonLocation = json:decode(location)
t1 = jsonLocation.sensors[0].lastMeasurement.value
lf = jsonLocation.sensors[1].lastMeasurement.value
ld = jsonLocation.sensors[2].lastMeasurement.value
lx = jsonLocation.sensors[3].lastMeasurement.value
uv = jsonLocation.sensors[4].lastMeasurement.value
print('Temperatur: '..t1)
Error: EventSystem: in sensebox1: [string "..."]:13: attempt to index field '?' (a nil value)
Can you look at my snytax for json, i think there is an mistake