Test Luup code failed with server error 500.

I’m a new one in vera but I think I have some issues with the luup engine. I tried to develop just a simple luup code. I did the test in the develop apps → test luup code (lua)

this was my code
local x = 1
I know it’s very very simple but I did that for some reason. After pressing go the message “sent sucesfully” came back.
Then I created a little bit more complex one

local deviceNo = 6

local SS_SID = “urn:micasaverde-com:serviceId:MotionSensor1” – Security Sensor Service ID

local armed = luup.variable_get (SS_SID, “Armed”, deviceNo)

if (armed == “1”) then
return true
return false

This ends with code failed and the firebug is saying 500 internal server error. I though that there is an issue with my code so I deleted everything and went back to the code
local x = 1

but this is ending with the code failed too. tho only thing to get even the local x = 1 working I have to reboot the vera lite.

This is the response after I click on the go in test

<s:Envelope xmlns:s=“http://schemas.xmlsoap.org/soap/envelope/” s:encodingStyle=“http://schemas.xmlsoap.org/soap/encoding/”>

Code failed


I’m running the latest version of the firmware
You are running the latest version: 1.5.408 .

Could please somebody point me where the error could be?

You may not be doing anything wrong. The “test Luup code” box will say Code Failed whenever your code returns false. This makes it somewhat unhelpful. I advise users to avoid it.

The 500 Server Error might not be telling you anything useful either. It may be that way by design.

To add to futzle’s reply, you may want to upgrade to 1.5.622 firmware as you are running a very old version.


  • Garrett

Thank you guys for the reply.
futzle could you please advice what should I use for the debugging? and I do not understand why the test said error code even from local x = 1. there should be no issue.
garrettwp thank you very much also for the info. I was not aware that I’m running the old firmware as according to the firmware tab in my vera lite I was running the latest one. I just upgraded to 1.5.622 as you recommended.
Unfortunately the behavior of the test luup code is the same. It looks to me like after putting one wrong there it’s “frozen” and ever the right code then is ending with code failed. Which is really not good. Could this be a bug?




local x=1
return true

And try reversing [tt]true[/tt]/[tt]false[/tt] in your intended code, to see if you get the opposite behavior.

And try changing to the [tt]SecuritySensor1[/tt] service ID.

[code]local deviceNo = 6

local SS_SID = “urn:micasaverde-com:serviceId:SecuritySensor1” – Security Sensor Service ID

local armed = luup.variable_get (SS_SID, “Armed”, deviceNo)

if (armed == “1”) then
return true
return false[/code]


Good catch.

  • Garrett

This is just a guess: A statement like “local x” or an if-statement is neither true nor false. Try an indisputably true statement like “return true” and see what it does.

I normally advise that you just bang the Luup code straight into the scene you want it to live in. You’ll need to watch the Luup log to see what’s going on, but learning to read the Luup log is IMO unavoidable so you may as well get used to it.

If you want to keep using the Test Luup Code box, be aware of its limitations. Stick a “return true” at the end and don’t return anywhere else. Use luup.log() if you want to see the value of a variable, and inspect the Luup log to see what it prints.

Exactly. [tt]local x=1[/tt] may yield ‘success’; a subsequent [tt]return false[/tt] will yield ‘fail’; a subsequent [tt]local x=1[/tt] now yields ‘fail’.

thank you very much
you were right.
the return false caused it. I most probably did not know correctly how it works. I though it’s for checking the code → if the syntax is ok.
So I was waiting for some code ok, result is false (of the code run). Thank you again for your help it’s working ok now.

Is there some other tools for luup development? for example for vim or something else or what are you using please?
thank you

(Don’t laugh) I just use vim in a terminal. About the fanciest customization I do is to :set ts=2. Anything else distracts from the Zone.

Once, I tried LuaEclipse. Oh dear.

Lua for Windows works well for checking Lua syntax and functionality. It does not support Luup calls, though, so you have to debug them live in Vera.

If you are on a mac, you may want to look into “CodeRunner”, it supports many languages. I also use vim heavily as well.

  • Garrett

Yup, the Luup test box has had all of us confused, as @futzle said. There is an open bug report to have it improved.

Yup, vim.