Corretto problema che faceva chiudere le elttrovalvole in caso di pioggia anche se erano state aperte in modalità 'force'

This commit is contained in:
lejubila
2017-04-25 01:43:18 +02:00
parent ff608dc8d9
commit 2fc1c04f3d
3 changed files with 28 additions and 5 deletions

View File

@@ -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

View File

@@ -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:

View File

@@ -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"