Cannot execute Lua code in Scene

No idea from the Vera experts here on why my scene scripts are not working? Do I have a cripple device?

Can you post the exact scene code you are trying to use?

None of the script I tried work, so I deleted all my existing scenes and simply trying to run a print statement.

print ("Hello World")

I have occasionally seen the error you are reporting. It is not consistent, and may center around the fact that Vera doesn’t do anything useful with print() in its environment–it does not write the string to the log, and I’m not sure what it does with it (it would have been a simple matter for them to override it and provide a useful implementation, but oh well). Most of the time, it is a completely benign no-op, but occasionally, I can get that odd “can’t call a nil value” error as well. Try using [tt]luup.log(“Hello world”)[/tt] instead.

Also, as is being discussed in other threads right now, scene Lua must return a boolean true or false at whatever exit(s) it takes. Returning false stops the scene execution, and true allows it to continue. So your complete test code might look like this:

luup.log("Hello world",2) return true

The second (optional) argument to luup.log is a message level, which defaults to 50 if not given as in the first paragraph’s example. In the code above, I’ve set it to 2, which outputs the message in yellow (warning) to the Vera log file and makes it easier to find. Also note that the log file is buffered, so the “chunk” may not be written to “disk” and accessible to you until other messages have come sufficient to fill the buffer and cause a write/flush of the block. Running your test scene several times will often produce that result.

Thanks for the insight into the print function.

I copied your exact code and still no go. The message is not sent to the logs. I am starting to think there is an issue with my veraedge.

08      11/27/18 11:54:07.426   JobHandler_LuaUPnP::HandleActionRequest device: 0 se
rvice: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunScene <0x7627
08      11/27/18 11:54:07.427   JobHandler_LuaUPnP::HandleActionRequest argument ser
viceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1 <0x7627d520>
08      11/27/18 11:54:07.427   JobHandler_LuaUPnP::HandleActionRequest argument act
ion=RunScene <0x7627d520>
08      11/27/18 11:54:07.428   JobHandler_LuaUPnP::HandleActionRequest argument Sce
neNum=3 <0x7627d520>
08      11/27/18 11:54:07.428   JobHandler_LuaUPnP::HandleActionRequest argument ran
d=0.5230174351797819 <0x7627d520>
08      11/27/18 11:54:07.428   Scene::RunScene running 3 Test02 <0x7627d520>
01      11/27/18 11:54:07.429   LuaInterface::CallFunction_Scene Scene  3 failed att
empt to call a nil 

OK. Let’s try this. Run the request below (change the IP address to that of your Vera where indicated), and post the output. Let’s see if a broad view exposes anything interesting.


Here goes:

--Devices with UPNP implementations:

function scene_4()
luup.log("Hello world",2)
return true

Ran Hello World from Test Luup code (Lua) under Apps->Develop Apps and got the below in the log:

08      11/27/18 22:51:43.853   JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunLua <0x75c59520>
08      11/27/18 22:51:43.853   JobHandler_LuaUPnP::HandleActionRequest argument id=lu_action <0x75c59520>
08      11/27/18 22:51:43.854   JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1 <0x75c59520>
08      11/27/18 22:51:43.854   JobHandler_LuaUPnP::HandleActionRequest argument action=RunLua <0x75c59520>
08      11/27/18 22:51:43.855   JobHandler_LuaUPnP::HandleActionRequest argument Code=luup.log("Hello world",2)
return true <0x75c59520>
02      11/27/18 22:51:43.856   luup_log:0: Hello world <0x75c59520>

OK. The scene number in the request output is different from the scene number you’ve reported up until reply #7. Did you attempt to delete the scene and recreate it? If not, please do these:



If you did recreate the scene, then, well, I’m at a loss. I see no reason for the scene to take a nil error.

If you did recreate the scene, then, well, I'm at a loss. I see no reason for the scene to take a nil error.
Was hoping you wouldn't say that. I did delete a recreate a new scene to make sure I didn't foobar anything. But for shits and giggles, I check the url you provided.




{ "name": "NewTest01", "triggers_operator": "OR", "groups": [ ], "triggers": [ ], "timers": [ ], "users": "", "modeStatus": "0", "lua": "bHV1cC5sb2coIkhlbGxvIHdvcmxkIiwyKQpyZXR1cm4gdHJ1ZQ==", "encoded_lua": 1, "id": 4, "room": 0, "Timestamp": 1543341318 }

Not sure if this is related, but while messing with the scene (deleting and recreating), now all the names for my smart lock has changed to “Code #” (# matching the index number). Anyway to restore the names that are associated with each PIN code?

I think it’s time you open a ticket with support.

To resurrect this thread…Vera support claimed that the device firmware was too old and may have to lingering bug. I finally had some time to get the firmware updated and still have the same result.

Then I discovered something new, connected the device to the Internet to allow remote support and voila, the scene codes work. WTF. Why is internet connection required to perform local functions like executing a code? Is there a way to bypass this?

My first guess at the problem is the Lua process breaks because Alert is not able to report back to Skynet.

AFAIK Internet connection is required to get the date/time at boot, but you can bypassa that (as I did, search for it in the forum). Apart from that, remote connection is not required, unless you need it for a plugin (ie: Nest, Ecobee or other cloud-based devices).

Have my own internal NTP server from which the device accurately set the time. None of those plugins are present or required.

That’s strange. I have modified my Vera a bit, using @rafale77 code to remove some checks (like the one for Internet connectivity). Search for his thread, you will find some inspiration.

I was just reading your thread and it is quite a mystery… My vera is completely disconnected from the mios servers with the exception of the event servers which is the alerts reporting you are referring to and I have never observed this. That being said, I have most of my code on openLuup these days but still have a couple of scenes on the vera. How did you disconnect the device from the internet? Did you physically unplugged it or did you block IP/ports from your firewall? And do you mean you enabled remote support on the UI? (This creates an SSH tunnel to the vera server).

A wild guess here but it could also be the NetworkMonitor program in the firmware (nothing to do with the plugin) which I have disabled and have asked eZLO to take out as well blocking something.

If @rafale77 has code that can do this, then I have a new best friend :slight_smile:

The veraedge is completely blocked at the firewall. To allow remote support, it was temporarily connected to the DMZ network with no restriction.

Interestingly, I deleted all my old scenes, created a new one with “Hello World” and now it works. I am super confused now. Anyhow, looks like that annoyance is resolved.

@rafale77 Do you have a link to you code to disable internet check? Also, all I am trying to do is have the Veraedge push updates when an even occur. Is there a better way to do this than using scene?

Found this. Will start there.