Page 1 of 3
Take snapshot with camera when ringing doorbell
Posted: Saturday 16 July 2016 23:26
by denkol
I am new to this forum and have some questions. Although I have searched for a topic on this forum, I get not found anything that can help me. I'm a starter with Domoticz and already playfully acquainted with the program. I have no programming knowledge, but do like to experiment with everything that has to do with automation. What I have achieved; At this time I got it done if someone rings my doorbell, enters the lighting in my hall and I get a push message on my phone. What do I expand now? I would like it if someone pressed my doorbell with my security camera a snapshot is created and sent via push to my phone. I read somewhere that this should be possible by using a script. Where can I find a script that I can modify it if necessary? How / where do I put the software Domoticz this script? Where can I find somewhere a good description of "how it works". Thanks for the effort
Re: Take snapshot with camera when ringing doorbell
Posted: Sunday 17 July 2016 7:12
by Egregius
Re: Take snapshot with camera when ringing doorbell
Posted: Sunday 17 July 2016 8:08
by trixwood
with your post 345... 346 now

Re: Take snapshot with camera when ringing doorbell
Posted: Sunday 17 July 2016 9:09
by denkol
Thanks. Do not know why I could not find it myself. Hope I can find my answer here.

Re: Take snapshot with camera when ringing doorbell
Posted: Wednesday 03 January 2018 0:10
by ernieb44
I have been working on this for a while now and used the script provided by a fellow Domoticz forum user.
The script has been improved over time, it now consists of transcoding a video directly from the RTSP stream from my cam and sending it to Telegram when someone hits the doorbell. In the event that someone hits the doorbell again within 10 seconds after the previous push the script does nothing.
I've created a blockly event where it rings the bell and kicks off the script below the moment de doorbell is pressed.
Make sure you have
ffmpeg installed [sudo apt-get install ffmpeg]
Code: Select all
#!/bin/sh
now=$(date +"%T")
SnapFile="/var/tmp/frontdoorcam.mp4" # Temp name of the video, change it when using this script for multiple cams
VideoLength=5 # Seconds to record
WaitTime=10 # Seconds the script waits before it sends another video
User=**** # Username which has access to the RTSP stream
Password=****** # Password for above provided user
rtspUrl="rtsp://$User:$Password@[IP address]/" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url
ChatID=******* # Telegram chat ID See https://www.domoticz.com/wiki/Installing_Telegram_Notification_System for setup instructions
TelegramAPIToken=*********:********************** # Telegram API token
filedate=`stat -L --format %Y $SnapFile`
retc=$?
if [ $retc -eq 0 ] ; then
sec=$(( `date +%s`-$filedate))
echo file found and age is $sec seconds
else
sec=999
echo File not found $SnapFile
fi
if [ $sec -gt $WaitTime ] ; then
echo file older than $WaitTime seconds: $sec sending video
ffmpeg -y -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile
curl -s -F chat_id=$ChatID -F video="@$SnapFile" -F caption="$now Doorbell ringing.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo
else
echo There was another try within $WaitTime seconds: $sec
fi
Re: Take snapshot with camera when ringing doorbell
Posted: Wednesday 03 January 2018 16:14
by gajotnt
Hello Ernieb44, can you do a more detailed explanation on how to make this?
ernieb44 wrote: ↑Wednesday 03 January 2018 0:10
I have been working on this for a while now and used the script provided by a fellow Domoticz forum user.
The script has been improved over time, it now consists of transcoding a video directly from the RTSP stream from my cam and sending it to Telegram when someone hits the doorbell. In the event that someone hits the doorbell again within 10 seconds after the previous push the script does nothing.
I've created a blockly event where it rings the bell and kicks off the script below the moment de doorbell is pressed.
Make sure you have
ffmpeg installed [sudo apt-get install ffmpeg]
Code: Select all
#!/bin/sh
now=$(date +"%T")
SnapFile="/var/tmp/frontdoorcam.mp4" # Temp name of the video, change it when using this script for multiple cams
VideoLength=5 # Seconds to record
WaitTime=10 # Seconds the script waits before it sends another video
User=**** # Username which has access to the RTSP stream
Password=****** # Password for above provided user
rtspUrl="rtsp://$User:$Password@[IP address]/" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url
ChatID=******* # Telegram chat ID See https://www.domoticz.com/wiki/Installing_Telegram_Notification_System for setup instructions
TelegramAPIToken=*********:********************** # Telegram API token
filedate=`stat -L --format %Y $SnapFile`
retc=$?
if [ $retc -eq 0 ] ; then
sec=$(( `date +%s`-$filedate))
echo file found and age is $sec seconds
else
sec=999
echo File not found $SnapFile
fi
if [ $sec -gt $WaitTime ] ; then
echo file older than $WaitTime seconds: $sec sending video
ffmpeg -y -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile
curl -s -F chat_id=$ChatID -F video="@$SnapFile" -F caption="$now Doorbell ringing.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo
else
echo There was another try within $WaitTime seconds: $sec
fi
Re: Take snapshot with camera when ringing doorbell
Posted: Thursday 04 January 2018 19:12
by gajotnt
Looks like FFMPEG isint available.
Had to use:
apt-get install libav-tools
Guess that now for me to send photos instead of video it should be something like this (will try as soon as I get home):
Code: Select all
#!/bin/sh
now=$(date +"%T")
SnapFile="/var/tmp/frontdoorcam.jpg" # Temp name of the photo, change it when using this script for multiple cams
#VideoLength=5 # Seconds to record
WaitTime=10 # Seconds the script waits before it sends another photo
User=**** # Username which has access to the RTSP stream
Password=****** # Password for above provided user
rtspUrl="rtsp://$User:$Password@[IP address]/" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url
ChatID=******* # Telegram chat ID See https://www.domoticz.com/wiki/Installing_Telegram_Notification_System for setup instructions
TelegramAPIToken=*********:********************** # Telegram API token
filedate=`stat -L --format %Y $SnapFile`
retc=$?
if [ $retc -eq 0 ] ; then
sec=$(( `date +%s`-$filedate))
echo file found and age is $sec seconds
else
sec=999
echo File not found $SnapFile
fi
if [ $sec -gt $WaitTime ] ; then
echo file older than $WaitTime seconds: $sec sending photo
avconv -rtsp_transport tcp -i $rtspUrl -f image2 -vframes 1 -pix_fmt yuvj420p $SnapFile # avconv -i $rtspUrl -vf $SnapFile
curl -s -F chat_id=$ChatID -F photo="@$SnapFile" -F caption="$now Doorbell ringing.." https://api.telegram.org/bot$TelegramAPIToken/sendPhoto
else
echo There was another try within $WaitTime seconds: $sec
fi
Re: Take snapshot with camera when ringing doorbell
Posted: Friday 12 January 2018 20:35
by ernieb44
gajotnt wrote: ↑Wednesday 03 January 2018 16:14
Hello Ernieb44, can you do a more detailed explanation on how to make this?
ernieb44 wrote: ↑Wednesday 03 January 2018 0:10
I have been working on this for a while now and used the script provided by a fellow Domoticz forum user.
The script has been improved over time, it now consists of transcoding a video directly from the RTSP stream from my cam and sending it to Telegram when someone hits the doorbell. In the event that someone hits the doorbell again within 10 seconds after the previous push the script does nothing.
I've created a blockly event where it rings the bell and kicks off the script below the moment de doorbell is pressed.
Make sure you have
ffmpeg installed [sudo apt-get install ffmpeg]
Code: Select all
#!/bin/sh
now=$(date +"%T")
SnapFile="/var/tmp/frontdoorcam.mp4" # Temp name of the video, change it when using this script for multiple cams
VideoLength=5 # Seconds to record
WaitTime=10 # Seconds the script waits before it sends another video
User=**** # Username which has access to the RTSP stream
Password=****** # Password for above provided user
rtspUrl="rtsp://$User:$Password@[IP address]/" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url
ChatID=******* # Telegram chat ID See https://www.domoticz.com/wiki/Installing_Telegram_Notification_System for setup instructions
TelegramAPIToken=*********:********************** # Telegram API token
filedate=`stat -L --format %Y $SnapFile`
retc=$?
if [ $retc -eq 0 ] ; then
sec=$(( `date +%s`-$filedate))
echo file found and age is $sec seconds
else
sec=999
echo File not found $SnapFile
fi
if [ $sec -gt $WaitTime ] ; then
echo file older than $WaitTime seconds: $sec sending video
ffmpeg -y -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile
curl -s -F chat_id=$ChatID -F video="@$SnapFile" -F caption="$now Doorbell ringing.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo
else
echo There was another try within $WaitTime seconds: $sec
fi
Sure.. i can do that.. but please let me know what extra information you are looking for?
Re: Take snapshot with camera when ringing doorbell
Posted: Thursday 13 December 2018 11:13
by wastaal
ernieb44 wrote: ↑Wednesday 03 January 2018 0:10
I have been working on this for a while now and used the script provided by a fellow Domoticz forum user.
The script has been improved over time, it now consists of transcoding a video directly from the RTSP stream from my cam and sending it to Telegram when someone hits the doorbell. In the event that someone hits the doorbell again within 10 seconds after the previous push the script does nothing.
I've created a blockly event where it rings the bell and kicks off the script below the moment de doorbell is pressed.
Make sure you have
ffmpeg installed [sudo apt-get install ffmpeg]
Code: Select all
#!/bin/sh
now=$(date +"%T")
SnapFile="/var/tmp/frontdoorcam.mp4" # Temp name of the video, change it when using this script for multiple cams
VideoLength=5 # Seconds to record
WaitTime=10 # Seconds the script waits before it sends another video
User=**** # Username which has access to the RTSP stream
Password=****** # Password for above provided user
rtspUrl="rtsp://$User:$Password@[IP address]/" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url
ChatID=******* # Telegram chat ID See https://www.domoticz.com/wiki/Installing_Telegram_Notification_System for setup instructions
TelegramAPIToken=*********:********************** # Telegram API token
filedate=`stat -L --format %Y $SnapFile`
retc=$?
if [ $retc -eq 0 ] ; then
sec=$(( `date +%s`-$filedate))
echo file found and age is $sec seconds
else
sec=999
echo File not found $SnapFile
fi
if [ $sec -gt $WaitTime ] ; then
echo file older than $WaitTime seconds: $sec sending video
ffmpeg -y -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile
curl -s -F chat_id=$ChatID -F video="@$SnapFile" -F caption="$now Doorbell ringing.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo
else
echo There was another try within $WaitTime seconds: $sec
fi
I'm trying to get this to work but so far no luck. Anyone here who can help me out? Here's the script which is on my raspberry.
Code: Select all
#!/bin/sh
now=$(date +"%T")
SnapFile="/var/tmp/frontdoorcam.mp4" # Temp name of the video, change it when using this script for multiple cams
VideoLength=5 # Seconds to record
WaitTime=10 # Seconds the script waits before it sends another video
User=<username> # Username which has access to the RTSP stream
Password=<password> # Password for above provided user
rtspUrl="rtsp://$User:[email protected]:554/play1.sdp/" # Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url
ChatID=<chatid> # Telegram chat ID See https://www.domoticz.com/wiki/Installing_Telegram_Notification_System for setup instructions
TelegramAPIToken=<token> # Telegram API token
filedate=`stat -L --format %Y $SnapFile`
retc=$?
if [ $retc -eq 0 ] ; then
sec=$(( `date +%s`-$filedate))
echo file found and age is $sec seconds
else
sec=999
echo File not found $SnapFile
fi
if [ $sec -gt $WaitTime ] ; then
echo file older than $WaitTime seconds: $sec sending video
ffmpeg -y -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile
curl -s -F chat_id=$ChatID -F video="@$SnapFile" -F caption="$now Doorbell ringing.." https://api.telegram.org/bot$TelegramAPIToken/sendVideo
else
echo There was another try within $WaitTime seconds: $sec
fi
FFMpeg is installed. RTSP dream works in VLC. When I run the script I get the following error.
Code: Select all
stat: cannot stat '/var/tmp/frontdoorcam.mp4': No such file or directory
File not found /var/tmp/frontdoorcam.mp4
file older than 10 seconds: 999 sending video
ffmpeg version 3.2.10-1~deb9u1+rpt2 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Raspbian 6.3.0-18+rpi1+deb9u1) 20170516
configuration: --prefix=/usr --extra-version='1~deb9u1+rpt2' --toolchain=hardened --libdir=/usr/lib/arm-linux-gnueabihf --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libebur128 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx-rpi --enable-mmal --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libiec61883 --arch=armhf --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
libavutil 55. 34.101 / 55. 34.101
libavcodec 57. 64.101 / 57. 64.101
libavformat 57. 56.101 / 57. 56.101
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libavresample 3. 1. 0 / 3. 1. 0
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
[rtsp @ 0xb97620] method DESCRIBE failed: 404 File Not Found, Or In Incorrect Format
rtsp://admin:[email protected]:554/play1.sdp/: Server returned 404 Not Found
Re: Take snapshot with camera when ringing doorbell
Posted: Saturday 09 February 2019 16:22
by tonbor
Did you change the variables to your own, IP adres, password...… etc. And if so, did you get the script working after all?
Re: Take snapshot with camera when ringing doorbell
Posted: Tuesday 12 February 2019 20:36
by wastaal
tonbor wrote: ↑Saturday 09 February 2019 16:22
Did you change the variables to your own, IP adres, password...… etc. And if so, did you get the script working after all?
No unfortunately not. And yes, I changed IP adres, pass word....
Re: Take snapshot with camera when ringing doorbell
Posted: Wednesday 13 February 2019 14:45
by tonbor
I did examen this piece of code. I cannot find the part where the ip camera starts to record and give back the result to the variable $retc in this bash file. Should be here I think but it isn't "retc=$?=$?………………………."

I will look further…….
Re: Take snapshot with camera when ringing doorbell
Posted: Wednesday 13 February 2019 15:07
by tonbor
I did not look very well, this is the video catch line ffmpeg -y -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile, still trying…….
Re: Take snapshot with camera when ringing doorbell
Posted: Wednesday 13 February 2019 15:54
by tonbor
Do not worry, I came far, but not yet to the end

Re: Take snapshot with camera when ringing doorbell
Posted: Thursday 14 February 2019 20:53
by wastaal
tonbor wrote: ↑Wednesday 13 February 2019 15:54
Do not worry, I came far, but not yet to the end
Would be awesome if you get it right.
Re: Take snapshot with camera when ringing doorbell
Posted: Monday 18 February 2019 17:32
by tonbor
I got it working. The code is allright. Use your ip adres of your camera (not domoticz) and right url, see onvif suggestions in the code. So your ip and url should be in place of this piece of code "@192.168.1.22:554/play1.sdp/" Copy code from the net make sure it is not dos characters, so use dos2unix if you get unespected and of file running bash. Do install FFMJPEG library. And do not forget to chmod your bashfile.That s it.

Re: Take snapshot with camera when ringing doorbell
Posted: Monday 18 February 2019 21:27
by tonbor
#!/bin/sh
now=$(date +"%T")
SnapFile="/var/tmp/frontdoorcam.mp4" # Temp name of the video, change it when using this script for multiple cams
VideoLength=5 # Seconds to record
WaitTime=10 # Seconds the script waits before it sends another video
User="user" # Username which has access to the RTSP stream
Password="password" # Password for above provided user
rtspUrl="rtsp://user:
[email protected]:554/11"
# Use https://sourceforge.net/projects/onvifdm/ to find your correct RTSP stream url
echo $rtspUrl
ChatID=yourIDenumber # Telegram chat ID See
https://www.domoticz.com/wiki/Installin ... ion_System for setup instructions
TelegramAPIToken="number:verylongstring" # Telegram API token
echo $TelegramAPIToken
filedate=`stat -L --format %Y $SnapFile`
ffmpeg -y -i $rtspUrl -r 30 -vcodec copy -an -t $VideoLength $SnapFile
curl -s -F chat_id=$ChatID -F video="@$SnapFile" -F caption="$now Deurbel klinkt.."
https://api.telegram.org/bot$TelegramAPIToken/sendVideo
Re: Take snapshot with camera when ringing doorbell
Posted: Wednesday 20 February 2019 15:56
by tonbor
It

Works
Re: Take snapshot with camera when ringing doorbell
Posted: Wednesday 20 February 2019 17:23
by Prutsium
Fun ... ook even het scriptje als basis gebruikt maar ik krijg het binnen als een (Animated)Gif .... klopt dat?
Re: Take snapshot with camera when ringing doorbell
Posted: Wednesday 20 February 2019 17:25
by wastaal
tonbor wrote: ↑Wednesday 20 February 2019 15:56It

Works
Super! Unfortunately no luck here. Still same errors. I will look into this later again.