From e1556ec4c9bd83f41e2cf97fc056d219f2c70b7e Mon Sep 17 00:00:00 2001 From: couriersud Date: Mon, 3 Apr 2023 21:25:59 +0200 Subject: [PATCH 1/7] Add inotifyd to busybox build --- src/busybox/.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/busybox/.config b/src/busybox/.config index 4b1e02d..ac252d6 100644 --- a/src/busybox/.config +++ b/src/busybox/.config @@ -755,7 +755,7 @@ CONFIG_HEXEDIT=y # CONFIG_I2CSET is not set # CONFIG_I2CDUMP is not set # CONFIG_I2CDETECT is not set -# CONFIG_INOTIFYD is not set +CONFIG_INOTIFYD=y # CONFIG_LESS is not set CONFIG_FEATURE_LESS_MAXLINES=0 # CONFIG_FEATURE_LESS_BRACKETS is not set From 48091448d0a570fe90703ff39ba8a0cc79bdae49 Mon Sep 17 00:00:00 2001 From: couriersud Date: Mon, 3 Apr 2023 21:27:06 +0200 Subject: [PATCH 2/7] Add inotifyd to busybox build --- src/busybox/install.busybox | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/busybox/install.busybox b/src/busybox/install.busybox index 4043b2d..af55de6 100755 --- a/src/busybox/install.busybox +++ b/src/busybox/install.busybox @@ -15,3 +15,5 @@ echo "#!/mnt/mmc/sonoff-hack/bin/busybox" > ../../build/sonoff-hack/usr/bin/wget chmod 0755 ../../build/sonoff-hack/usr/bin/wget echo "#!/mnt/mmc/sonoff-hack/bin/busybox" > ../../build/sonoff-hack/usr/bin/xargs chmod 0755 ../../build/sonoff-hack/usr/bin/xargs +echo "#!/mnt/mmc/sonoff-hack/bin/busybox" > ../../build/sonoff-hack/usr/bin/inotifyd +chmod 0755 ../../build/sonoff-hack/usr/bin/inotifyd From bdc378c54718d51bf20ffa4e733e81f23508198d Mon Sep 17 00:00:00 2001 From: couriersud Date: Mon, 3 Apr 2023 21:30:29 +0200 Subject: [PATCH 3/7] Add inotifyd to busybox build --- src/busybox/install.busybox | 1 + 1 file changed, 1 insertion(+) diff --git a/src/busybox/install.busybox b/src/busybox/install.busybox index af55de6..e6e1d24 100755 --- a/src/busybox/install.busybox +++ b/src/busybox/install.busybox @@ -17,3 +17,4 @@ echo "#!/mnt/mmc/sonoff-hack/bin/busybox" > ../../build/sonoff-hack/usr/bin/xarg chmod 0755 ../../build/sonoff-hack/usr/bin/xargs echo "#!/mnt/mmc/sonoff-hack/bin/busybox" > ../../build/sonoff-hack/usr/bin/inotifyd chmod 0755 ../../build/sonoff-hack/usr/bin/inotifyd + From 5554150fd1e3bfab955e4d5e9173707a51a1de40 Mon Sep 17 00:00:00 2001 From: couriersud Date: Fri, 7 Apr 2023 18:19:05 +0200 Subject: [PATCH 4/7] Create fast_motion.sh Add support for cam1/fast_motion and cam1/fast_image mqtt topics to have immediate motion detection --- scripts/fast_motion.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 scripts/fast_motion.sh diff --git a/scripts/fast_motion.sh b/scripts/fast_motion.sh new file mode 100644 index 0000000..733703c --- /dev/null +++ b/scripts/fast_motion.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +SONOFF_HACK_PREFIX="/mnt/mmc/sonoff-hack" +MQTT_HOST=192.168.11.5 +MQTT_USER=openhab_iot +MQTT_PASS=PASSWORD + +#LOG_FILE="/dev/null" +LOG_FILE="/tmp/fastmotion.log" + +log() { + echo "$(date +'%Y-%m-%d %H:%M:%S') -" "$*" >> $LOG_FILE +} +run() { + ${SONOFF_HACK_PREFIX}/usr/bin/inotifyd - /tmp:n | while read a b c; do + log received $a $b $c + if [ "$c" = "colinkPushNotice" ]; then + ${SONOFF_HACK_PREFIX}/bin/mosquitto_pub -h ${MQTT_HOST} -u ${MQTT_USER} -P ${MQTT_PASS} -t cam1/fast_motion -m ON + ${SONOFF_HACK_PREFIX}/bin/snapshot -f /tmp/snapfast.jpg + ${SONOFF_HACK_PREFIX}/bin/mosquitto_pub -h ${MQTT_HOST} -u ${MQTT_USER} -P ${MQTT_PASS} -t cam1/fast_image -f /tmp/snapfast.jpg + sleep 5 + ${SONOFF_HACK_PREFIX}/bin/mosquitto_pub -h ${MQTT_HOST} -u ${MQTT_USER} -P ${MQTT_PASS} -t cam1/fast_motion -m OFF + fi + done +} + +run_loop() { + while true; do + log "Starting fast mation detection ..." + run + log "aborted ... waiting 10 seconds" + sleep 10 + done +} + +run_loop From 1efa94f0d6f858f5ad13f8ef62fd39876d3c2614 Mon Sep 17 00:00:00 2001 From: couriersud Date: Fri, 7 Apr 2023 18:25:59 +0200 Subject: [PATCH 5/7] Delete fast_motion.sh --- scripts/fast_motion.sh | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 scripts/fast_motion.sh diff --git a/scripts/fast_motion.sh b/scripts/fast_motion.sh deleted file mode 100644 index 733703c..0000000 --- a/scripts/fast_motion.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh - -SONOFF_HACK_PREFIX="/mnt/mmc/sonoff-hack" -MQTT_HOST=192.168.11.5 -MQTT_USER=openhab_iot -MQTT_PASS=PASSWORD - -#LOG_FILE="/dev/null" -LOG_FILE="/tmp/fastmotion.log" - -log() { - echo "$(date +'%Y-%m-%d %H:%M:%S') -" "$*" >> $LOG_FILE -} -run() { - ${SONOFF_HACK_PREFIX}/usr/bin/inotifyd - /tmp:n | while read a b c; do - log received $a $b $c - if [ "$c" = "colinkPushNotice" ]; then - ${SONOFF_HACK_PREFIX}/bin/mosquitto_pub -h ${MQTT_HOST} -u ${MQTT_USER} -P ${MQTT_PASS} -t cam1/fast_motion -m ON - ${SONOFF_HACK_PREFIX}/bin/snapshot -f /tmp/snapfast.jpg - ${SONOFF_HACK_PREFIX}/bin/mosquitto_pub -h ${MQTT_HOST} -u ${MQTT_USER} -P ${MQTT_PASS} -t cam1/fast_image -f /tmp/snapfast.jpg - sleep 5 - ${SONOFF_HACK_PREFIX}/bin/mosquitto_pub -h ${MQTT_HOST} -u ${MQTT_USER} -P ${MQTT_PASS} -t cam1/fast_motion -m OFF - fi - done -} - -run_loop() { - while true; do - log "Starting fast mation detection ..." - run - log "aborted ... waiting 10 seconds" - sleep 10 - done -} - -run_loop From 8a34281502e2a69537903d74ffe5b293acb05a6d Mon Sep 17 00:00:00 2001 From: couriersud Date: Fri, 7 Apr 2023 18:26:53 +0200 Subject: [PATCH 6/7] Create fast_motion.sh --- .../static/sonoff-hack/script/fast_motion.sh | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/static/static/sonoff-hack/script/fast_motion.sh diff --git a/src/static/static/sonoff-hack/script/fast_motion.sh b/src/static/static/sonoff-hack/script/fast_motion.sh new file mode 100644 index 0000000..733703c --- /dev/null +++ b/src/static/static/sonoff-hack/script/fast_motion.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +SONOFF_HACK_PREFIX="/mnt/mmc/sonoff-hack" +MQTT_HOST=192.168.11.5 +MQTT_USER=openhab_iot +MQTT_PASS=PASSWORD + +#LOG_FILE="/dev/null" +LOG_FILE="/tmp/fastmotion.log" + +log() { + echo "$(date +'%Y-%m-%d %H:%M:%S') -" "$*" >> $LOG_FILE +} +run() { + ${SONOFF_HACK_PREFIX}/usr/bin/inotifyd - /tmp:n | while read a b c; do + log received $a $b $c + if [ "$c" = "colinkPushNotice" ]; then + ${SONOFF_HACK_PREFIX}/bin/mosquitto_pub -h ${MQTT_HOST} -u ${MQTT_USER} -P ${MQTT_PASS} -t cam1/fast_motion -m ON + ${SONOFF_HACK_PREFIX}/bin/snapshot -f /tmp/snapfast.jpg + ${SONOFF_HACK_PREFIX}/bin/mosquitto_pub -h ${MQTT_HOST} -u ${MQTT_USER} -P ${MQTT_PASS} -t cam1/fast_image -f /tmp/snapfast.jpg + sleep 5 + ${SONOFF_HACK_PREFIX}/bin/mosquitto_pub -h ${MQTT_HOST} -u ${MQTT_USER} -P ${MQTT_PASS} -t cam1/fast_motion -m OFF + fi + done +} + +run_loop() { + while true; do + log "Starting fast mation detection ..." + run + log "aborted ... waiting 10 seconds" + sleep 10 + done +} + +run_loop From a9df4ebc7e9cf9917874f9f1619848b73ac652de Mon Sep 17 00:00:00 2001 From: couriersud Date: Fri, 7 Apr 2023 18:28:55 +0200 Subject: [PATCH 7/7] Update system.sh Start fast_motion demon --- src/static/static/sonoff-hack/script/system.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/static/static/sonoff-hack/script/system.sh b/src/static/static/sonoff-hack/script/system.sh index 256f8f4..c418885 100755 --- a/src/static/static/sonoff-hack/script/system.sh +++ b/src/static/static/sonoff-hack/script/system.sh @@ -343,6 +343,9 @@ fi # Run rtsp watchdog $SONOFF_HACK_PREFIX/script/wd_rtsp.sh & +# Run fast_motion +$SONOFF_HACK_PREFIX/script/fast_motion.sh & + # Add crontab CRONTAB=$(get_config CRONTAB) FREE_SPACE=$(get_config FREE_SPACE)