From 072ae9c2675675720979dcaf4780a283f49110de Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Mon, 20 Mar 2023 22:31:01 +0200 Subject: [PATCH] add check for ha uri --- files/process_motion_event.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/files/process_motion_event.sh b/files/process_motion_event.sh index 6157b0d..34ef82b 100644 --- a/files/process_motion_event.sh +++ b/files/process_motion_event.sh @@ -239,11 +239,13 @@ if [ -n "${ntfy_server}" ]; then fi fi -message "Sending event to Home Assistant ..." -result=$(curl -s -X POST -H "Authorization: Bearer ${ha_token}" -H "Content-Type: application/json" "${ha_url}/api/events/motion_event" -d "${data}") -return_code=$? -if [ $return_code != 0 ]; then - message "Error ${return_code} sending to Home Assistant '${ha_url}'" +if [ -n "${ha_url}" ]; then + message "Sending event to Home Assistant ..." + result=$(curl -s -X POST -H "Authorization: Bearer ${ha_token}" -H "Content-Type: application/json" "${ha_url}/api/events/motion_event" -d "${data}") + return_code=$? + if [ $return_code != 0 ]; then + message "Error ${return_code} sending to Home Assistant '${ha_url}'" + fi fi if ${remove_picture}; then