diff --git a/events/scripts/sendmail.sh b/events/scripts/sendmail.sh index a7eb757..025115a 100755 --- a/events/scripts/sendmail.sh +++ b/events/scripts/sendmail.sh @@ -21,11 +21,49 @@ # EVENT="$1" -CAUSE="$2" -TIME=$3 TO="mail@destination.com" -FROM="piGuardian@your_domain.com" -SUBJECT="piGuardian notification mail: $EVENT" +FROM="piGarden@your_domain.com" +SUBJECT="piGarden notification mail: event $EVENT" +BODY="" + +case "$EVENT" in + "init_before" | "init_after") + STATE="$2" + TIME=$3 + BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nTIME: $(/bin/date -d@$TIME)" + ;; + + "ev_open_before" | "ev_open_after") + ALIAS="$2" + FORCE="$3" + TIME=$4 + BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nZONE: $ALIAS\nFORCED IRRIGATION: $FORCE\nTIME: $(/bin/date -d@$TIME)" + ;; + + "ev_close_before" | "ev_close_after") + ALIAS="$2" + TIME=$3 + BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nZONE: $ALIAS\nTIME: $(/bin/date -d@$TIME)" + ;; + + "check_rain_sensor_before" | "check_rain_sensor_after" | "check_rain_sensor_change") + STATE="$2" + TIME=$3 + BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nSTATE: $ALIAS\nTIME: $(/bin/date -d@$TIME)" + ;; + + "check_rain_online_before" | "check_rain_online_after" | "check_rain_online_change") + STATE="$2" + TIME=$3 + BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nSTATE: $ALIAS\nTIME: $(/bin/date -d@$TIME)" + ;; + + *) + exit + ;; + +esac + +echo -e "$BODY" | /usr/bin/mail -s "$SUBJECT" $TO -r $FROM & -echo -e "PiGuardian triggered new event\n\nEVENT: $EVENT\nCAUSE: $CAUSE\nTIME: $(/bin/date -d@$TIME)" | /usr/bin/mail -s "$SUBJECT" $TO -r $FROM -A /home/pi/piGuardian/log/piGuardian.log diff --git a/events/scripts/sendtelegram.sh b/events/scripts/sendtelegram.sh deleted file mode 100755 index 4328a27..0000000 --- a/events/scripts/sendtelegram.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# Send mail on triggered event -# -# $1 = event -# $2 = cause -# $3 = time -# -# To send an email with this script you must install telegram-cli @see http://tuxmaniacs.it/2015/01/installare-telegram-sul-raspberry-pi.html -# - -EVENT="$1" -CAUSE="$2" -TIME=$3 - -TG_CLI="/home/pi/tg/bin/telegram-cli" - -TO="Your_Destination_Contact" - -CMD="msg $TO \"piGuardian triggered new event\\n\\nEVENT: $EVENT\\nCAUSE: $CAUSE\\nTIME: $(/bin/date -d@$TIME)\"" -(sleep 1; echo "contact_list"; sleep 1; echo $CMD) | $TG_CLI -W diff --git a/piGarden.sh b/piGarden.sh index c5ccb8b..ecc11f9 100755 --- a/piGarden.sh +++ b/piGarden.sh @@ -801,7 +801,7 @@ fi . "$DIR_SCRIPT/include/events.include.sh" LAST_INFO_FILE="$STATUS_DIR/last_info" -LAST_WARNING_FILE="$STATUS_DIR/last_worning" +LAST_WARNING_FILE="$STATUS_DIR/last_warning" LAST_SUCCESS_FILE="$STATUS_DIR/last_success" if [ -z $LOG_OUTPUT_DRV_FILE ]; then