Help debugging "ERROR : Error in lua for scenes and events"

I made a lot of changes yesterday. I’m working on more this morning. I just started getting the “ERROR : Error in lua for scenes and events” message. Is there a way to spot where the code is that’s causing the error? When I look at my logs, I can see:

LuaInterface::StartEngine failed run: 0 attempt to call a string value

followed by the Lua for my various scenes. It always cuts off (stops displaying scene function() code) in the same place. But I’ve inspected the code in that scene and it looks good (and works in the Lua tester). In the log, I see this on the last line of the echo of Lua in the log

function scen LEAK this:24576 start:3248128 to 0x1a37000 <0x2bf4f680>

I’ve copied all of the scene functions that are echoed into the log and run them through the Lua tester, too.

Is there a reliable way to isolate where the failing code lives?

FRUSTRATING!

I rebooted and the error has gone away.

My original question still stands, though - when I get that error, I generally look to the current code I’m working on. But what if the error lies elsewhere?

Test all of your LUA in a standalone LUA environment.
Only after it works move it to Vera.
It’s to painful to debug on Vera.
There are many threads about LUA environments in this forum.

So, it sounds like once I’ve got the error, it’s too late. Prevention is the way to go.

Depending on where the LUA is (Startup LUA, Trigger or Scene LUA, Plugin LUA) … there are different ways to debug. Also depends on how bad the error is.

But it’s much more productive to eliminate syntax/logic errors outside of Vera.

I get this error on one out of 100 reloads. A reboot always fixes the issue.

Weird things happen when the unit is in this state. For example, “luup.is_night” and “not luup.is_night()” both return true…so conditional Luup scene filtering doesn’t work.

Is there anything I can do to detect the “ERROR : Error in lua for scenes and events” condition in my startup LUA?

I get this (very annoying) problem when I have scenes with lua that are on a scheduled interval (once a minute for example). Happens sporadically at startup.

By removing all scenes that where on scheduled intervals I got a stable installation again.

In my startup Lua i have defined a bunch of functions, not sure if this is related to that.

Did anyone understand which is the cause of this issue? I’ve the same behavior :cry:

I have been living with this for many years: Random “Error in lua for scenes and events or startup lua”. I think it is related to timing and slow processing of the CPU which randomly does not have all the codes ready during a luup reload or boot up. I noticed that it gets worse as the startup LUA size, the plugin count and the scene count increases.

I am gradually migrating to Openluup and eventually hoping to use the vera only as a Zwave and zigbee bridge without automation and only minimal plugins.

Same here and Vera support can’t help since the issue is hard to reproduce :frowning: