From 78fa176848cb34c1380caf8527e9fbcbb0bad0d8 Mon Sep 17 00:00:00 2001 From: lejubila Date: Thu, 3 May 2018 11:45:47 +0200 Subject: [PATCH] Implementato eventi events/ev_not_open_for_rain, events/ev_not_open_for_rain_sensor, events/ev_not_open_for_rain_online. Aggiornato script di invio mail notifiche --- events/ev_not_open_for_rain/.gitignore | 4 ++++ events/ev_not_open_for_rain_online/.gitignore | 4 ++++ events/ev_not_open_for_rain_sensor/.gitignore | 4 ++++ events/scripts/sendmail.sh | 7 +++++++ piGarden.sh | 4 ++++ 5 files changed, 23 insertions(+) create mode 100644 events/ev_not_open_for_rain/.gitignore create mode 100644 events/ev_not_open_for_rain_online/.gitignore create mode 100644 events/ev_not_open_for_rain_sensor/.gitignore diff --git a/events/ev_not_open_for_rain/.gitignore b/events/ev_not_open_for_rain/.gitignore new file mode 100644 index 0000000..86d0cb2 --- /dev/null +++ b/events/ev_not_open_for_rain/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file diff --git a/events/ev_not_open_for_rain_online/.gitignore b/events/ev_not_open_for_rain_online/.gitignore new file mode 100644 index 0000000..86d0cb2 --- /dev/null +++ b/events/ev_not_open_for_rain_online/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file diff --git a/events/ev_not_open_for_rain_sensor/.gitignore b/events/ev_not_open_for_rain_sensor/.gitignore new file mode 100644 index 0000000..86d0cb2 --- /dev/null +++ b/events/ev_not_open_for_rain_sensor/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file diff --git a/events/scripts/sendmail.sh b/events/scripts/sendmail.sh index d4e1b6b..53a3519 100755 --- a/events/scripts/sendmail.sh +++ b/events/scripts/sendmail.sh @@ -65,6 +65,13 @@ case "$EVENT" in BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nZONE: $ALIAS\nTIME: $(/bin/date -d@$TIME)" ;; + "ev_not_open_for_rain" | "ev_not_open_for_rain_online" | "ev_not_open_for_rain_sensor") + ALIAS="$2" + FORCE="$3" + TIME=$4 + BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nZONE: $ALIAS\nFORCED IRRIGATION: $FORCE\nTIME: $(/bin/date -d@$TIME)" + ;; + "check_rain_sensor_before" | "check_rain_sensor_after" | "check_rain_sensor_change") STATE="$2" TIME=$3 diff --git a/piGarden.sh b/piGarden.sh index c98bcf2..0a61e0f 100755 --- a/piGarden.sh +++ b/piGarden.sh @@ -93,6 +93,8 @@ function ev_open { local dif=0 let "dif = now - last_rain" if [ $dif -lt $NOT_IRRIGATE_IF_RAIN_ONLINE ]; then + trigger_event "ev_not_open_for_rain_online" "$1" "$2" + trigger_event "ev_not_open_for_rain" "$1" "$2" log_write "Solenoid '$1' not open for rain (online check)" message_write "warning" "Solenoid not open for rain" return @@ -106,6 +108,8 @@ function ev_open { local dif=0 let "dif = now - last_rain" if [ $dif -lt $NOT_IRRIGATE_IF_RAIN_SENSOR ]; then + trigger_event "ev_not_open_for_rain_sensor" "$1" "$2" + trigger_event "ev_not_open_for_rain" "$1" "$2" log_write "Solenoid '$1' not open for rain (sensor check)" message_write "warning" "Solenoid not open for rain" return