Page 1 of 1

Bash Script Problem on a Pi Running Domoticz 4.11488

Posted: Friday 29 November 2019 20:57
by alarm_guy1
Hi guys,

I have a simple bash script, in domoticz/scripts/doorbell.sh

Code: Select all

#!/bin/sh
sudo aplay ~/doorbell-1.wav &
exit 0
It has the rights 777

and if I run sh doorbell.sh from within domoticz/scripts/doorbell.sh my Pi plays the doorbell-1.wav no issues

I have a switch in Domoticz that I can manually turn on and off.(Pic attached)
and refers to the Bash script
When I toggle the switch nothing, no sound nothing.
The log reads as follows
2019-11-29 19:54:32.854 (Esp Wifi 1) Light/Switch (test GPIO 5)
2019-11-29 19:54:32.842 Status: User: Admin initiated a switch command (283/test GPIO 5/On)
2019-11-29 19:54:33.073 Status: Executing script: /home/pi/domoticz/scripts/doorbell.sh
2019-11-29 19:54:34.367 (domoticz) General/kWh (Kitchen Lights kWh Meter)
2019-11-29 19:54:34.405 (domoticz) Usage (Kitchen Lights Watts 1)
2019-11-29 19:54:34.412 (domoticz) General/kWh (Kitchen Lights kWh Meter)
2019-11-29 19:54:34.442 (Esp Wifi 1) Light/Switch (test GPIO 5)
2019-11-29 19:54:34.433 Status: User: Admin initiated a switch command (283/test GPIO 5/Off)
2019-11-29 19:54:35.178 (domoticz) General/kWh (Kitchen Lights kWh Meter)

I have no idea where to go with this as it appears to be working in Domoticz but no sound and def. works from the command line

Any help greatly appreciated

Re: Bash Script Problem on a Pi Running Domoticz 4.11488

Posted: Saturday 30 November 2019 0:39
by waaren
waaren wrote: Saturday 30 November 2019 0:37
alarm_guy1 wrote: Friday 29 November 2019 20:57 I have no idea where to go with this as it appears to be working in Domoticz but no sound and def. works from the command line
Can you try with the full qualified scriptname ? So something like script:///home/pi/domoticz/scripts/doorbell.sh

Re: Bash Script Problem on a Pi Running Domoticz 4.11488

Posted: Saturday 30 November 2019 2:30
by alarm_guy1
Thanks for the quick reply,
Unfortunately that made no difference, other than stating it was working ok and executing the script.

It is like Domoticz doesn't have rights to the sound card or similar

Re: Bash Script Problem on a Pi Running Domoticz 4.11488

Posted: Saturday 30 November 2019 6:09
by waaren
alarm_guy1 wrote: Saturday 30 November 2019 2:30 It is like Domoticz doesn't have rights to the sound card or similar
Or maybe (the user executing) domoticz does not recognize the aplay command or cannot find the wav file.
Please try with full qualified aplay command and parm (something like sudo /usr/bin/play /home/pi/doorbell-1.wav & ) as the env maybe different for domoticz.

Re: Bash Script Problem on a Pi Running Domoticz 4.11488 [SOLVED]

Posted: Saturday 30 November 2019 8:16
by alarm_guy1
Many many thanks

works a treat
cheers

Just added the line as you said and BOOM

sudo /usr/bin/play /home/pi/doorbell-1.wav &