diff --git a/firmware_mod/scripts/common_functions.sh b/firmware_mod/scripts/common_functions.sh index 5c7a18e..2b2f385 100755 --- a/firmware_mod/scripts/common_functions.sh +++ b/firmware_mod/scripts/common_functions.sh @@ -290,6 +290,30 @@ motion_detection(){ esac } +# Control the motion detection mail function +motion_send_mail(){ + case "$1" in + on) + rewrite_config /system/sdcard/config/motion.conf sendemail "true" + ;; + off) + rewrite_config /system/sdcard/config/motion.conf sendemail "false" + ;; + status) + status=`awk '/sendemail/' /system/sdcard/config/motion.conf |cut -f2 -d \=` + case $status in + false) + echo "OFF" + ;; + true) + echo "ON" + ;; + esac + esac +} + + + # Control the motion tracking function motion_tracking(){ case "$1" in diff --git a/firmware_mod/scripts/mqtt-autodiscovery.sh b/firmware_mod/scripts/mqtt-autodiscovery.sh index 86b1cf3..60e8305 100644 --- a/firmware_mod/scripts/mqtt-autodiscovery.sh +++ b/firmware_mod/scripts/mqtt-autodiscovery.sh @@ -9,6 +9,9 @@ # Motion detection on/off switch /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/motion_detection/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME motion detection\", \"icon\": \"mdi:run\", \"state_topic\": \"$TOPIC/motion/detection\", \"command_topic\": \"$TOPIC/motion/detection/set\"}" +# Motion send mail alert on/off switch +/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/switch/$DEVICE_NAME/motion_send_mail/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME motion send mail\", \"icon\": \"mdi:run\", \"state_topic\": \"$TOPIC/motion/send_mail\", \"command_topic\": \"$TOPIC/motion/send_mail/set\"}" + # Motion detection snapshots /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/camera/$DEVICE_NAME/motion_snapshot/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{\"name\": \"$DEVICE_NAME motion snapshot\", \"topic\": \"$TOPIC/motion/snapshot\"}" diff --git a/firmware_mod/scripts/mqtt-control.sh b/firmware_mod/scripts/mqtt-control.sh index 91534fa..3cfb972 100755 --- a/firmware_mod/scripts/mqtt-control.sh +++ b/firmware_mod/scripts/mqtt-control.sh @@ -146,6 +146,20 @@ killall mosquitto_sub.bin 2> /dev/null /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/detection ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_detection status)" ;; + "${TOPIC}/motion/send_mail") + /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)" + ;; + + "${TOPIC}/motion/send_mail/set ON") + motion_send_mail on + /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)" + ;; + + "${TOPIC}/motion/send_mail/set OFF") + motion_send_mail off + /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_send_mail status)" + ;; + "${TOPIC}/motion/tracking") /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -m "$(motion_tracking status)" ;; diff --git a/firmware_mod/scripts/mqtt-status-interval.sh b/firmware_mod/scripts/mqtt-status-interval.sh index 24c783f..86bc36c 100644 --- a/firmware_mod/scripts/mqtt-status-interval.sh +++ b/firmware_mod/scripts/mqtt-status-interval.sh @@ -18,6 +18,7 @@ do /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(night_mode status)" /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/night_mode/auto ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(auto_night_mode status)" /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/detection ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(motion_detection status)" + /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/send_mail ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(motion_send_mail status)" /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motion/tracking ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(motion_tracking status)" /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/vertical ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(motor status vertical)" /system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "${TOPIC}"/motors/horizontal ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "$(motor status horizontal)" diff --git a/firmware_mod/www/cgi-bin/state.cgi b/firmware_mod/www/cgi-bin/state.cgi index 074e51e..8965115 100644 --- a/firmware_mod/www/cgi-bin/state.cgi +++ b/firmware_mod/www/cgi-bin/state.cgi @@ -108,6 +108,12 @@ if [ -n "$F_cmd" ]; then fi ;; + hostname) + echo $(hostname); + ;; + version) + echo $(cat /system/sdcard/.lastCommitDate); + ;; *) echo "Unsupported command '$F_cmd'" ;; diff --git a/firmware_mod/www/index.html b/firmware_mod/www/index.html index 8ab4a42..26fa2ef 100644 --- a/firmware_mod/www/index.html +++ b/firmware_mod/www/index.html @@ -3,7 +3,7 @@
-