We have moved at community.getvera.com

Author Topic: ERROR : Error in lua for scenes and events  (Read 216 times)

Offline wilme2

  • Hero Member
  • *****
  • Posts: 1302
  • Karma: +33/-13
ERROR : Error in lua for scenes and events
« on: January 22, 2019, 10:24:28 am »
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.

Long Live UI5!  (OK finally made the switch to UI7 in January 2018, and am pretty happy....)

Offline wilme2

  • Hero Member
  • *****
  • Posts: 1302
  • Karma: +33/-13
Re: ERROR : Error in lua for scenes and events
« Reply #1 on: January 22, 2019, 10:42:02 am »
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...

« Last Edit: January 22, 2019, 10:50:06 am by wilme2 »
Long Live UI5!  (OK finally made the switch to UI7 in January 2018, and am pretty happy....)

Offline rigpapa

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1121
  • Karma: +187/-3
Re: ERROR : Error in lua for scenes and events
« Reply #2 on: January 22, 2019, 11:31:22 am »
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... :(

Edit: clarification
« Last Edit: January 22, 2019, 12:08:12 pm by rigpapa »
Author of Reactor, DelayLight, SiteSensor, Rachio, Deus Ex Machina II, Intesis WMP Gateway, Auto Virtual Thermostat and VirtualSensor plugins. Vera Plus w/100+ Z-wave devices. Vera3, Lite. Hassio, Slapdash.

Offline wilme2

  • Hero Member
  • *****
  • Posts: 1302
  • Karma: +33/-13
Re: ERROR : Error in lua for scenes and events
« Reply #3 on: January 22, 2019, 12:21:22 pm »
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... :(

Good idea about is_ready().  Updated my scene to:
Code: [Select]
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).
Long Live UI5!  (OK finally made the switch to UI7 in January 2018, and am pretty happy....)

Offline rafale77

  • Community Beta
  • Hero Member
  • ******
  • Posts: 1749
  • Karma: +101/-27
  • HA ≠ IoT as a blue sky is cloudless.
Re: ERROR : Error in lua for scenes and events
« Reply #4 on: January 22, 2019, 12:28:46 pm »
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.
openLuup (79 devices, 141 scenes, 19 apps) master to VeraPlus (142 zwave nodes, 8 Zigbee nodes, 221 devices,  20 scenes , 2 apps) +  Hubitat (15 Zigbee nodes) + Home-Assistant (API Integrations). Bridged to Siri and Alexa. Homewave. VeraPlus ExtRooted and mios server independent.

Offline wilme2

  • Hero Member
  • *****
  • Posts: 1302
  • Karma: +33/-13
Re: ERROR : Error in lua for scenes and events
« Reply #5 on: January 22, 2019, 12:43:01 pm »
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.
« Last Edit: January 22, 2019, 12:45:08 pm by wilme2 »
Long Live UI5!  (OK finally made the switch to UI7 in January 2018, and am pretty happy....)

Offline rafale77

  • Community Beta
  • Hero Member
  • ******
  • Posts: 1749
  • Karma: +101/-27
  • HA ≠ IoT as a blue sky is cloudless.
Re: ERROR : Error in lua for scenes and events
« Reply #6 on: January 22, 2019, 12:53:43 pm »
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.
openLuup (79 devices, 141 scenes, 19 apps) master to VeraPlus (142 zwave nodes, 8 Zigbee nodes, 221 devices,  20 scenes , 2 apps) +  Hubitat (15 Zigbee nodes) + Home-Assistant (API Integrations). Bridged to Siri and Alexa. Homewave. VeraPlus ExtRooted and mios server independent.