I did the following:
Hack the dafang camera:
https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks (read the faq and install notes)
Install inotify on rpi:
sudo apt-get install inotify-tools
Install NFS server on rpi:
sudo apt-get install nfs-common nfs-server -y
Make a folder in which you want to share, in my case i made a Dafang folder:
sudo mkdir /mnt/Dafang
sudo chmod -R 777 /mnt/Dafang
Open /etc/exports and add the nfs share:
sudo nano /etc/exports
add the following line(change IPCAM to the ip of the dafang camera:
/mnt/Dafang IPCAM(rw,sync,no_subtree_check,all_squash,anonuid=1000,anongid=1000)
On the dafang camera make a file (i called it nfs) and put it in /system/sdcard/config/autostart
In that file add the following line(change IPDOMOTICZ to the ip of your domoticz):
mount -o nolock -t nfs IPDOMOTICZ:/mnt/Dafang /system/sdcard/motion/stills
Edit /sdcard/config/motion.conf and set save_snapshot=false to save_snapshot=false
Then save the following code to a bash file ie dafang.sh
Code: Select all
#!/bin/bash
#
IMAGEDIRECTORY="/mnt/Dafang" #NFS Location of files saved from DAFANG
CHATID="" #CHATID telegram
BOTID="" #Bot token telegram
MONITORDIR="/mnt/Dafang" #Directory which DAFANG save snapshots to
#no need to edit after this point ...
inotifywait -m -r -e create --format '%w%f' "${MONITORDIR}" | while read NEWFILE
do
cd $IMAGEDIRECTORY || exit
fn=$(ls -t | head -n1)
#-- send message to telegram
curl --data chat_id=$CHATID --data-urlencode "text=Beweging gedetecteerd, is er iemand thuis slaapkamer?" "https://api.telegram.org/$BOTID/sendMessage"
#-- send snapshot with Telegram
curl -s -X POST "https://api.telegram.org/$BOTID/sendPhoto" -F chat_id=$CHATID -F photo=@$fn
done

Edit /etc/rc.local and add(change it to the directory where the dafang.sh file is located:
bash /home/pi/domoticz/scripts/bash/dafang.sh &
And edit accordingly.
I also made a button in domoticz which activates motion detection on and to turn it off with the following urls:
On: http://root:ismart12@IPDAFANG/cgi-bin/a ... tection_on
OFF: http://root:ismart12@IPDAFANG/cgi-bin/a ... ection_off
(note, change the default username/password, and edit IPDAFANG to your Dafang camera ip).
Then a simple blocky which turns the motion detect on (on detection its makes a snapshot) when nobody is home.
Hope this helps anyone with a dafang camera, and sorry for the long post