Intermittent "Error in Lua scenes and events" message

I have recently upgraded form a Vera 2 (UI5) to Vera Edge (UI7).

I have written a fair bit of Lua code which was working without any problems under UI5.
In general all seems to be working well with the edge indeed much better than Vera 2.

However I am occasionally (like every day or 2) getting the message “Error in Lua scenes and events” and the engine stops. It can take between 1 and 4 attempts at reloading the engine and then the message goes away and the system runs fine for another day or two.

I have seen this message many time when I was developing my system but it was always solid and caused by a coding error. Once I had fixed the coding error I never saw the message again until I undertook some further development.

I cannot understand how I get this message intermittently.

Has anyone else seen this problem and can you give me any advise?

With thanks

I have the same problem
I have a scene with lua code that translates the data from weather undergroud to dutch
Its fairly long. every couple of days it stops working
I have no idea why
it looks like the code becomes scrambled
greetings jodelo

One thing in common, we are both using the weather underground plugin.


Yeah, but the same code works fine in a PLEG
That stays stable

A big difference is that I use URL encoding to encapsulate the LUA code. This does not have any limitation in content. I also execute the code wrapped in an exception catching context.

MCV uses XML to wrap the LUA code … this means that some characters like, but not limited to the the “<” character take on special meanings.

They use XML wrapping for Plugin definition files … I guess they figured they would use the same for the internally managed LUA code (i.e. scene, triggger, and startup LUA).
But they do not provide adequate protection for user errors in this.

Unbelievable… All of these scenes failed at once the other day. Normally they run for days without issues. Good explanation RTS, as always - much appreciate you shedding light on issues such as these…

08      09/23/15 19:43:13.101   Scene::RunScene running 85 Weather <0x2bc35680>
01      09/23/15 19:43:13.102   LuaInterface::CallFunction_Scene Scene  85 failed attempt to call a nil value <0x2bc35680>
08      09/23/15 19:43:13.102   JobHandler_LuaUPnP::AlarmCallback Ran scene:85 Weather / timer: next at 1443055693 now 1443055393 <0x2bc35680>

08      09/23/15 19:43:13.103   Scene::RunScene running 111 WAN Link 1<0x2bc35680>
01      09/23/15 19:43:13.104   LuaInterface::CallFunction_Scene Scene  111 failed attempt to call a nil value <0x2bc35680>
08      09/23/15 19:43:13.104   JobHandler_LuaUPnP::AlarmCallback Ran scene:111 WAN Link 1 / timer: next at 1443055693 now 1443055393 <0x2bc35680>

08      09/23/15 19:43:13.105   Scene::RunScene running 112 Bosch<0x2bc35680>
01      09/23/15 19:43:13.105   LuaInterface::CallFunction_Scene Scene  112 failed attempt to call a nil value <0x2bc35680>
08      09/23/15 19:43:13.106   JobHandler_LuaUPnP::AlarmCallback Ran scene:112 Bosch / timer: next at 1443055693 now 1443055393 <0x2bc35680>

08      09/23/15 19:43:13.107   Scene::RunScene running 113 Viking <0x2bc35680>
01      09/23/15 19:43:13.108   LuaInterface::CallFunction_Scene Scene  113 failed attempt to call a nil value <0x2bc35680>
08      09/23/15 19:43:13.108   JobHandler_LuaUPnP::AlarmCallback Ran scene:113 Viking / timer: next at 1443055693 now 1443055393 <0x2bc35680>

08      09/23/15 19:43:13.109   Scene::RunScene running 84 GrandFather Clock <0x2bc35680>
01      09/23/15 19:43:13.110   LuaInterface::CallFunction_Scene Scene  84 failed attempt to call a nil value <0x2bc35680>
08      09/23/15 19:43:13.110   JobHandler_LuaUPnP::AlarmCallback Ran scene:84 GrandFather Clock / timer: next at 1443055453 now 1443055393

Hey Richard, Thanx for your reaction
at least i know why now
I’ll put everything in PLEG :slight_smile:


I also had these issues: It was down to uninitilised fields & the fact that the luua starup code isn’t always run first. Depending on what else was being triggered meant sometimes the luua startup code would initialise my variables in time for usage, sometimes it wouldn’t.

I have also recently noticed getting these errors since going to UI7 - NIL values and uninitialised global.
I tried creating a watchdog to restart the box, but that simply suffered the same problem and never actually runs.
Is there a way to force the start_lua to run first - or to monitor the log file and restart if the problem occurs?


Using UI7. Have all my scene code contained in a file that is loaded at start up:

myLua = require("L_MyLuaCode")

Been working for ages. Last week or so, when the auto magic Lua engine restarts occur, the start code is sometimes not loaded/executed. Easy to notice, as none of my scenes work.

Debugging indicates myLua = nil

Typical error msg:

01 01/20/16 10:13:12.524 LuaInterface::StartEngine failed run: 0 attempt to call a string value <0x2b4d8680> 01 01/20/16 10:13:12.524 JobHandler_LuaUPnP::AlarmCallback EXECUTE_GLOBAL_LUA failed:

Restarting the Lua engine (generally) resolves the issue.

Not loading/executing the Start Up code is a critical error, that should be detected and result in a Halt.

Just for a data point, I’m having the same issue.

All of my scenes fail at the same time after running for weeks.

I opened a support case, and the tech said that development was looking at the problem, and it may be fixed in a future release.

I may move my scenes into PLEG to see if I can harden them from this behavior.

Just to update, I put my scenes into PLEG’s, and my scene failures are have stopped.

I can’t say why, but I tried everything to code around the failure, encapsulating the Lua in PLEG seemed to resolve it.

I did the same a few weeks ago. Gone from failures most days to rock solid for 3 weeks. No idea what the cause was.

In my case I tracked it down to a MySensors gateway that had crashed. Vera was repeatedly trying to communicate with it and then got squashed by a Vera 60 second timeout. Somehow this was causing the start up to not load. Restarting the MySensors gateway fixed the problem. Interesting that something on the LAN, that Vera talks to, can stop Vera from functioning. Should be fixed.

In my case this similar issue. On any power interruption my Vera Lite would run into this Lua error. a manual reboot would solve this. Had checked all my scenes and found no wrong Lua. In the end I noticed a similarity in the log files. During the “startup” process a specific scene returned “failed attempt to call a nil value”. This error did not appear when I rebooted via the reboot button on the Net & WiFi page. Checking the Lua code showed no issue, however running it returned a “code failed”. Strange… . I realized this powerplug (greenwave 6 plugs) didn’t send its status. One manual poll solved the issue. I added a poll command in the scene and the problem was solved.

When it happens ( several times a week , I see also in the log that "a specific scene returned “failed attempt to call a nil value”.
A Luup reload clear the error

Need more info than you have supplied but the error suggests a function was called and it was not found. Generally occurs when the function is not global or the function is part of a module and has not been called correctly by prefixing the module name.

Also note that global functions that are defined (coded) within a scene’s LUA code do not exist until that scene if first run (after a reboot or LUA reload). Referencing that global function from another scene will fail (like described) if the first scene has not yet been run.

LUA is known as a “Just in time” type compiler, which means compilation for specific code will only occur when that code is first needed.

For that reason, it is generally a good idea to define global functions in the LUA startup code area. The startup code is always executed, so you can be sure that the function will actually exist when scenes are run.

Similar symtoms at my vera edge also. I have scheduled a reboot every second day in order to keep my system stable because I thought it was memory leak type problem. I do have 3 global fuctions and 30-40 global variables at startup lua.

Is there any easy way to notice this situation and send an alarm or SMS in case this error is on ?

I will try to investicate this more when the problem hapen next time.

I have had stable system for 2 weeks now. Yesterday I did add 2 new very simple scenes and the error is back . I did reboot the system and I hope it did fix the problem. I also do run the nice weather plugin + sonos and have implemented 3 generic fuctions to startup lua.