Lua script executing sh script... not working! Topic is solved

echeberri77
Posts: 36
Joined: Friday 09 March 2018 19:52
Target OS: Linux
Domoticz version: 3.9203
Location: Italy
Contact:

Re: Lua script executing sh script... not working!

Post by echeberri77 » Friday 23 March 2018 17:18

echeberri77 wrote:
jannl wrote:The path ezsynth inside the script. The script itself is executed as shown in the Domoticz log
Ok, I'll adding complete path. I'll let you know. Thanks!

Inviato dal mio MHA-L29 utilizzando Tapatalk
Found the First issue: i played for the First time the welcome audio message using izsynth and the root user. When playback occurs an mp3 file is created and It Will be played for the next times... But if you playback It for the First time with root user It Will be only "root readable" with no permissions for other... I saw the izsynth log and I found that playback occurs correctly only if root user launch the Command... Is any other user launch that izsynth string Will receive a read permission Denied! I changed permissions in that mp3 file and not It is possible to hear It when played by a non root user. Domoticz however still mute on playing It.
..There must ne something else...

Inviato dal mio MHA-L29 utilizzando Tapatalk


echeberri77
Posts: 36
Joined: Friday 09 March 2018 19:52
Target OS: Linux
Domoticz version: 3.9203
Location: Italy
Contact:

Re: Lua script executing sh script... not working!

Post by echeberri77 » Friday 23 March 2018 23:01

Still not working!
I added into the sh file the complete path as suggested:

Code: Select all

#!/bin/bash
/home/xavier/Documenti/izsynth-master/izsynth -e naturalreaders -v Federica -t "Luci del corridoio accese"
I also tried to delete cached mp3 file and let domoticz creates itself by executing che script. The mp3 file is corrected created (by domoticz triggering) but I am not able to hear any sound!
It's crazy....

DennisD
Posts: 67
Joined: Friday 18 September 2015 21:46
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Lua script executing sh script... not working!

Post by DennisD » Saturday 24 March 2018 0:12

Maybe unrelated , but i encounter the same issue with a script (bash file) which i call in a blocky

jvandenbroek
Posts: 172
Joined: Wednesday 12 March 2014 17:37
Target OS: Raspberry Pi
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Lua script executing sh script... not working!

Post by jvandenbroek » Saturday 24 March 2018 15:48

Supplying full path in script should work, but keep in mind that if the called path itself calls other binaries, it might not work. Try including PATH=/usr/local/bin:/usr/bin etc, make sure that all paths are included.

echeberri77
Posts: 36
Joined: Friday 09 March 2018 19:52
Target OS: Linux
Domoticz version: 3.9203
Location: Italy
Contact:

Re: Lua script executing sh script... not working!

Post by echeberri77 » Saturday 24 March 2018 16:01

jvandenbroek wrote:Supplying full path in script should work, but keep in mind that if the called path itself calls other binaries, it might not work. Try including PATH=/usr/local/bin:/usr/bin etc, make sure that all paths are included.
Still not working.
I tried to change into izsynth configuration the path where mp3 are stored once created. Then I asked domoticz di launch a new sound message creating in this way a new mp3 audio into the new path. If i look to this file permissions settings I Can see that root created It... It means domoticz uses root priviledges to launch script.
I still however have the problem: no audio. If i launch from a terminal the sh batch (using both a root and a no-root user) i cani correctly hear sound!!!
If It would be a path issue I shouldn't be able to hear sound when launching sh from terminal too.
I am really confused.

Inviato dal mio MHA-L29 utilizzando Tapatalk



echeberri77
Posts: 36
Joined: Friday 09 March 2018 19:52
Target OS: Linux
Domoticz version: 3.9203
Location: Italy
Contact:

Re: Lua script executing sh script... not working!

Post by echeberri77 » Sunday 25 March 2018 8:28

Let me sum up it all again.
Into my domoticz system I have this dummy light switch:

Code: Select all

  Turn On	13	SonOff_corridoio	A	1	Luci corridoio	Lighting 1	X10	Off
This switch is used to command my sonoff and in particular it switchs on a light. If I push the software button I can switch lamp ON.
In my domoticz directory

Code: Select all

/home/xavier/domoticz/scripts/
(I have these scripts):
script_device_lucicorridoiovoice.lua

Code: Select all

commandArray = {} 

if (devicechanged['Luci corridoio'] == 'On') then
os.execute ('/home/xavier/domoticz/scripts/luci_corridoio.sh &')
end 

return commandArray
luci_corridoio.sh

Code: Select all

#!/bin/bash
/home/xavier/domoticz/scripts/izsynth -e naturalreaders -v Federica -t "Luci del corridoio accese"
Into this script directory I also copied izsynth executable.

All files inside script directory are chmod +x and chmod 777.

User used by domoticz to launch to execute script is root user.

If I trigger luci_corridoio.sh with domoticz lighting button it correctly creates the mp3 sound file (it means it is able to correctly launch izsynth).


Let's start all from the beginning. Any idea?

User avatar
jannl
Posts: 955
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Geleen
Contact:

Re: Lua script executing sh script... not working!

Post by jannl » Sunday 25 March 2018 8:49

Read the posts regarding the path settings.
Make sure all path settings and environment settings are the same in the command line and in the script. They are different depending on the way the script is started. Either direct from commandline or via Domoticz. This is linux, not windows.

Redirecting set and/or setenv to a file in the scripts helps to debug the differences.

echeberri77
Posts: 36
Joined: Friday 09 March 2018 19:52
Target OS: Linux
Domoticz version: 3.9203
Location: Italy
Contact:

Re: Lua script executing sh script... not working!

Post by echeberri77 » Sunday 25 March 2018 9:29

jannl wrote:
Sunday 25 March 2018 8:49
Redirecting set and/or setenv to a file in the scripts helps to debug the differences.
Could you please help me doing this?
Thanks!

echeberri77
Posts: 36
Joined: Friday 09 March 2018 19:52
Target OS: Linux
Domoticz version: 3.9203
Location: Italy
Contact:

Re: Lua script executing sh script... not working!

Post by echeberri77 » Sunday 25 March 2018 9:40

I added log to che lua script execution.
script_device_lucicorridoio.lua

Code: Select all

commandArray = {} 
if (devicechanged['Lucicorridoio'] == 'On') then
os.execute ('/home/xavier/domoticz/scripts/Lucicorridoio.sh>/home/xavier/domoticz/scripts/log/lua.log')
end 
return commandArray
This is the content of lua.log after switch ON (and mp3 file is alredy present on script directory):

Code: Select all

================================================================================
[2C [1/1] - izsynth Name:[Luci_del_corridoio_accese-1641778200] 
File exist   - input:[/home/xavier/domoticz/scripts/Luci_del_corridoio_accese-1641778200.mp3]
Playing      - input:[/home/xavier/domoticz/scripts/Luci_del_corridoio_accese-1641778200.mp3] command:[mplayer] options:[ -quiet -nolirc -noconsolecontrols -afm mp3lib,ffmpeg]
--------------------------------------------------------------------------------
[2C [1/1] 
This is the content of lua.log in case mp3 is not yet present:

Code: Select all

[2C [1/1] - izsynth Name:[Luci_del_corridoio_accese-1641778200] 
Synthesizing - input:[/home/xavier/domoticz/scripts/izsynth-20180325-094039/Luci_del_corridoio_accese-1641778200.txt] engine:[naturalreaders] voice:[Federica] output:[/home/xavier/domoticz/scripts/Luci_del_corridoio_accese-1641778200.mp3] size:[20K] type:[audio/mpeg] result:[SUCCESS]
Playing      - input:[/home/xavier/domoticz/scripts/Luci_del_corridoio_accese-1641778200.mp3] command:[mplayer] options:[ -quiet -nolirc -noconsolecontrols -afm mp3lib,ffmpeg]
--------------------------------------------------------------------------------
[2C [1/1] 
Err...it doesn't tell me so much....From what I can read mp3 file is correctly played.....hmmmmm

User avatar
jannl
Posts: 955
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Geleen
Contact:

Re: Lua script executing sh script... not working!

Post by jannl » Sunday 25 March 2018 10:12

Hm. I agree. Looks like it is working. Not sure if it is a volume issue. Can you set the volume from the script?

set > filename.log sends the output of set toba file. Same for setenv

echeberri77
Posts: 36
Joined: Friday 09 March 2018 19:52
Target OS: Linux
Domoticz version: 3.9203
Location: Italy
Contact:

Re: Lua script executing sh script... not working!

Post by echeberri77 » Sunday 25 March 2018 10:41

jannl wrote:
Sunday 25 March 2018 10:12
Hm. I agree. Looks like it is working. Not sure if it is a volume issue. Can you set the volume from the script?

set > filename.log sends the output of set toba file. Same for setenv
Err...I don't really know how to do that. Could you explain please?

User avatar
jannl
Posts: 955
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Geleen
Contact:

Re: Lua script executing sh script... not working!

Post by jannl » Sunday 25 March 2018 10:47

What do mean?

If you mean set > filename.log. add that to the log and replace filename.log with a path and filename the user the script runs under has write rights.

echeberri77
Posts: 36
Joined: Friday 09 March 2018 19:52
Target OS: Linux
Domoticz version: 3.9203
Location: Italy
Contact:

Re: Lua script executing sh script... not working!

Post by echeberri77 » Sunday 25 March 2018 10:54

I forced volume 100 (the maximum) to izsynth arguments. This is content of lua.log:

Code: Select all

================================================================================
[2C [1/1] - izsynth Name:[Luci_del_corridoio_accese-1203338941] 
File exist   - input:[/home/xavier/domoticz/scripts/Luci_del_corridoio_accese-1203338941.44khz.wav]
Playing      - input:[/home/xavier/domoticz/scripts/Luci_del_corridoio_accese-1203338941.44khz.wav] command:[mplayer] options:[ -quiet -nolirc -noconsolecontrols -afm mp3lib,ffmpeg -ao alsa -volume 100]
--------------------------------------------------------------------------------
[2C [1/1] 
Last edited by echeberri77 on Sunday 25 March 2018 11:00, edited 1 time in total.

User avatar
jannl
Posts: 955
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Geleen
Contact:

Re: Lua script executing sh script... not working!

Post by jannl » Sunday 25 March 2018 10:59

Looks like an error in the script or calling the script

User avatar
jannl
Posts: 955
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Geleen
Contact:

Re: Lua script executing sh script... not working!

Post by jannl » Sunday 25 March 2018 10:59

Debugging in linux can be a pain in the ass

echeberri77
Posts: 36
Joined: Friday 09 March 2018 19:52
Target OS: Linux
Domoticz version: 3.9203
Location: Italy
Contact:

Re: Lua script executing sh script... not working!

Post by echeberri77 » Sunday 25 March 2018 11:00

jannl wrote:
Sunday 25 March 2018 10:59
Looks like an error in the script or calling the script
It was my mistake: a missing " at the end of a line. Now fixed.

echeberri77
Posts: 36
Joined: Friday 09 March 2018 19:52
Target OS: Linux
Domoticz version: 3.9203
Location: Italy
Contact:

Re: Lua script executing sh script... not working!

Post by echeberri77 » Sunday 25 March 2018 15:46

Still no luck.
I don't really know what to check at this point....

echeberri77
Posts: 36
Joined: Friday 09 March 2018 19:52
Target OS: Linux
Domoticz version: 3.9203
Location: Italy
Contact:

Re: Lua script executing sh script... not working!

Post by echeberri77 » Tuesday 27 March 2018 9:37

echeberri77 wrote:Still no luck.
I don't really know what to check at this point....
During these days i had the chance to try another vocal synthetizer and I am having the same issue: no output audio. It seems to be a sound card output problem. Domoticz seems unable to use the correct sound card for output...
Any suggestion?

Inviato dal mio MHA-L29 utilizzando Tapatalk


echeberri77
Posts: 36
Joined: Friday 09 March 2018 19:52
Target OS: Linux
Domoticz version: 3.9203
Location: Italy
Contact:

Re: Lua script executing sh script... not working!

Post by echeberri77 » Tuesday 27 March 2018 15:47

SOLVED!!!! Damn, damn and damn again !!!!! :lol: :lol: :lol: :lol: :lol:
Izsynth uses by defaul the first alsa device. The curious thing is: if you launch izsynth from terminal it uses the secondary output (that is my sound card). If izsynth is launched within a sh script by domoticz it try to use alsa device 0 that in my system is hdmi audio (that is not used)!!!!
How to solve it?
Here we are:

Code: Select all

#!/bin/bash
izsynth -e fromtexttospeech -v Carla22 -t "Attenzione, luci del corridoio accese" -w  -d alsa:device=hw=1.3

This drove me totally crazy!!!! :mrgreen: :mrgreen: :mrgreen: :mrgreen:

User avatar
jannl
Posts: 955
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Geleen
Contact:

Re: Lua script executing sh script... not working!

Post by jannl » Saturday 31 March 2018 10:16

This is probably because during installation some settings where made taking care of using the correct output as a default.

Thisis why I told you to investigate that. During script execution in this way the normal user settings are not present. The same counts for instance for crontab scripts.

Jan

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest