I can, from the command line run: lua night.lua and get: this will end up in the domoticz log2017-01-25 07:42:06.938 User: Admin initiated a switch command (1/Patio/On)
2017-01-25 07:42:06.939 OpenZWave: Domoticz has send a Switch command! NodeID: 5 (0x05)
2017-01-25 07:42:06.942 (OZW) Light/Switch (Patio)
2017-01-25 07:42:07.934 Executing script: /home/cal/domoticz/scripts/lua/night.lua
2017-01-25 07:42:07.962 Error: Error executing script command (/home/cal/domoticz/scripts/lua/night.lua). returned: 512
lua error 512
Moderator: leecollings
-
- Posts: 20
- Joined: Monday 02 January 2017 17:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
lua error 512
OK, I give up. I need help. Google has been less than helpful. I have Dom running and now I want to create a LUA script that says: if (nighttime) continue else return. So I added "script://lua/night.lua" (using a cut down example) to just 1 line: print("this will end up in the domoticz log"). What I get in the log is:
- Siewert308SW
- Posts: 290
- Joined: Monday 29 December 2014 15:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: The Netherlands
- Contact:
Re: lua error 512
try script:///lua/night.lua
see the three slashes
see the three slashes
Setup:
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
- RPi4 - Domo Stable / Aeotec Z-stick7 / PiHole Unbound Gemini
- RPi4 - PiHole / PiVPN Unbound Gemini
- Synology DS923+ / DS218j
- P1 Gas/Power, SmartGateway watermeter
- Fibaro switches, contacts, plugs, smoke/Co2 ect
- rootfs @ USB HDD
-
- Posts: 20
- Joined: Monday 02 January 2017 17:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: lua error 512
I had tried the "/"x3 before. With "/ / /" my logs say I turned the light on but the "print" line in the lua script doesn't show up - no error, no message. If I use only 2 slashes I get: "Error executing script command (/home/cal/domoticz/scripts/night.lua). returned: 512" in the logs. The thing is that link to night.lua is correct. I can copy and (lua) paste and get the message I should receive in the log.
Question: Does the "print" line in a lua script 'work'? Does a lua script "require" something else? an #include?? a return commandArray? a return 0? Although I think I've tried all combinations.
Do you have a MIN lua script?
Thanks
Question: Does the "print" line in a lua script 'work'? Does a lua script "require" something else? an #include?? a return commandArray? a return 0? Although I think I've tried all combinations.
Do you have a MIN lua script?
Thanks
-
- Posts: 722
- Joined: Friday 02 October 2015 12:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Finland
- Contact:
Re: lua error 512
There are example scripts under ../domoticz/scripts/lua. Also, if you add a script via the event system screen in web UI you get a basic template.
To my understanding the on/off triggers behind the switches are not primarily meant to be used with Lua scripts although they should of course work when used correctly. The event system is designed to trigger Lua scripts based e.g. on "devicechanged" events (I think python is another language possibility if Domoticz is compiled to support that) and when triggered in that way it can use these special tables such as devicechanged, otherdevices, uservariables etc. Then if you want to trigger e.g. bash, php etc. you can do it via the on/off actions. At least this is how I've understood it. Although, as said, nothing wrong as such triggering also Lua from on/off action (just need to remember the limitation concerning e.g. the special tables). If you search the forum you'll find more posts about the issue, strange that google didn't return these...
viewtopic.php?t=7252
And yes, Lua requires "return commandArray" as you can see in the example scripts. If you still have problems I'd suggest to share the entire script here
To my understanding the on/off triggers behind the switches are not primarily meant to be used with Lua scripts although they should of course work when used correctly. The event system is designed to trigger Lua scripts based e.g. on "devicechanged" events (I think python is another language possibility if Domoticz is compiled to support that) and when triggered in that way it can use these special tables such as devicechanged, otherdevices, uservariables etc. Then if you want to trigger e.g. bash, php etc. you can do it via the on/off actions. At least this is how I've understood it. Although, as said, nothing wrong as such triggering also Lua from on/off action (just need to remember the limitation concerning e.g. the special tables). If you search the forum you'll find more posts about the issue, strange that google didn't return these...

viewtopic.php?t=7252
And yes, Lua requires "return commandArray" as you can see in the example scripts. If you still have problems I'd suggest to share the entire script here

-
- Posts: 20
- Joined: Monday 02 January 2017 17:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: lua error 512
Well I have it working but I have to believe there is a code problem bucause:
logs:
So, what I have working is:
note 2 slashes not 3. It runs:
and log contains:
Well now I can move on to the end game which is daytime= driveway motion=On, announce/bell. nighttime= floodOn, KitchendoorOn, FrontdoorOn. And my Cucs are 3mm high, tomatoes are 0.01mm high (itty-bitty little white stem sticking out of seed) so I can start the coding for my hydroponic greenhouse.
Thanks for the pointers - Av'a ber on me.
Code: Select all
-- comment
print("this will end up in the domoticz log")
commandArray = {}
return commandArray
and nothing is logged.Executing script: /home/cal/domoticz/scripts/lua/night.lua
2017-01-26 06:49:58.883 Error: Error executing script command (/home/cal/domoticz/scripts/night.lua). returned: 512
So, what I have working is:
Code: Select all
On Action: script://lua/night.php On
Off Action: script://lua/night.php Off
Code: Select all
#!/usr/bin/php
<?php
echo "Now is the time\n";
$OO = $argv[1];
exec ("/usr/bin/curl -s -i -m 5 -H 'Accept: application/json' 'http://sg53:8080/json.htm?type=command¶m=switchlight&idx=1&switchcmd=$OO'", $ret);
foreach ($ret as $r)
echo "R= $r\n";
which is exactly what I wanted to see - except where is "Now is the time\n" and the several $ret lines? I'm running: PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"2017-01-26 06:18:52.854 OpenZWave: Domoticz has send a Switch command! NodeID: 9 (0x09)
2017-01-26 06:18:52.856 (OZW) Light/Switch (FrontDoor)
2017-01-26 06:18:52.878 OpenZWave: Domoticz has send a Switch command! NodeID: 8 (0x08)
2017-01-26 06:18:52.879 (OZW) Light/Switch (Kitchen Door)
2017-01-26 06:18:53.900 Executing script: /home/cal/domoticz/scripts/lua/night.php
2017-01-26 06:18:54.442 User: Admin initiated a switch command (1/Patio/Off)
2017-01-26 06:18:54.444 OpenZWave: Domoticz has send a Switch command! NodeID: 5 (0x05)
2017-01-26 06:18:54.446 (OZW) Light/Switch (Patio)
Well now I can move on to the end game which is daytime= driveway motion=On, announce/bell. nighttime= floodOn, KitchendoorOn, FrontdoorOn. And my Cucs are 3mm high, tomatoes are 0.01mm high (itty-bitty little white stem sticking out of seed) so I can start the coding for my hydroponic greenhouse.
Thanks for the pointers - Av'a ber on me.
-
- Posts: 722
- Joined: Friday 02 October 2015 12:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Finland
- Contact:
Re: lua error 512
I don't think you can print / echo to Domoticz log form "external" scripts (which the on/off action scripts essentially are). I assume only those scripts (lua / python) that are executed by the event system can do that. Ok, maybe if you somehow specify to write them directly to your Domoticz log file (/var/log/domoticz.log?) - still doubt the "in memory" log in web UI would show those as well.
As for the lua file, if you insist getting rid of the error, check if you have given proper permissions (i.e. sudo chmod 755 file). Still, don't think anything will ever end up to Domoticz log when the script is triggered like this and you only have the "print('Some text')" -type of command there...
As for the lua file, if you insist getting rid of the error, check if you have given proper permissions (i.e. sudo chmod 755 file). Still, don't think anything will ever end up to Domoticz log when the script is triggered like this and you only have the "print('Some text')" -type of command there...

-
- Posts: 20
- Joined: Monday 02 January 2017 17:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: lua error 512
Thing is this: script_time_demo.lua:print('this will end up in the domoticz log')Still, don't think anything will ever end up to Domoticz log when the script is triggered like this and you only have the "print('Some text')" -type of command there..
would lead one to believe that it just might put a message in to log....
-
- Posts: 722
- Joined: Friday 02 October 2015 12:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Finland
- Contact:
Re: lua error 512
Yes, you'll see it in the log as long as you trigger the script via the event system, which to my understanding uses the internal lua engine. When you have it as on/off command it is basically executed as a(ny other) command line script and thus does not have "access" to Domoticz log. What I mean is those example scripts are meant to show what you can do with the event system...liderbug wrote: Thing is this: script_time_demo.lua:print('this will end up in the domoticz log')
would lead one to believe that it just might put a message in to log....

Who is online
Users browsing this forum: No registered users and 1 guest