Code runs OK in Test, but not in scene

I’ve got a problem this morning. It seems that all of scenes that have LUA code in them are not working. Last night at sunset they all worked fine.

I’ve tested a sample of code in the APP - Develop Code - Test Lua Code screen.
It works fine.

But when I cut and paste the same code into a test scene, manually operated, just the code, it does not work.

Did I screw something up? I’ve been trying to fix a door/window device that has intermittent communication (I think the unit has failed). Still haven’t fixed that issue, but I may have messed up something else along the way? I updated the neighbor nodes under Settings-Z wave settings-update neighbor nodes.

I’m on a VeraPlus, UI7, have about 25 devices.

Any help would be greatly appreciated

Thought I’d share the solution that was given to me by the helpful people at the other end of the Vera support phone line.

Here’s the situation -

I had been working with trying to diagnose a faulty door/window sensor. I had written a piece of code that would sound my doorbell unit when the door was opened. It seemed to work ok when I tested the code. It did not work when I put it into a scene. I chalked it up to the door/window sensor not working (which it still isn’t)

The bottom line is that if you insert a piece of defective LUA code into a scene, Vera will not run ANY LUA code, whether it is in the particular scene where the bad code is, or any other scene that has LUA code.

So my other scenes are now apparently working - I’ll be sure when I go through 24 hours. Still working on getting the sensor working. Anybody know of a powered door/window sensor, not a battery operated one?

Hope this helps someone else.

Yes it is odd but the entire lua interpreter goes down if it sees any error in the code… You should actually get a warning message on the UI about it. Something like “error in scene lua or plugin”. Would have been hard for us to know you had errors in other code! :slight_smile:

[quote=“XA44Owq26HxCq88, post:2, topic:200456”]Thought I’d share the solution that was given to me by the helpful people at the other end of the Vera support phone line.

Here’s the situation -

I had been working with trying to diagnose a faulty door/window sensor. I had written a piece of code that would sound my doorbell unit when the door was opened. It seemed to work ok when I tested the code. It did not work when I put it into a scene. I chalked it up to the door/window sensor not working (which it still isn’t)

The bottom line is that if you insert a piece of defective LUA code into a scene, Vera will not run ANY LUA code, whether it is in the particular scene where the bad code is, or any other scene that has LUA code.

So my other scenes are now apparently working - I’ll be sure when I go through 24 hours. Still working on getting the sensor working. Anybody know of a powered door/window sensor, not a battery operated one?

Hope this helps someone else.[/quote]

They’re battery-powered, but we have the Schlage sensors all around the house. Replaced the first battery a few weeks back…for a sensor that had been in use for over two years.

–Richard

I just tried an experiment. I put some garbage into scene Lua for a scene. No error when saving the Lua or the scene–Vera isn’t checking syntax at this point. No surprises there (although they could put it through [tt]loadstring()[/tt] and get immediate feedback on it from the underlying interpreter).

On Luup reload, as you said, scene Lua is completely botched for all scenes. Luup logs this fact in nice attention-getting red color in the log. But most informative is what Vera logs there: all of the scene Lua for every scene that has it, and the startup Lua, are displayed as a single Lua fragment in the error message. So this tells us that Luup is making a giant string out of all of it, and pushing it into loadstring() in one go, rather than preparing each individually. This explains why a hard error in any scene or startup Lua disables all scene Lua and startup Lua. So…

Always look in your Vera log file if your scenes stop running. But then, this should go without saying. The Vera log is hard to sift through, but it’s full of gold. It may be worth a squiz any time you’re editing scene Lua, just to be sure.

Yes, this is a very cheap and cheerful way of making them share the same Lua context. Rather sad that they didn’t bother to use the powerful built-in [tt]setfenv()[/tt] (in Lua 5.1) which can make that happen for separately compiled modules.

Rafale77,

I had come to expect that blue line warning of the error, but in this instance I wasn’t seeing any notice.

I tried to get to my logs using the following command

http://192.168.1.x/cgi-bin/cmh/log.sh?Device=0
(where x is the local device)

Got a “not Found” error

thanks

Use http://vera_IP/cgi-bin/cmh/log.sh?Device=LuaUPnP

That is the correct url to get to the log from the browser.
If the log file happen to be large, this may hammer the browser. If you happen to use USB logging, it may be a while before you see the log.
I highly recommend downloading the log so you can do a search for things by SCP instead. Install winscp and go to /tmp/log/cmh on the vera…

If you install ALTUI, you can use its built-in tools to view and search the logs.

The latest version of LuaView also does syntax-checking of the Lua code and reports any errors (in addition to using the ACE syntax-highlighting editor on both UI7 and AltUI). This may help find errors you might otherwise find difficult to notice (until Luup reloads and then nothing works).

Actually Luaview is a great way to look at all your lua code at once and try to figure out where the problem may come from. Thanks Rigpapa! I did not have much use for it initially but I get the feeling I may need it in the near future.

Thanks for the help

http://vera_IP/cgi-bin/cmh/log.sh?Device=LuaUPnP

Did not work for me, I still get the message “Not Found” error {}

I’ve got AltUI installed but cannot find where the log reporting is.

What is winscp? Couldn’t find it in apps

It’s a program for windows allowing you to access a remote computer and get files from its drive.

[quote=“XA44Owq26HxCq88, post:13, topic:200456”]Thanks for the help

http://vera_IP/cgi-bin/cmh/log.sh?Device=LuaUPnP

Did not work for me, I still get the message “Not Found” error {}

I’ve got AltUI installed but cannot find where the log reporting is.

What is winscp? Couldn’t find it in apps[/quote]

In ALTUI, look under Misc—> OS Commands. There are a number of pre-built commands for searching and examining the logs.

Thanks all, now I’ve got some learning to do…