Page 1 of 1
Running script from a Domoticz switch
Posted: Sunday 10 September 2017 20:25
by Teknor
I have Pikrellcam installed on my Raspberry Pi 3 for motion detection purposes. I have created two scripts pikrellOn.sh and pikrellOff.sh in the folder pi/domoticz/scripts
The pikrellOn.sh looks like this
- Spoiler: show
-
echo "motion_enable on" > ~/pikrellcam/www/FIFO
and
echo "motion_enable off" > ~/pikrellcam/www/FIFO
When running ./pikrellOn.sh or pikrellOff.sh I can turn on or off motion detection. So far so good. However, I would like to do this with a Domoticz switch. I have created a dummy switch and tried different variations of triggers, but not succeeded. Can anyone point me in the correct direction? ...might need a detailed description here.

Re: Running script from a Domoticz switch
Posted: Sunday 10 September 2017 20:43
by jvdz
Did you set the EXECUTE bit for the pikrellOn.sh? (sudo chmod +x pikrellOn.sh)
Try using the full path: script:///home/pi/domoticz/scripts/pikrellOn.sh
Jos
Re: Running script from a Domoticz switch
Posted: Sunday 10 September 2017 20:58
by Teknor
Hi - yes did run sudo chmod +x for both files. I guess that's why I can run them with the command ./pikrellOn/Off.sh
Re: Running script from a Domoticz switch
Posted: Sunday 10 September 2017 21:03
by jvdz
ok.. and did you try the second suggestion? guess it also needs home in the full path?
Jos
Re: Running script from a Domoticz switch
Posted: Sunday 10 September 2017 21:10
by Teknor
Thanks @jvdz for following up on this one.
Yes, no luck with that either.
These work fine:
~/domoticz/scripts $ ./pikrellOn.sh
~/domoticz/scripts $ ./pikrellOff.sh
..these do not work:
On action: script:///pi/domoticz/scripts/pikrellOn.sh
Off action: script:///pi/domoticz/scripts/pikrellOff.sh
edit: including ///home/pi.... give error in the Domoticz log
Re: Running script from a Domoticz switch
Posted: Sunday 10 September 2017 21:17
by koowee
Teknor wrote: ↑Sunday 10 September 2017 21:10
..these do not work:
On action: script:///pi/domoticz/scripts/pikrellOn.sh
Off action: script:///pi/domoticz/scripts/pikrellOff.sh
Are you sure that those paths are correct? Maybe those should be something like script:///
home/pi/domoticz/scripts/pikrellOn.sh
Re: Running script from a Domoticz switch
Posted: Sunday 10 September 2017 21:20
by philchillbill
Your bash script needs to start with a 'shebang' line at the very top:
or
Re: Running script from a Domoticz switch
Posted: Sunday 10 September 2017 21:25
by Teknor
Changed the path to:
script:///home/pi/domoticz/scripts/pikrellOn.sh
script:///home/pi/domoticz/scripts/pikrellOff.sh
From the Domo log:
2017-09-10 21:19:27.886 Executing script: /home/pi/domoticz/scripts/pikrellOff.sh
2017-09-10 21:19:27.897 Error: Error executing script command (/home/pi/domoticz/scripts/pikrellOff.sh). returned: 512
2017-09-10 21:19:33.727 User: Admin initiated a switch command (6/PikrellAUXSwitch/On)
2017-09-10 21:19:33.734 (DummyAUX) Lighting 1 (PikrellAUXSwitch)
2017-09-10 21:19:33.952 Executing script: /home/pi/domoticz/scripts/pikrellOn.sh
2017-09-10 21:19:33.963 Error: Error executing script command (/home/pi/domoticz/scripts/pikrellOn.sh). returned: 512
Re: Running script from a Domoticz switch
Posted: Sunday 10 September 2017 21:27
by Teknor
Changed the scripts to
Code: Select all
#!/bin/sh
echo "motion_enable on" > ~/pikrellcam/www/FIFO
...still no luck...
These work directly from the terminal, now the scripts also include "shebangs"
Code: Select all
pi@raspaux:~/domoticz/scripts $ ./pikrellOn.sh
pi@raspaux:~/domoticz/scripts $ ./pikrellOff.sh
Re: Running script from a Domoticz switch
Posted: Sunday 10 September 2017 22:48
by Teknor
Solved!
Thanks all. Solution was to specify the whole path in the script
Before
Code: Select all
#!/bin/sh
echo "motion_enable on" > ~/pikrellcam/www/FIFO
Now
Code: Select all
#!/bin/sh
echo "motion_enable on" > /home/pi/pikrellcam/www/FIFO