Intermittent "Error in Lua scenes and events" message

Hello
In my problem is caused by global variables kept in “Edit Startup Lua” in “Develop apps” menu.
Most of my scenes based on Lue are using global variables (devce IDs) from “Startup Lua” script.
Sometimes it happens that after some update/adding device/… “ERROR : Error in lua for scenes and events” appears. In /var/log/cmh/LuaUPnP.log I can find that scenes are failing because of NIL value - globals are not loaded.
SOLUTION (or rather PATCH) is to go Apps|Develop Apps| Edit startup Lua and click “Go” button (without any changes in code).
In this case all Lua is reloaded and problem disappears. Sometimes I have to do it twice.

I had not yet time to find the reason…probably because it is not bugging me yet enough :slight_smile:
I can guess that there is something wrong in vera processes restart sequence.
If I have more time I will try to find exact reason and patch (maybe using require() in Lua).

Greetings

I kicked off this thread back in Sept 2015 and have not achieved a stable system since then - until now that is.

Whilst there may be other reasons why the engine crashes, a common theme of this thread has been the unintended operation (compare and/or arithmetic) carried out on variables with nil values.

This situation recently became intolerable (several hundred crashes each day) and I raised a support ticket. MCV (are they still called that?) were very responsive and eventually advised that my Lua code was at fault and provided some backup showing that I was attempting to operate on variables with nil values. This was undeniable.

The problem was that I could see no errors in my Lua code. I had initialised every variable in Start up Lua and could not see where the nil values were coming from. Further research led me to the scenes that referenced variables in some of my devices namely my HomePro ZRP210 power switches. These are of a very early design and it was noticeable that my more recent models were not producing the same symptoms nor were any of my other devices.

As these devices had been included into my ZWave network under my Vera2 (earlier ZWave chip) I was advised to exclude/include them under Vera Edge. This made no difference. However, in doing so I noticed that, of the variables displayed under the Advanced tab, many were empty. Wondering if this meant that they had not been initialised by the include process and therefore carried nil values, I overwrote all of them with zeros.

My problem disappeared immediately. The Lua engine has now run for 24 hours without a single failure and looks rock solid (at least for now).

All my devices have been added as a generic device which I assume means that the Vera code does not initialise all those variables that are specific to that device leaving them with nil values. Either that or UI7 is not entirely compatible with some older devices.

I have to say that my Lua code does not directly reference any of the uninitialised variables so I am not entirely sure of how the reference to nil values has come about. I only know that zeroising them has solved my problem.

I offer my experience in the hope that it helps others facing the same problem.