diff --git a/files/process_motion_event.sh b/files/process_motion_event.sh index 1f70377..a66ed64 100644 --- a/files/process_motion_event.sh +++ b/files/process_motion_event.sh @@ -3,6 +3,8 @@ #shellcheck disable=SC1091 test -e /var/lib/from_repos/scripts/shared_functions.sh && source /var/lib/from_repos/scripts/shared_functions.sh +remove_picture=false + data="\"date\": \"$(date +%s)\"" while [ $# -gt 0 ] do @@ -147,6 +149,10 @@ do email_destination="${1}" shift ;; + "--remove-picture"|"-r") + shift + remove_picture=true + ;; *) ;; esac @@ -170,4 +176,10 @@ fi message "Sending Home Assistant event ..." result=$(curl -X POST -H "Authorization: Bearer ${ha_token}" -H "Content-Type: application/json" "${ha_url}/api/events/motion_event" -d "${data}") return_code=$? -message "Return code: ${return_code}. Result: ${result}" \ No newline at end of file +message "Return code: ${return_code}. Result: ${result}" + +if ${remove_picture}; then + file_dirname=$(dirname "${file}") + file_dirname_parent=$(dirname "${file_dirname}") + find "${file_dirname_parent}" -type f -name \*.jpg -delete +fi \ No newline at end of file