Hi guys.
I'm running motionEye on Raspberry PI OS Trixie 64b lite. Raspberry PI 4.
I'm trying to get motionEye alerts on Telegram with this abandoned project: https://github.com/DaniW42/motioneye-telegram
It is working except for not being able to send me the last video. The video it sends me is /boot/firmware/overlays/hifiberry-amp4pro.dtbo which makes me think there's something wrong in the script. That video is in fact the result of:
but it should rather be searched with (my pictures are recorded on an external USB drive mounted on /media/usb0):Unfortunately I'm not good in scripting. Can anyone point me to where the error might be?
This is the script:
Thank you!
I'm running motionEye on Raspberry PI OS Trixie 64b lite. Raspberry PI 4.
I'm trying to get motionEye alerts on Telegram with this abandoned project: https://github.com/DaniW42/motioneye-telegram
It is working except for not being able to send me the last video. The video it sends me is /boot/firmware/overlays/hifiberry-amp4pro.dtbo which makes me think there's something wrong in the script. That video is in fact the result of:
Code:
tree -ftri "/" | grep -v thumb | grep .mp4 | head -n1Code:
tree -ftri "/media/usb0/vs" | grep -v thumb | grep .mp4 | head -n1This is the script:
I don't get the text message and camera id too but that is not much important.#!/bin/bash
## Get the name of the camera which detected a motion (done by parameter %$ in motioneye webinterface command)
var_cameraName=$1
## Get the id of the camera which detected a motion (done by parameter %t in motioneye webinterface command)
var_cameraId=$2
var_forceSend='false'
[[ $@ == *"force"* ]] && var_forceSend="true"
## get my current directory
var_binDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
## Get the name of the motioneye-telegram project directory
var_projectDir="$var_binDir"/..
var_mediaDir="$(dirname $(grep target_dir /home/username/.config/motioneye/camera-$var_cameraId.conf | cut -d ' ' -f 2))"
var_mediaCameraDir="$var_mediaDir/$var_cameraName"
## Read Configuration-File so we have the variables available
source $var_projectDir/telegram.conf
## Functions
func_writeLog () {
printf "$1\n" >> $var_projectDir/motion-send.log
}
func_sendMessage () {
curl -s -X POST "https://api.telegram.org/bot"$var_botAp ... endMessage" -F chat_id="$var_chatId" -F text="$1" | tee -a $var_projectDir/motion-send.log
}
func_sendPhoto () {
curl -s -X POST "https://api.telegram.org/bot"$var_botApiKey"/sendPhoto" -F chat_id="$var_chatId" -F photo="@$1" -F caption="$2" | tee -a $var_projectDir/motion-send.log
}
func_sendVideo () {
curl -s -X POST "https://api.telegram.org/bot"$var_botApiKey"/sendVideo" -F chat_id="$var_chatId" -F video="@$1" -F caption="$2" | tee -a $var_projectDir/motion-send.log
}
func_checkForceSendTrue () {
[ $var_forceSend == "true" ] && var_deviceAvailable="false"
}
func_createSnapArray () {
i=0
while read line
do
snapArray[ $i ]="$line"
(( i++ ))
done < <(tree -ftri "$var_mediaCameraDir" | grep .jpg | head -n"$var_picCount" | sort)
}
func_writeLog "========================================================="
func_writeLog "$(date) - MOTION DETECTED by Camera $var_cameraName."
func_checkForceSendTrue
if $var_deviceAvailable -eq "true"
then
func_writeLog "$(date) - Device available, end script."
func_writeLog "========================================================="
func_writeLog ""
else
func_writeLog "$(date) - Device NOT available, RUN script."
lastvideo=$(tree -ftri "$var_mediaCameraDir" | grep -v thumb | grep .mp4 | head -n1)
func_writeLog "$(date) - \$lastvideo is $lastvideo"
func_writeLog "$(date) - BEGIN sendVideo:"
func_sendVideo $lastvideo "$var_cameraName - ${lastsnap: -23:19}"
func_createSnapArray
j=0
for i in "${snapArray[@]}"
do
func_writeLog "$(date) - snap is ${snapArray[$j]}"
func_writeLog "$(date) - BEGIN sendPhoto:"
var_tmp="${snapArray[$j]}"
func_sendPhoto $i "$var_cameraName - ${var_tmp: -23:19}"
(( j++ ))
done
func_writeLog "========================================================="
func_writeLog ""
fi
exit 0
Thank you!
Statistics: Posted by Raspbop — Wed Jan 21, 2026 3:42 pm — Replies 0 — Views 7