05.04.2018, 14:18
Hi there,
I use Always this script for weather condition
I cannot understand the reason why in this case I read this following error:
Resident script:14: attempt to index global 'json' (a boolean value)
stack traceback:
What does it mean?
Thanks.
I use Always this script for weather condition
Code:
require('json')
require('socket.http')
socket.http.TIMEOUT = 5
local city = 716028
local data = socket.http.request('http://openrb.com/weather/?w=' .. city)
if not data then
alert('Weather: cannot fetch data')
return
end
data = json.pdecode(data)
if not data then
alert('Weather: cannot parse data')
return
end
-- current condition and temperature
-- grp.update('7/1/3', data.current.text, dt.string)
grp.update('7/1/4', data.current.temp)
-- forecast for today
grp.update('7/1/5', data.today.text, dt.string)
grp.update('7/1/6', data.today.low, dt.float16)
grp.update('7/1/7', data.today.high, dt.float16)
-- forecast for tomorrow
grp.update('7/1/8', data.tomorrow.text, dt.string)
grp.update('7/1/9', data.tomorrow.low, dt.float16)
grp.update('7/1/10', data.tomorrow.high, dt.float16)
grp.update('7/1/11', ((data.wind.chill-32)/1.8000), dt.float16)
grp.update('7/1/12', data.wind.direction, dt.angle)
grp.update('7/1/13', data.wind.speed, dt.float16)
grp.update('7/1/14', data.atmosphere.humidity, dt.float16)
grp.update('7/1/15', data.atmosphere.visibility, dt.float16)
grp.update('7/1/16', data.atmosphere.pressure, dt.float16)
grp.update('7/1/17', data.atmosphere.rising, dt.bool)
grp.update('7/1/18', data.astronomy.sunrise , dt.string)
grp.update('7/1/19', data.astronomy.sunset, dt.string)
Resident script:14: attempt to index global 'json' (a boolean value)
stack traceback:
What does it mean?
Thanks.