The thirst thing I tired was fetching the file via http, so something like http://xxx.xxx.xxx.xxx/snap.jpeg, this works only If you are already logged-in.
Next I tried:
wget --user=ubnt --password=yyyyyy https://xxx.xxx.xxx.xxx:/snap.jpeg this generates the "Unknown authentication scheme" error. It seems that you have to change someting in the camera to make this work. I am a bit lazy to adapt all my camera's.
So I decided to fetch snap.jpeg via scp, problem is however that you need to enter a password and that's not very convenient. There is a trick described on the ubiquiti fora where you have to upload the key into the camera, and again I didnt want to do that.
Next I used sshpass, I know this is not the most secure method, but what the heck it's behind my firewall
Code: Select all
sshpass -p yyyyyyyy scp -r [email protected]:/tmp/snap.jpeg /tmp/snap.jpeg
If you want to call this script from within Domotics, be sure the camera key is in the known_hosts file for root:
Code: Select all
sudo ssh-keyscan -H xxx.xxx.xxx.xxx >> ~/.ssh/known_hosts
The snapshot is rather big so you have to reduce it in size:
Code: Select all
convert -resize 40% /tmp/snap.jpeg /tmp/snap2.jpeg
Code: Select all
base64 --wrap=0 /tmp/snap2.jpeg
Code: Select all
#!/bin/bash
sshpass -p yyyyyyyyyy scp -r [email protected]:/tmp/snap.jpeg /tmp/snap.jpeg
convert -resize 40% /tmp/snap.jpeg /tmp/snap2.jpeg
URL="https://www.pushsafer.com/api"
PRIVATEKEY="" #Your Private or Alias Key
TITLE="Bel!"
MESSAGE="Er wordt gebeld";
# DEVICE="131"; #Device or Device Group ID
ICON="55";
SOUND="3";
VIBRATION="0";
JPEG="$( base64 --wrap=0 /tmp/snap2.jpeg )"
PICTURE="data:image/png;base64,$JPEG";
if [ ${#PRIVATEKEY} == 0 ]
then
echo "Error: You need to supply an app token"
exit 1;
fi
if [ ${#MESSAGE} == 0 ]
then
echo "Error: message may not be empty"
exit 1;
fi
RESPONSE=`curl -s --data k=$PRIVATEKEY --data-urlencode t="$TITLE" --data-urlencode m="$MESSAGE" --data d="$DEVICE" --data i="$ICON" --data s="$SOUND" --data v="$VIBRATION" --data-urlencode p="$PI$
echo "Send Push"
echo "| TITLE: $TITLE"
echo "| MESSAGE: $MESSAGE"
echo "| RESPONSE: $RESPONSE"
echo "|____________________"