lua code for restarting lua engine

Is there a lua command which you can use in your own lou code for a forced restart/reload of the lua engine?
I mean the same function as the lua reload button in th Apps/Develop apps section of the vera interface.

Your answer is in the Wiki at http://wiki.micasaverde.com/index.php/Luup_Scenes_Events#Reload_Luup_at_3_AM_every_day

luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”, “Reload”, {}, 0)

Most people complain that Vera restarts way too often … :wink:

the problem is that the lua enige randomly reports an error and seems not to be working anymore.
My scenes are dead when this happens and a lua reload is the only way to get is back working again.

I implemented the code but sadly it does not help when the lua engine errors…

Maybe someone could give me a tip how to restart the lua enige when it errors (there is no lua code error, on restart everything works again).

I was thinking somethin like a remote server (my NAS) which polls the vera unit every X times and when the vera unit reports and error the NAS unit performs a lua engine restart. Would this be possible?

If so, which code/url must i call to get the lua engine status from vera?

Hi,

It should be something like:
http://veralite IP/port_3480/data_request?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=Reload’

But, if it truly does not respond I do not know if the Vera would response to this.

What I have done on my UI6 box if have a scene with a scheduled restart twice a week. That seems to keep it going.

On UI7 I uses the sysmon plug in to monitor available memory and restart when that goes below 50K as that seems when the ‘cannto write user data’ issue seems to be starting.

Cheers Rene

Note that LUA is a “JIT” (Just in time) type compiler. This means that code is only compiled when it needs to be executed (the first time after a reboot or LUA reload).

This is why global functions that are contained within a scene cannot be called, until that scene is first run.

So you could have LUA error that is in a scene, and the error encountered when the scene the code is associated with is run. So what is that error message?

(I always like to go after the root problem, rather than just fixing a symptom.)

The error is not in the code.

I asked vera support for it to take a look, they replied that it was 100% not a lua code error but a plugin which caused a random crash. (ping plugin).
There is no specific error, just on top of UI7 a short blue message that LUA has an error, nothing more or less.

Only a lua reload solves it.

I allready did make a timeschedule to reload the lua engine, but when lua crashes also the timers seem to stop, so no reload…

If i could detect a lua error/crash remotely i could call using a remote server (NAS) a lua reload, but i have no idea how i can detect from an external system that the lua engine is crashed of had an error…

I’m not sure if yours is the same error as mine which gives the message “error in Lua scenes and events”. It’s random and can come after hours or days of working normally or immediately after a reboot.

My understanding is that this message signals a syntax error with your code and I have seen it may times during development so I don’t understand why it should suddenly appear days after the engine has been running normally.

I have raised a ticket but so far there has been no progress despite further enquiries.

It’s annoying since UI7/VeraEdge otherwise seems finally to be a stable and reliable solution that’s fit for purpose.

i got the same message.

I had already contact with support because of reguarly unreachable UI, i cannot login and only see the vera logo and loading gif.
After a while a message appears that it takes to long and i can retry.
This problem was in investigation and i added the lua error to it, this is completely random when the lua error appears.

In UI5 the error popup immdiatly on load if you have an error in your code somewhere…
I asked support what these random lua error came from, according to support it was not lua code error but plugins/apps which cause this.
In my case it was the ping sensor… They where in contact with the developers to fix these problems.
This is what they answered to me:

This error is not necessarily because of the syntax of your lua code and most of the times is because of some of the plugins, not being updated. There where some changes a while ago to the backend, and some apps needed an update as well. Some of the developers acknowledged this and updated their plugins, some of the plugins are no longer maintained by their original developers, and some of them will update them in the near future. In any case this has been reported to the development team and they are aware of this, and trying to get in touch with everybody to help them update the plugins accordingly.

Thanks for sharing this.

Perhaps it is worth our sharing what plugins we are using to see if any are common.
I have :
Virtual On/Off Switches
Variable Container
Underground Weather
MiOS Update Utility
Alternate UI

Of these I did read somewhere on the forum (I think) that Variable Container is no longer maintained and I don’t think that Alterate UI is likely to be the problem as I was having the symptoms before I installed it.

I need all of these except possibly the MioS Updater. I’m not sure that it is even relevant for UI7 but have not removed it in case I inadvertently generate another problem.

Rgds

These plugins i have installed, if more then 1 device i added total behind the name):

  • combination switch (22 devices)
  • variable Container (5 devices)
  • Virtual Motion Sensor (11 devices)
  • MultiSwitch
  • HouseModes Plugin
  • ICY E-Themostaat
  • VeraAlerts (installed but not used)
  • XBMCState
  • Day or Night (installed but not used in scene, obligated for XBMCState)

installed but removed/uninstalled yesterday (until now no lua error):

  • PingSensor
  • ALternativeUI

Looks like it could be variable container then, which would square with the idea that it is no longer being maintained. I also did not have this problem with UI5 which adds further fuel to this idea.

I could remove this plugin but I have code to display variables all over the place so it would be inconvenient to say the least. It would be alright until the next piece of development comes along. Debugging without a convenient way of displaying variable values is a real pain.

Are you aware of any other plugins that can display variable values through the UI?

I dabble but am not a competent coder so writing a plugin to do this would be beyond my skill level.

I am not sure but i believe MultiString does the same.
Removing the variable container is for me also not an option, i use it mainly as a kind of database.
Here i can set values (last check/change times, true/false settings etc) which i use in some scenes.

The major minus of the vera unit is the lack of a build in database which can be accessed and used in your scenes…

It would be one of the best improvements if there was a sort of database (mysql etc) present or an option to call one (native) from within the lua code itself: luup.mysql.get(“sql_query”)
If a database was present the need for the variable plugin for me was no longer needed.

But i am not sure this plugin (variable plugin) is really causing this, as said the support department of vera pointed out that the ping sensor was causing this. I removed the ping plugin yesterday and until now i did not had any random errors anymore.
If this was indeed the cause of the problem i only wil know in a few days/weeks time.

I did have to work around the ping sensor problem because i needed the ping info in several scenes, so i did some scripting on my synology nas and let the NAS now do some checks instead of the vera unit The result of these checkes are updated in the vera unit by http request from the NAS.

Thanks for the advice. Multistring looks to be a good candidate but works somewhat differently.

I note that Variable Container is no longer offered as an official plugin. I presume this means that it is now considered a legacy product and therefore not supported. It’s not a good situation going forward which give me more motivation to find a solution that does not rely on it. I will investigate Multistring and hopefully use it to replace my Variable Container implementation.

Let’s see if the removal of Ping Sensor solves your problem. That said, if it’s a UI7 interface problem caused by incompatible plugins (as per MCV’s advice) then Variable Container could also be part of the problem.

I’ll come back to this forum when I have made the needed amendments and let you know if it solved the problem.

Rgds

Have now converted to Multistring and everything is working normally with the exception of the original problem.

I now have some 6 plugins (all listed and working properly) which I presume means they are supported in UI7. I have even gone to the length of commenting out all my user code but the problem persists.

I’m now as sure as I can be that this is a UI7 problem and will be following up on my ticket.