LuaTest - A Tool for Testing Scene Lua Code

A nudge eh, well, I think you are asking in the wrong topic because I recognize that file as belonging to the plugin DataYours2. You can download the needed files for that plugin and upload them via the UI by choosing Apps, Develop Apps, Luup files.
But why did you put the require line there if you don’t know what it is for?

LuaTest can be used on UI7. Almost everything works correctly. The only failure is that the Device Action List button does not work and produces a Handler failed message. I shall investigate…

LuaTest 1.6 uploaded. This fixes the problem of the Device Action List button not working under UI7. This version should work on UI5, UI6 or UI7.

See the first post for the code and instructions.

[quote=“ilikelife, post:12, topic:180205”]OK, I’m a noob, but this is amazing! I agree with parkerc that it should be pinned, and i also think it should be make a permanent addition to Vera. (with a nice royalty paid to RexBeckett

I’ve been reading and playing and trying to code some things, but it’s SO difficult to know what is going on (or what I’m doing wrong). I’ve been able to accomplish things in other languages, but it helps to “see” my mistakes. This tool allows that. I spent most of yesterday trying things, and came back today to find a bunch of enhancements!

This is just to say THANK YOU to RexBeckett.[/quote]

I just stumbled across LuaTest too, and I’m looking forward to trying it. All weekend (well a good part of it), I’ve been trying to figure out why my luup code was not working. A simple luup.log(“Testing to see if I see ANYTHING!”) results in nada. luup.log(test_variable) outputs a “50” line to the log, but it was painful…

The “Test Luup code” window that Vera gives you should work like LuaTest; instead you press GO and cross your fingers :-).

instead you press GO and cross your fingers :-).

That’s why I created LuaTest. It’s hard to write good code with your fingers crossed. ;D

I’m trying to run this but all i get is no handler from the url. Am i doing something wrong? I’ve followed all the instructions and restarted my vera. Run the code from the test luup code box but still unable to get it to load.

I’m running UI7 FW1.7.388

[quote=“marcbea, post:26, topic:180205”]I’m trying to run this but all i get is no handler from the url. Am i doing something wrong? I’ve followed all the instructions and restarted my vera. Run the code from the test luup code box but still unable to get it to load.

I’m running UI7 FW1.7.388[/quote]

Do you get any error message when you run the three lines in Test Luup? It is possible that Vera is restarting after you run this code - UI7 can do that sometimes. This would lose the link to the handler. If the three lines run without error, you could place them at the end of Startup Lua so that the handler is permanently registered.

Another fan of this tool here. Up and going in minutes.
What a great way to test the logic of code you want to add to scenes, etc.

Many thanks.

[quote=“sgs, post:28, topic:180205”]Another fan of this tool here. Up and going in minutes.
What a great way to test the logic of code you want to add to scenes, etc.

Many thanks.[/quote]

Thanks for the feedback, @sgs. I’m glad you are finding it useful.

What a great tool this is Rex.
Try for a while things in lua but I never got very far. This really helps me big steps forward.

The only thing missing is to add automatic or context help on the function you are using. But I know this is asking too much.

But I’d already be very happy, with a lua help for beginners.
Or links to good help sites, with good examples as part of this tool.

[quote=“Peter, post:30, topic:180205”]What a great tool this is Rex.
Try for a while things in lua but I never got very far. This really helps me big steps forward.

The only thing missing is to add automatic or context help on the function you are using. But I know this is asking too much.

But I’d already be very happy, with a lua help for beginners.
Or links to good help sites, with good examples as part of this tool.[/quote]

Thanks for the feedback, @Peter.

LuaTest uses a very simple browser interface. This was deliberate to allow it to be used on a variety of platforms. It does mean, though, that sophisticated options like context-sensitive help are not possible.

If you would like more advanced development and debugging aids, I recommend Zero Brane Studio for Vera. This is an excellent IDE for Lua that runs the code on Vera and provides a comprehensive set of debugging tools. It does require the purchase of a subscription.

If you haven’t already done so, check out the online Lua Manual. I also recommend getting the Programming in Lua book. This is also available as a online version at [url=http://www.lua.org/pil/]http://www.lua.org/pil/[/url] or as a PDF download.

I have found many useful Lua code snippets on the web. There are numerous examples on stackoverflow and github sites that come up when Googling anything that starts with Lua.

Hi,

Just wanted to say I have had my Vera for 4-5 months now.
I have been scripting lua now since then and its been painstaking if you get something wrong with vera restarts, or tweaking, and looking up variables and functions.

I downloaded this luatest tool just this week and have accomplished more and figured out some bugs and tweaks in minutes. This may be the single greatest tool I have used yet for Vera!

Thanks again!

I echo all the sentiments on the great utility of this tool!

Thanks RexBeckett for this (among other) contributions!!

Rex,

It has been said before, but seriously, this is one fine piece of work. More or less a newb to both LUA and Vera 3 and I have spent hours earlier today trying to figure out what was wrong with my “IF THEN ELSEIF THEN ELSE END” statement and was getting entirely frustrated with the response I was seeing in the log files (basically they were Microsoft answers, …technically correct, but totally useless in solving the problem) and I nailed it in a matter of seconds using this tool.

If they don’t incorporate it in the next UI release I will have to seriously question the powers that be…

Thanks so much!

I’m glad it helped, @mdp716. Thanks for the feedback.

...they were Microsoft answers, ...technically correct, but totally useless in solving the problem...

I had a good chuckle over that. I’ve had a few of those from MS products.

Is there a URL which will allow me to run Luatest via relay instead of with local access directly to my vera’s IP address? E.g. something which I should append to the “https://vera-us-oem-relay41.mios.com…” in my browser.
Thanks!

[quote=“ntkmp42, post:36, topic:180205”]Is there a URL which will allow me to run Luatest via relay instead of with local access directly to my vera’s IP address? E.g. something which I should append to the “https://vera-us-oem-relay41.mios.com…” in my browser.
Thanks![/quote]

I’ve never tried running it remotely. It seems a little risky to me to be testing scene code when you cannot see/hear what happens. I also think there is a good chance that the edit function could be compromised by running through a relay.

If you want to try it, I would expect the following to work:

https://vera-us-oem-relay41.mios.com/<verausername>/<verapassword>/<veraserial>/data_request?id=lr_LuaTest&file=<filename.lua>

Because you are running UI7 you will not be able to do this remotely due to the complex authentication involved.

  • Garrett

Good point, Garrett. I failed to spot the significance of the OP’s server name. ???

Rex, I’ll add my 2 cents to the thread - Thanks for this awesome facility. I used it to debug some (simple) code I was writing to interface with my Ambibox (http://www.ambibox.ru/en/) TV backlight through a telnet API. It allowed me to figure out what was going on in no time, wish I’d come across it several hours earlier.

It made the difference between just giving up and even thinking of trying to turn the code into a full plugin.

Thanks!