mirror of
https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks.git
synced 2025-09-02 20:52:41 +02:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -51,6 +51,7 @@ firmware_mod/System Volume Information/IndexerVolumeGuid
|
||||
firmware_mod/System Volume Information/WPSettings.dat
|
||||
firmware_mod/config/motion.conf
|
||||
firmware_mod/config/mqtt.conf
|
||||
firmware_mod/config/telegram.conf
|
||||
firmware_mod/config/sendmail.conf
|
||||
firmware_mod/config/rtspserver.conf
|
||||
firmware_mod/config/ntp_srv.conf
|
||||
|
43
firmware_mod/bin/telegram
Executable file
43
firmware_mod/bin/telegram
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
what="$1"
|
||||
shift
|
||||
data="$@"
|
||||
CURL="/system/sdcard/bin/curl"
|
||||
|
||||
. /system/sdcard/config/telegram.conf
|
||||
|
||||
sendMessage() {
|
||||
text="$(echo "${@}" | sed 's:\\n:\n:g')"
|
||||
echo "Sending message: $text"
|
||||
|
||||
$CURL -s \
|
||||
-X POST \
|
||||
https://api.telegram.org/bot$apiToken/sendMessage \
|
||||
--data-urlencode "text=$text" \
|
||||
-d "chat_id=$userChatId"
|
||||
}
|
||||
|
||||
sendFile() {
|
||||
echo "Sending file: $1"
|
||||
$CURL -s \
|
||||
-X POST \
|
||||
https://api.telegram.org/bot$apiToken/sendDocument \
|
||||
-F chat_id="$userChatId" \
|
||||
-F document=@"$1"
|
||||
}
|
||||
|
||||
sendPhoto() {
|
||||
caption="$(hostname)-$(date +"%d%m%Y_%H%M%S")"
|
||||
echo "Sending Photo: $1 $caption" >> /tmp/telegram.log
|
||||
$CURL -s \
|
||||
-X POST \
|
||||
https://api.telegram.org/bot$apiToken/sendPhoto \
|
||||
-F chat_id="$userChatId" \
|
||||
-F photo="@${1}" \
|
||||
-F caption="${caption}"
|
||||
}
|
||||
|
||||
[ "$what" == "m" ] && sendMessage $data
|
||||
[ "$what" == "f" ] && sendFile $data
|
||||
[ "$what" == "p" ] && sendPhoto $data
|
||||
[ -z "$what" ] && echo -e "$0 <m|f|p> <data>\n m: message\n f: file\n p: picture"
|
@@ -17,4 +17,5 @@ save_snapshot=false
|
||||
max_snapshots=20
|
||||
publish_mqtt_message=false
|
||||
sendemail=false
|
||||
send_telegram=false
|
||||
save_dir=/system/sdcard/motion/stills
|
||||
|
7
firmware_mod/config/telegram.conf.dist
Normal file
7
firmware_mod/config/telegram.conf.dist
Normal file
@@ -0,0 +1,7 @@
|
||||
############################################################
|
||||
# edit this file and move it to /system/sdcard/config/telegram.conf #
|
||||
############################################################
|
||||
|
||||
# Add your Telegram credentials here (these are just examples)
|
||||
apiToken="23132160:AAFrSEwzJ-X-64tLnD8JJ$JoAxWIMg$$w"
|
||||
userChatId="30985132"
|
@@ -13,13 +13,13 @@ fi
|
||||
if [ "$save_snapshot" = true ] ; then
|
||||
filename=$(date +%d-%m-%Y_%H.%M.%S).jpg
|
||||
if [ ! -d "$save_dir" ]; then
|
||||
mkdir -p $save_dir
|
||||
mkdir -p "$save_dir"
|
||||
fi
|
||||
# Limit the number of snapshots
|
||||
if [[ $(ls $save_dir | wc -l) -ge $max_snapshots ]]; then
|
||||
rm -f "$save_dir/$(ls -l $save_dir | awk 'NR==2{print $9}')"
|
||||
if [ "$(ls "$save_dir" | wc -l)" -ge "$max_snapshots" ]; then
|
||||
rm -f "$save_dir/$(ls -l "$save_dir" | awk 'NR==2{print $9}')"
|
||||
fi
|
||||
/system/sdcard/bin/getimage > $save_dir/$filename &
|
||||
/system/sdcard/bin/getimage > "$save_dir/$filename" &
|
||||
fi
|
||||
|
||||
# Publish a mqtt message
|
||||
@@ -27,7 +27,7 @@ if [ "$publish_mqtt_message" = true ] ; then
|
||||
. /system/sdcard/config/mqtt.conf
|
||||
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -m "ON"
|
||||
if [ "$save_snapshot" = true ] ; then
|
||||
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -f $save_dir/$filename
|
||||
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/snapshot ${MOSQUITTOOPTS} ${MOSQUITTOPUBOPTS} -f "$save_dir/$filename"
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -37,9 +37,20 @@ if [ "$sendemail" = true ] ; then
|
||||
/system/sdcard/scripts/sendPictureMail.sh&
|
||||
fi
|
||||
|
||||
# Send a telegram message
|
||||
if [ "$send_telegram" = true ]; then
|
||||
if [ "$save_snapshot" = true ] ; then
|
||||
/system/sdcard/bin/telegram p "$save_dir/$filename"
|
||||
else
|
||||
/system/sdcard/bin/getimage > "telegram_image.jpg"
|
||||
+ /system/sdcard/bin/telegram p "telegram_image.jpg"
|
||||
+ rm "telegram_image.jpg"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run any user scripts.
|
||||
for i in /system/sdcard/config/userscripts/motiondetection/*; do
|
||||
if [ -x $i ]; then
|
||||
if [ -x "$i" ]; then
|
||||
echo "Running: $i on"
|
||||
$i on
|
||||
fi
|
||||
|
@@ -31,12 +31,12 @@
|
||||
<div class="control">
|
||||
<div class="select">
|
||||
<select name="motion_sensitivity" id="motion_sensitivity">
|
||||
<option value="-1">Motion deactivated</option>
|
||||
<option value="0">0</option>
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
<option value="3">3</option>
|
||||
<option value="4">4</option>
|
||||
<option value="-1">Deactivated</option>
|
||||
<option value="0">Very Low</option>
|
||||
<option value="1">Low</option>
|
||||
<option value="2">Moderate</option>
|
||||
<option value="3">High</option>
|
||||
<option value="4">Very High</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user