Run script at Switch on called by webhook Topic is solved

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
Onrust
Posts: 37
Joined: Saturday 24 June 2017 10:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Contact:

Run script at Switch on called by webhook

Post 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?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Run script at Switch on called by webhook

Post 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
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Onrust
Posts: 37
Joined: Saturday 24 June 2017 10:44
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Contact:

Re: Run script at Switch on called by webhook

Post by Onrust »

Awesome, you rock! That worked indeed. Many thanks! :)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest