From 2fc1c04f3d0763269b607c962e3c750d3dd5b609 Mon Sep 17 00:00:00 2001 From: lejubila Date: Tue, 25 Apr 2017 01:43:18 +0200 Subject: [PATCH] =?UTF-8?q?Corretto=20problema=20che=20faceva=20chiudere?= =?UTF-8?q?=20le=20elttrovalvole=20in=20caso=20di=20pioggia=20anche=20se?= =?UTF-8?q?=20erano=20state=20aperte=20in=20modalit=C3=A0=20'force'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +++ README.md | 4 ++-- piGarden.sh | 26 +++++++++++++++++++++++--- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 512d7ef..02009d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.2.2 - 25/04/2017 +Fix bug: if it's reining, the solenoid valves were also closed even if they were pushed open in "force" mode + ## 0.2.1 - 22/04/2017 Add installation instructions in README.md file diff --git a/README.md b/README.md index 64b90b9..66bf55e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## piGarden +# piGarden Bash script to manage an irrigation system built with a Raspberry Pi @@ -10,7 +10,7 @@ Documentation of piGarden and build system irrigation with Raspberry Pi can be f This script is open-sourced software under GNU GENERAL PUBLIC LICENSE Version 2 -## Installagtion +## Installation 1) Installs the necessary packages on your terminal: diff --git a/piGarden.sh b/piGarden.sh index f6e4cba..7e77fe2 100755 --- a/piGarden.sh +++ b/piGarden.sh @@ -89,10 +89,14 @@ function ev_open { fi fi + local state=1 + if [ "$2" = "force" ]; then + state=2 + fi + log_write "Solenoid '$1' open" message_write "success" "Solenoid open" supply_positive - #gpio_alias2number $1 ev_alias2number $1 EVNUM=$? ev_number2gpio $EVNUM @@ -100,7 +104,7 @@ function ev_open { $GPIO -g write $g $RELE_GPIO_CLOSE sleep 1 $GPIO -g write $g $RELE_GPIO_OPEN - ev_set_state $EVNUM 1 + ev_set_state $EVNUM $state } # @@ -393,7 +397,7 @@ function close_all { ev_status $al local state=$? #echo "$al = $state" - if [[ "$state" = "1" || "$1" = "force" ]]; then + if [[ "$state" -gt "0" || "$1" = "force" ]]; then ev_close $al log_write "close_all - Close solenoid '$al' for rain" fi @@ -932,6 +936,7 @@ function show_usage { echo -e "Usage:" echo -e "\t$NAME_SCRIPT init initialize supply and solenoid in closed state" echo -e "\t$NAME_SCRIPT open alias [force] open a solenoid" + #echo -e "\t$NAME_SCRIPT open_for time alias [force] open a solenoid for specified time (in minute)" echo -e "\t$NAME_SCRIPT close alias close a solenoid" echo -e "\t$NAME_SCRIPT list_alias view list of aliases solenoid" echo -e "\t$NAME_SCRIPT ev_status alias show status solenoid" @@ -1194,10 +1199,25 @@ case "$1" in open) if [ "empty$2" == "empty" ]; then echo -e "Alias solenoid not specified" + exit 1 fi ev_open $2 $3 ;; + open_for) + re='^[0-9]+$' + if ! [[ $2 =~ $re ]] ; then + echo -e "Time of irrigation is wrong or not specified" + exit 1 + fi + + if [ "empty$3" == "empty" ]; then + echo -e "Alias solenoid not specified" + exit 1 + fi + ev_open $3 $4 + ;; + close) if [ "empty$2" == "empty" ]; then echo -e "Alias solenoid not specified"