[error] Too many lines
Posted: Sunday 29 July 2018 10:47
I'm getting the following error all of a sudden on a script: ' dzVents: Error (2.4.7): Error parsing json to LUA table: /home/pi/domoticz/scripts/dzVents/../lua/JSON.lua:1009: Lua script execution exceeds maximum number of lines'
This is the script:
This is the script:
Code: Select all
return {
on = {
timer = { 'every 5 minutes' },
httpResponses = { 'blitz' } -- matches callback string below
},
data = {
last = { initial = 0 }
},
execute = function(domoticz, triggerItem)
local lightning = domoticz.devices('Bliksemteller')
local preLight = tonumber(lightning.rawData[1])
distance = function(lat1, lng1, lat2, lng2)
radius = 6371
dLat = (lat2 - lat1) * math.pi / 180
dLng = (lng2 - lng1) * math.pi / 180
lat1 = lat1 * math.pi / 180
lat2 = lat2 * math.pi / 180
val = math.sin(dLat / 2) * math.sin(dLat / 2) + math.sin(dLng / 2) * math.sin(dLng / 2) * math.cos(lat1) * math.cos(lat2)
ang = 2 * math.atan2(math.sqrt(val), math.sqrt(1 - val))
return radius * ang
end
local latHome = 51.860069 --replace with your own coordenates
local lngHome = 4.4122027 --replace with your own coordenates
local distanceRange = 10 --change to the maximum distance you want for filtering (in KMs)
local last = tonumber(domoticz.data.last)
if (triggerItem.isTimer) then
domoticz.openURL({
url = 'https://www.onweeractueel.nl/domoticz_bo.json',
method = 'GET',
callback = 'blitz'
})
elseif (triggerItem.isHTTPResponse) then
local response = triggerItem
if (response.ok and response.isJSON) then
local value = 0
local ignored = 0
tl = #response.json
tc = 1
repeat
local times = tonumber(response.json[tc][1])
local lat = tonumber(response.json[tc][2])
local lng = tonumber(response.json[tc][3])
local distanceBetween = distance(latHome, lngHome, lat, lng)
if (distanceBetween <= distanceRange) then
if (times > last) then
value = value + 1
else
value = 0
end
domoticz.data.last = times
end
tc = tc + 1
until tc > tl
print('Blitz Value = '..value)
if value ~= preLight then
lightning.updateCustomSensor(value)
end
else
print('**blitz failed to fetch info')
end
end
end
}