[error] Too many lines  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

[error] Too many lines

Post by EdwinK »

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:

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
}
Last edited by EdwinK on Sunday 29 July 2018 10:53, edited 1 time in total.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: [error] Too many lines

Post by dannybloe »

Mmm. Didn't know there was a max in de JSON.lua library. dzVents uses the one that comes with Domoticz.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: [error] Too many lines

Post by EdwinK »

I don't know anything at all about this, so I hope you have some ideas :)

Just noticed when doing something else, so maybe it was going on for a long time
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: [error] Too many lines

Post by waaren »

EdwinK wrote: Sunday 29 July 2018 10:54 I don't know anything at all about this, so I hope you have some ideas :)

Just noticed when doing something else, so maybe it was going on for a long time
@EdwinK, this is a known problem and reported here
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: [error] Too many lines

Post by dannybloe »

Well, appears that it is something in Domoticz. See also this topic.
I really have no idea why this is in the Domoticz code at all.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
elmortero
Posts: 248
Joined: Sunday 29 November 2015 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9639
Location: Spain
Contact:

Re: [error] Too many lines

Post by elmortero »

I have been looking into this a lot and never found a solution/workaround. Never figured it was a limitation in Domoticz.
It does make sense in the way that you would not want the event system to hang.
In the case of the script mentioned by the OP, not rarely the json result is over 20000 lines long and I figure that it might take too long to process them all.
I have contacted the owner/admin of onweeractueel to see if the results can be filtered (by setting max/min lon and lat) but never got an answer to that.
Also investigating alternative providers, but there are not many, and the existing ones are rather expensive
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: [error] Too many lines

Post by waaren »

elmortero wrote: Sunday 29 July 2018 12:39 I have been looking into this a lot and never found a solution/workaround. Never figured it was a limitation in Domoticz.
It does make sense in the way that you would not want the event system to hang.
In the case of the script mentioned by the OP, not rarely the json result is over 20000 lines long and I figure that it might take too long to process them all.
I have contacted the owner/admin of onweeractueel to see if the results can be filtered (by setting max/min lon and lat) but never got an answer to that.
Also investigating alternative providers, but there are not many, and the existing ones are rather expensive
Seems indeed a hard coded limit in json_reader.cpp (stackLimit_g) to prevent a situation where a bad json could cause a segmentation fault.

If onweeractueel would extend their api with an option to filter the result on location and/or time, it would add more user control to the size of the response.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: [error] Too many lines

Post by dannybloe »

No it is not in json reader. We don’t use that. It is in EventSystem.cpp. Lua is doing the json parsing.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: [error] Too many lines

Post by EdwinK »

waaren wrote: Sunday 29 July 2018 12:09
EdwinK wrote: Sunday 29 July 2018 10:54 I don't know anything at all about this, so I hope you have some ideas :)

Just noticed when doing something else, so maybe it was going on for a long time
@EdwinK, this is a known problem and reported here
Thanks. Didn't know that.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
elmortero
Posts: 248
Joined: Sunday 29 November 2015 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.9639
Location: Spain
Contact:

Re: [error] Too many lines

Post by elmortero »

waaren wrote: Sunday 29 July 2018 12:09 @EdwinK, this is a known problem and reported here
Yes, but I never got a response..

Greetz,
Oli
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: [error] Too many lines  [Solved]

Post by waaren »

elmortero wrote: Sunday 29 July 2018 20:43
waaren wrote: Sunday 29 July 2018 12:09 @EdwinK, this is a known problem and reported here
Yes, but I never got a response..

Greetz,
Oli
@EdwinK, @elmortero, today the question was bumped and we received a reply !

"At this moment we are rebuild the script where an api is do the job where you can receive based on a unique location the info in place of all the unrelated info."
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: [error] Too many lines

Post by EdwinK »

Great :)

Thanks for the feedback.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
phoenixblue
Posts: 76
Joined: Friday 25 November 2016 11:20
Target OS: Windows
Domoticz version:
Contact:

Re: [error] Too many lines

Post by phoenixblue »

I see you are using the script inside dzVents I'm correct?




User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: [error] Too many lines

Post by EdwinK »

Yes, I use the dzVents script.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
User avatar
phoenixblue
Posts: 76
Joined: Friday 25 November 2016 11:20
Target OS: Windows
Domoticz version:
Contact:

Re: [error] Too many lines

Post by phoenixblue »

EdwinK wrote:Yes, I use the dzVents script.
I have no experience to tell you if this script is working inside it because it's build for outside it.
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: [error] Too many lines

Post by EdwinK »

Going to try your script as now and put elmortero's on hold
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest