Hi,safi78 wrote:Hi,
I recently bought the Foscam C1 which has SOUND detection as well, thought I'd modify your script a bit and share it here:
I decided just to create a fake motion detector which turns off after 5s (don't need script for that )Code: Select all
#!/bin/bash FOSCAMIP="xxx.xxx.xxx.xxx" FOSCAM_PORT="88" FOSCAM_USER="xxxx" FOSCAM_PASS="xxxx" DOMO_IP="xxx.xxx.xxx.xxx" DOMO_PORT="8080" DOMO_USER="xxxx" DOMO_PASS="xxxx" FOSCAM_STATUS_IDX="xxx" #foscam sound detection loop is 5s by default. 5s * 12 = 1 minute (for cron can only schedule every minute) for i in {1..12} do if ping -c 1 $FOSCAMIP &> /dev/null then curl "http://$FOSCAMIP:$FOSCAM_PORT/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=$FOSCAM_USER&pwd=$FOSCAM_PASS" > Foscam.txt # use motionDetectAlarm instead of soundAlarm for motion and change foscam detection loop and sleep multiplier accordingly :) FOSCAMStatus=`grep -oP '(?<=<soundAlarm>).*(?=<\/soundAlarm>)' Foscam.txt` if [ $FOSCAMStatus = "2" ]; then curl -s -i -H "Accept: application/json" "http://$DOMO_USER:$DOMO_PASS@$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=switchlight&idx=$FOSCAM_STATUS_IDX&switchcmd=On&level=0" fi fi sleep 5 done
And, even more awesome, when there's SOUND detected at the cam it sends a snapshot to my Telegram! (Some additional scripting required of-course )
Thanks for the script & inspiration, it works brilliantly!
Kind regards,
Sander
i have a problem with your script, error on the line 25; it seems to here :
if [ $FOSCAMStatus = "2" ];
you explain about this line :
# use motionDetectAlarm instead of soundAlarm for motion and change foscam detection loop and sleep multiplier accordingly
FOSCAMStatus=`grep -oP '(?<=<soundAlarm>).*(?=<\/soundAlarm>)' Foscam.txt`
it creates the foscam.txt file, when i get inside there is lot of characters specials, i guess it's a original picture and the txt file is not the right format.
but i don't know why i have this error
Thanks