Teriminato debug gestione eventi, creato script sendmail.sh per l'invio di una mail allo scatenarsi du un evento
This commit is contained in:
@@ -21,11 +21,49 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
EVENT="$1"
|
EVENT="$1"
|
||||||
CAUSE="$2"
|
|
||||||
TIME=$3
|
|
||||||
|
|
||||||
TO="mail@destination.com"
|
TO="mail@destination.com"
|
||||||
FROM="piGuardian@your_domain.com"
|
FROM="piGarden@your_domain.com"
|
||||||
SUBJECT="piGuardian notification mail: $EVENT"
|
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
|
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -801,7 +801,7 @@ fi
|
|||||||
. "$DIR_SCRIPT/include/events.include.sh"
|
. "$DIR_SCRIPT/include/events.include.sh"
|
||||||
|
|
||||||
LAST_INFO_FILE="$STATUS_DIR/last_info"
|
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"
|
LAST_SUCCESS_FILE="$STATUS_DIR/last_success"
|
||||||
|
|
||||||
if [ -z $LOG_OUTPUT_DRV_FILE ]; then
|
if [ -z $LOG_OUTPUT_DRV_FILE ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user