ERROR : Error in lua for scenes and events

I have been seeing “ERROR : Error in lua for scenes and events” about 1 out of 4 times that Luup reloads. This started within the last 60 days. None of my Lua has changed.

I found the error in the luaupnp log at one point, and it looked like it had errored out on my startup LUA - which has not changed in years.

A reload fixes the problem. The reason I posted here is that I have heard a few other users indicating they saw similar issues, and I wanted to start a dedicated thread.

Looking over the existing research on this board, I came across this post, which made me think. http://forum.micasaverde.com/index.php/topic,39572.msg295541.html#msg295541

I do have a scene that runs every 15 minutes, and it would have run at almost the exact same time as the LUA reload this morning that returned the “ERROR : Error in lua for scenes and events”. Now that scene is not dependent on my startup LUA, but it is dependent on a plug-in. Whole scene is just “luup.call_action(“urn:micasaverde-com:serviceId:DSCAlarmPanel1”, “SendCommand”, {Command=“001”}, 14)”

I don’t know this changes anything, but the theory that interval scenes can be running before the supporting code has been loaded is interesting. I just don’t know why it has started to happen more regularly. Something with the load process on the latest 7.0.27 firmware (1.7.4002 on VeraSecure for me) might do it, as I have only recently updated…

I can tell you from my experience in writing and supporting Reactor, DelayLight, and other plugins that may manipulate devices, that I found it necessary to wait out the Z-Wave startup. I have a Plus with about 100 Z-Wave devices, and the completion of Z-Wave initialization comes significantly later than the startup functions for plugins are called–it is dependent both on the number of devices and the type and performance of those devices. So my plugins do their basic initializations, and then enter a [delay] loop waiting for NetStatusID on the ZWave device to change to 1 (ready). Then and only then do they finish their initialization and start doing any device-handling tasks.

The system-wide startup Lua seems to run right before plugins are started (at least, so it is on my development Vera3, where I log such things). So anything done in Startup Lua is almost certainly going to precede plugin initialization, or at least, it would be appropriately defensive to assume that.

Since that alarm panel is driven by a plugin, you would likely need to check that the plugin has completed its initialization and is ready for actions. A simple call to luup.is_ready() may be sufficient, depending on how the plugin initializes when Luup starts it (if, as in Reactor, part of the initialization is deferred, luup.is_ready() may not be accurate).

That said, it should go without saying that calling an action on a device that isn’t ready should not cause a Luup reload… :frowning:

Edit: clarification

[quote=“rigpapa, post:3, topic:200476”]A simple call to luup.is_ready() may be sufficient, depending on how the plugin initializes when Luup starts it (if, as in Reactor, part of the initialization is deferred, luup.is_ready() may not be accurate).

That said, it should go without saying that calling an action on a device that isn’t ready should not cause a Luup reload… :([/quote]

Good idea about is_ready(). Updated my scene to:

if (luup.is_ready(14) == true) then
	luup.call_action("urn:micasaverde-com:serviceId:DSCAlarmPanel1", "SendCommand", {Command="001"}, 14) 
end

And to clarify, what I am surmising is a suspected calling of an action on a device that is not ready isn’t causing a Luup reload - it is causing the startup LUA to fail, and generating the “ERROR : Error in lua for scenes and events”. Forcing me to to manually reload Luup - once I realize it happened - which is usually only when scenes dependent on that startup LUA do not function as expected (blinds don’t open/close or AV equipment does not respond).

Are you sure the error did not come after an (unexpected and unwanted) luup reload? I have personally never seen this error showing up spontaneously. It has always shown up after a luup or full vera reboot.

It has been occuring when I deactivate a scene from the Vera web GUI or Vera Mobile, which apparently requires luup reload. So really should not be an unexpected/unwanted/unhandled luup reload. But I might rethink the process (automated pet feeding we sometimes want to bypass) and potentially use a virtual switch or some other way to effectively deactivate a scene without the luup reload.

Yes I would not use the scene activation function for this very reason and would use a virtual switch or a flag variable instead. So it is indeed a Luup reload which is the event creating the error.

Hello,
A strange think occurs on my Vera edge.
Since six years I have vera with about 30 devices.
I have also many scenes and a startup with functions .
This works correctly, I have change my Vera 3 to Vera edge, withe the same network, all was correct.
In november of last year a device, exactly a dimmer, has dead, and don’t works.
After this, the network is very slow, some devices don’t works or not detect, and suddenly error in lua appears.
I disconnect the device, but the errors appears suddenly, I contact the assistance to help me.
During many month we do many things to try to resolve the problem, but nothing works.
Some times there are no errors during two days, but normally I have the error all the days. The only way to correct this is to reload the startup.
Last week, I have a response from vera, that say that the team of dev is alerted but without nothing for the time.
The same day I verify some scenes, to correct some thinks.
And on the Vera I see, the wifi led is lightning.
I’m surprised because I have allways deactivate this service.
I go to settings, and I see that the static Ip I have is now changing to DHCP with and other adress.
I tell to Vera, and I says that it never change this without tell me before.
And I see that since two days I don’t have error in lua.
So I go to settings, I put my old static Ip, and I restart the Vera.
Error in lua appears.
I come back to DHCP, the error disappears.
I try static with an other Ip, I restart and error appears.
With Dhcp error disappear.
And since one week, I never have the error.
I don’t understand two thinks.
Why without changes from myself the system pass on DHCP.
And why with DHCP, all works fine, and not with static IP.
If somebody understand…
I apologize for my poor english but I’m french and the frenchies don’t speaks very well on an other language

Parles pour toi… Non mais je rêve… :wink:

You are a little hard to follow though.
On your zwave errors, You likely some other failing devices breaking your zwave mesh network. I am surprised support did not look into the logs to identify the failing device.
All your network gremlins were likely due to support trying to reset and test a few things. Enabling DHCP helping on your network is also likely due to some specific devices on your network maybe not liking or conflicting with the static IP you have set. It is specific to your network. Also not knowing what lua error you had which could be caused by a plugin or some of your luup code makes it difficult for people to help.

One thing which comes to mind as I reported higher… this error normally only comes after a luup reload. When it shows up inconsistently, it is generally a loading error during the luup reload process due to timing of various processes starting not being very consistent. You maybe getting more frequent luup reloads when on static IP because of the vera’s NetworkMonitor running in the background not liking something. The static IP may have a problem using the wrong gateway or subnet mask for example preventing the vera from accessing the internet and therefore rebooting on a regular basis… This is just one example of failure mode…

I remove physicaly and on the network the device that causes the first error.
With the support I try to correct this errors, but there are not errors, and the errors disappear when I restart luup, and the errors appears when I reeboot the Vera ( hard or soft ).
The last action the support do is to add a xml file that had disappeared.
And it’s after this action that the Ip pass from static to DHCP and correct the issue, and it’s not me that do this action.
All the network and the settings are the same since 5 years.
During this time I made many changes, but never errors occurs.
And it’s impossible have wrong settings with static IP during five years, if the gateway or subnet mask are false never it works.

Based on my experience its limited to scenes and or events check your scene scripts, device names and numbers