Running script from a Domoticz switch

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
User avatar
Teknor
Posts: 30
Joined: Monday 08 February 2016 13:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.48
Location: Norway
Contact:

Running script from a Domoticz switch

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

Image
Attachments
Skjermbilde 2017-09-10 kl. 20.22.24.png
Skjermbilde 2017-09-10 kl. 20.22.24.png (329.71 KiB) Viewed 15245 times
Raspberry Pi 3 | EasyESP NodeMCU v3 | RFXTRX433e | Mysensors NRF24L01 | MotionEYE | PikrellCam
User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Running script from a Domoticz switch

Post 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
Last edited by jvdz on Sunday 10 September 2017 21:04, edited 1 time in total.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
Teknor
Posts: 30
Joined: Monday 08 February 2016 13:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.48
Location: Norway
Contact:

Re: Running script from a Domoticz switch

Post 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
Raspberry Pi 3 | EasyESP NodeMCU v3 | RFXTRX433e | Mysensors NRF24L01 | MotionEYE | PikrellCam
User avatar
jvdz
Posts: 2269
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Running script from a Domoticz switch

Post by jvdz »

ok.. and did you try the second suggestion? guess it also needs home in the full path?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
Teknor
Posts: 30
Joined: Monday 08 February 2016 13:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.48
Location: Norway
Contact:

Re: Running script from a Domoticz switch

Post 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
Last edited by Teknor on Sunday 10 September 2017 21:18, edited 1 time in total.
Raspberry Pi 3 | EasyESP NodeMCU v3 | RFXTRX433e | Mysensors NRF24L01 | MotionEYE | PikrellCam
koowee
Posts: 62
Joined: Thursday 29 December 2016 18:17
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Finland
Contact:

Re: Running script from a Domoticz switch

Post 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
User avatar
philchillbill
Posts: 399
Joined: Monday 12 September 2016 13:47
Target OS: Linux
Domoticz version: beta
Location: Eindhoven. NL
Contact:

Re: Running script from a Domoticz switch

Post by philchillbill »

Your bash script needs to start with a 'shebang' line at the very top:

Code: Select all

 #!/bin/sh
or

Code: Select all

 #!/bin/bash
Alexa skills author: EvoControl, Statereport, MediaServer, LMS-lite
User avatar
Teknor
Posts: 30
Joined: Monday 08 February 2016 13:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.48
Location: Norway
Contact:

Re: Running script from a Domoticz switch

Post 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
Raspberry Pi 3 | EasyESP NodeMCU v3 | RFXTRX433e | Mysensors NRF24L01 | MotionEYE | PikrellCam
User avatar
Teknor
Posts: 30
Joined: Monday 08 February 2016 13:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.48
Location: Norway
Contact:

Re: Running script from a Domoticz switch

Post 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
Raspberry Pi 3 | EasyESP NodeMCU v3 | RFXTRX433e | Mysensors NRF24L01 | MotionEYE | PikrellCam
User avatar
Teknor
Posts: 30
Joined: Monday 08 February 2016 13:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.48
Location: Norway
Contact:

Re: Running script from a Domoticz switch

Post 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
Raspberry Pi 3 | EasyESP NodeMCU v3 | RFXTRX433e | Mysensors NRF24L01 | MotionEYE | PikrellCam
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest