Error executing script command lua returned: 512

Moderator: leecollings

Post Reply
romeok01
Posts: 8
Joined: Wednesday 08 July 2015 20:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2563
Location: Poland
Contact:

Error executing script command lua returned: 512

Post by romeok01 »

I have problem with script in lua.

I write simple script in lua:

Code: Select all

commandArray = {}
 if (devicechanged['LED Zielona'] == 'On')  then
    commandArray['LED Czerwona']='On'
 end
 return commandArray
Name this file is: led.lua and i move this in folder: /home/pi/domoticz/scripts/lua

This is switch in my Domoticz
Image

I copy link for my script lua.led, to switch script, is: script://home/pi/domoticz/scripts/lua/led.lua

Image

When i turn on my LED Zielona sript led.lua not working :(

I have Domoticz v. 2.2653.
In log i have error:
Error executing script command (/home/pi/domoticz/scripts/lua/led.lua). returned: 512

When i run my script in console (sudo lua led.lua) i have error:
lua: led.lua:2: attempt to index global 'devicechanged' (a nil value)
stack traceback:
led.lua:2: in main chunk
[C]: in ?
Please help me.
roblom
Posts: 402
Joined: Wednesday 26 February 2014 15:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: the Netherlands
Contact:

Re: Error executing script command lua returned: 512

Post by roblom »

Rename the la script to "script_device_led.lua".
Remove the link on the switch. Then it should work.
Lua knows the state of the switches so you don't have to let the switch start the script. The lua script executes when the switch is correctly programmed.
romeok01
Posts: 8
Joined: Wednesday 08 July 2015 20:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.2563
Location: Poland
Contact:

Re: Error executing script command lua returned: 512

Post by romeok01 »

Thank You Very Much roblom :)

Now its work :)
elgarne
Posts: 36
Joined: Monday 26 May 2014 14:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Error executing script command lua returned: 512

Post by elgarne »

I'm in the same situation (error 512) and this is a workaround not the solution to this problem.
As stated in other threads, each script_device* script is executed each time a device state is changed. Thus, the more script_device* scripts you have, the most time it takes. Hence having a non script_device* script is interesting since it is executed only when required.
User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Error executing script command lua returned: 512

Post by jvdz »

Not sure if there is a question in your post, but I am using one script_device_main.lua script which is the only script fired when a device changes. It has a bunch of if's which will run the appropriate LUA script when the if is true by using the dofile() command.
This keeps the number of ran script to a minimum and it did speed up the whole process.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
elgarne
Posts: 36
Joined: Monday 26 May 2014 14:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Error executing script command lua returned: 512

Post by elgarne »

Yes, I understand but it is still a workaround.
domoticz is supposed to execute a script from a switch's "on" or "off" action, if the right path to the script is provided. Nevertheless, it returns a 512 error in such a case and I'd like to know how to fix this issue.
User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Error executing script command lua returned: 512

Post by jvdz »

So, why are you getting the 512? what are the error details?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
elgarne
Posts: 36
Joined: Monday 26 May 2014 14:54
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Error executing script command lua returned: 512

Post by elgarne »

If the file is renamed to script_device_CheckPresence.lua and has an

Code: Select all

if devicechanged['mydevice']
statement, it works perfectly. But if executed through the on action of a dummy switch, then it generates the following error:

Code: Select all

Error: Error executing script command (/home/pi/domoticz/scripts/lua/CheckPresence.lua). returned: 512
I googled for this error and all the threads I found about it have a similar workaround than the one you suggested. Some suggest to make the file executable etc but no solution seems to fix the issue.
User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Error executing script command lua returned: 512

Post by jvdz »

That makes sense as these extra Tables are not available when the script is manually shelled or through the On/Off action of a switch.
They are only available when you use the standard lua event system by using script_trigger_name.lua and stored in domoticz\scripts\lua.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest