Page 1 of 1

Lua script executing problem

Posted: Sunday 03 January 2016 15:28
by panomi
I'm starting with Domoticz and I've got the following problem executing a lua script. The situation is as follows:

- Got a virtual switch named: 'Yamaha'
- I've got the following lua script(script_device_Yamaha.lua) which resides in the folder: '/volume1/@appstore/domoticz/var/scripts/lua'

Code: Select all

commandArray = {}

if (devicechanged['Yamaha'] == 'Off') then
os.execute ("/volume1/@appstore/domoticz/var/scripts/test.sh")
end

return commandArray
- The script is supposed to execute the 'test.sh' in folder '/volume1/@appstore/domoticz/var/scripts/'
- The 'test.sh' has got the following code:

Code: Select all

#!/bin/sh

python /volume1/@appstore/domoticz/var/scripts/rxv_uit.py
- Both scripts are executable (chmod +x) and if I run the 'test.sh' the script runs and turns my Yamaha receiver on.

Problem lies with the lua script I think. Also I see no logging entries, looks like the lua script is not detected by Domoticz?

If someone can point me in the right direction that would be great!

Re: Lua script executing problem

Posted: Sunday 03 January 2016 15:34
by jvdz
Think you need sh in front of your script:

Code: Select all

os.execute ("sh /volume1/@appstore/domoticz/var/scripts/test.sh")
Jos

Re: Lua script executing problem

Posted: Sunday 03 January 2016 15:39
by panomi
jvdz wrote:Think you need sh in front of your script:

Code: Select all

os.execute ("sh /volume1/@appstore/domoticz/var/scripts/test.sh")
Jos
Tried that but no luck. Log shows:

Code: Select all

2016-01-03 15:36:18.348 (Dummy Control) Lighting 2 (Yamaha)
2016-01-03 15:36:22.727 (Dummy Control) Lighting 2 (Yamaha)
I think I should get something like below but that isn't the case:

Code: Select all

 EventSystem: Script event triggered: ....

Re: Lua script executing problem

Posted: Sunday 03 January 2016 15:44
by jvdz
panomi wrote: I think I should get something like below but that isn't the case:

Code: Select all

 EventSystem: Script event triggered: ....
You will only get that notification when you add the script to the Device Setup window in the "On Action" or "Off action" as :

Code: Select all

script:///volume1/@appstore/domoticz/var/scripts/test.sh
Jos

Re: Lua script executing problem

Posted: Sunday 03 January 2016 15:59
by panomi
Ok. If you don't fill out the On or Off action and you use a script in the lua folder this is automatically called, correct?

In the mean time still trying. If I add an escape character before ("\sh /") then the EventSystem comes up with an error which means the script is executed but the .sh file is not :).

Code: Select all

EventSystem: .../local/domoticz/var/scripts/lua/script_device_Yamaha.lua:6: invalid escape sequence near '\s'

Re: Lua script executing problem

Posted: Friday 08 January 2016 17:54
by panomi
Just checking, if I execute command LUA on my synology I get : -ash: lua: not found.

Do I need to install LUA libraries or are these included in Domoticz installation?

Re: Lua script executing problem

Posted: Friday 08 January 2016 19:47
by nayr
why dont you execute the python script directly? whats the point of this shell script that executes another script?

Re: Lua script executing problem

Posted: Friday 08 January 2016 19:51
by panomi
True, the problem is, I can't execute anything. Not with On / Off action and .sh or python. The scripts are all functional but nog through Domoticz. Files have execute rights. I'm confused.

Re: Lua script executing problem

Posted: Friday 08 January 2016 19:54
by nayr
your paths are pretty unique, I presume thats part of the package setup for your nas.. maby something got messed up there.

I had issue with an update broke my scripts, turns out they changed backend so relative paths worked and I had to add an extra / infront for the full path, ie: script:///path/to/script.sh worked but script://path/to/script.sh failed... might give full path a try with the 3x slashes

Re: Lua script executing problem

Posted: Friday 08 January 2016 20:00
by nayr
also for debugging add some console logging to your lua to see if its really firing off or not.

Code: Select all

print("Executing external script to turn off receiver.")

Re: Lua script executing problem

Posted: Saturday 23 January 2016 13:52
by panomi
Ik heb het probleem als volgt opgelost:

Een RPi2 gepakt en hierop Domoticz geïnstalleerd. Scripts werken direct.
Ik weet dus nog steeds niet waarom ze het op de Synology niet doen, maar kost teveel tijd om uit te zoeken.