This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Script error json stack traceback:
#1
Hi there,
I use Always this script for weather condition

Code:
1234567891011121314151617181920212223242526272829303132333435363738394041424344
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)
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.
Reply
#2
There might be an issue in either common function library or a user library with automatic load enabled. Go to Scripting - Tools - Print and search for lines like "json =" or "json="
Reply
#3
Thanks, I found it but even if I delated it, problem has been not sort it out.

Furthermore I have another problem in visualisation mode with this LM. When I push the icon button, telegram is sent to the bus but status object is not update hence button send always ON or OFF. It depends the status which I sent by KNX debug.

This is the first time that I find this kind of problem.

Ok, I sort it out the problem about object status disabling the bus sniffer.

But json problem still goes on.
Reply
#4
Try restarting the script via disable/enable
Reply
#5
Hi Admin,
ok, I did what you suggested and everything is fine now. Thanks. But what was the problem exactly?

I checked system of other my customer and I found that in HL Schneider firmware 2.0.1 the problem has been not sort it out. Error message is always the same and alarm is "('Weather: cannot fetch data'). In fact all data are very hold.

How can I manage this kind of problem?

Thanks.
Reply
#6
It's an issue with your scripts/libraries. In Lua every variable is global unless prefixed with "local". If you override json global in any script library you cannot use it anywhere else. Another solution is to require library like this:
Code:
1
local json = require('json')

As for weather forecast not loading, check that you have valid gateway and dns settings in network config.
Reply
#7
Thank you Admin.

Sort it out. I used local json = require ('json').

Thank you for your support.
Reply


Forum Jump: