Page 1 of 1

Run script at Switch on called by webhook

Posted: Saturday 26 October 2019 9:40
by Onrust
Hi all,

I have the following set-up:
- Domoticz running on a Pi
- Security camera software (Shinobi) on a dedicated server
- On motion detection, Shinobi calls a url to set a virtual switch in Domoticz to ON:

Code: Select all

http://192.168.178.60:8080/json.htm?type=command&param=udevice&idx=785&nvalue=1
This functions correctly, the switch is correctly being set to ON at motion.
- In Domoticz, the switch is set to run a script when the status changes to ON. The script looks like this:

Code: Select all

#!/bin/bash
SnapFile="/var/tmp/camsnapshot.jpg"
# Get snapshot via Domoticz server
wget -O $SnapFile "http://192.168.178.60:8080/camsnapshot.jpg?idx=1"
curl -s -X POST "https://api.telegram.org/botxxxxxxx/sendPhoto" -F chat_id=-xxxxx -F photo="@$SnapFile"
# Remove Image
/bin/rm $SnapFile
The issue is that the script doesn't run when the switch is activated from the webhook, even though the switch itself is correctly activated and set to ON. When I activate the switch manually in the Domoticz dashboard, it works fine and the script sends me a picture as expected.

The permissions of the script are set to 777.

What am I doing wrong here?

Re: Run script at Switch on called by webhook

Posted: Saturday 26 October 2019 12:30
by waaren
Onrust wrote: Saturday 26 October 2019 9:40 - On motion detection, Shinobi calls a url to set a virtual switch in Domoticz to ON:

Code: Select all

http://192.168.178.60:8080/json.htm?type=command&param=udevice&idx=785&nvalue=1
This functions correctly, the switch is correctly being set to ON at motion.
What am I doing wrong here?
It is not wrong but the udevice command is not designed to trigger a script or url in the ( on = / off = ) sections.

If you set Shinobi to send

Code: Select all

http://192.168.192.178.60:8080/json.htm?type=command&param=switchlight&idx=785&switchcmd=On
it will probably work

Re: Run script at Switch on called by webhook

Posted: Saturday 26 October 2019 12:58
by Onrust
Awesome, you rock! That worked indeed. Many thanks! :)