Lua script executing problem

Moderator: leecollings

Post Reply
panomi
Posts: 8
Joined: Sunday 03 January 2016 13:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Lua script executing problem

Post 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!
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Lua script executing problem

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
panomi
Posts: 8
Joined: Sunday 03 January 2016 13:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Lua script executing problem

Post 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: ....
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Lua script executing problem

Post 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
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
panomi
Posts: 8
Joined: Sunday 03 January 2016 13:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Lua script executing problem

Post 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'
panomi
Posts: 8
Joined: Sunday 03 January 2016 13:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Lua script executing problem

Post 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?
User avatar
nayr
Posts: 354
Joined: Tuesday 11 November 2014 18:42
Target OS: Linux
Domoticz version: github
Location: Denver, CO - USA
Contact:

Re: Lua script executing problem

Post by nayr »

why dont you execute the python script directly? whats the point of this shell script that executes another script?
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
panomi
Posts: 8
Joined: Sunday 03 January 2016 13:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Lua script executing problem

Post 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.
User avatar
nayr
Posts: 354
Joined: Tuesday 11 November 2014 18:42
Target OS: Linux
Domoticz version: github
Location: Denver, CO - USA
Contact:

Re: Lua script executing problem

Post 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
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
User avatar
nayr
Posts: 354
Joined: Tuesday 11 November 2014 18:42
Target OS: Linux
Domoticz version: github
Location: Denver, CO - USA
Contact:

Re: Lua script executing problem

Post 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.")
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
panomi
Posts: 8
Joined: Sunday 03 January 2016 13:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Lua script executing problem

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest