Add autoclose of the solenoid when the soil moisture has reached the set level
This commit is contained in:
@@ -107,8 +107,9 @@ EV1_ALIAS="1" #
|
||||
EV1_GPIO=17 # Physical 11 - wPi 0
|
||||
#EV1_NORAIN=1 # Non interrompe l'irrigazione di questa zona in caso di pioggia
|
||||
#EV1_MONOSTABLE=1 # L'elettrovalvola è monostabile
|
||||
#EV1_SENSOR_ALIAS=Mi_Flora # Nome del sensore (definito in SENSORx_ALIAS) per stabilire l'umidità del terreno
|
||||
#EV1_SENSOR_MOISTURE=50 # Percentule di umidità ottimale
|
||||
#EV1_SENSOR_ALIAS=Mi_Flora # Nome del sensore (definito in SENSORx_ALIAS) per stabilire l'umidità del terreno
|
||||
#EV1_SENSOR_MOISTURE=50 # Percentule di umidità ottimale
|
||||
#EV1_SENSOR_MOISTURE_AUTOCLOSE=1 # Chiude automaticamente l'elettrovalvola quando supera l'umidità impostata in EVx_MONOSTABLE
|
||||
|
||||
EV2_ALIAS="2" #
|
||||
EV2_GPIO=27 # Physical 13 - wPi 2
|
||||
|
||||
@@ -90,7 +90,7 @@ function close_all_for_rain {
|
||||
local al=${!a}
|
||||
ev_status $al
|
||||
local state=$?
|
||||
local moisture=$(ev_check_moisture $i)
|
||||
local moisture=$(ev_check_moisture_autoclose $i)
|
||||
if [ "$state" = "1" ] && [ "$moisture" -gt 0 ]; then
|
||||
ev_close $al
|
||||
log_write "irrigate" "warning" "close_all_for_rain - Close solenoid '$al' because maximum soil moisture has been reached"
|
||||
|
||||
@@ -159,7 +159,8 @@ function json_sensor_status_all {
|
||||
}
|
||||
|
||||
#
|
||||
# Controlla se la zona comandata da un elettrovalvola ha raggiunto l'umidità necessaria per interrompere l'irrigazione
|
||||
# Controlla se la zona comandata da un elettrovalvola ha raggiunto l'umidità necessaria per non fare partire l'irrigazione,
|
||||
# faerla chiudere in caso di pioggia.
|
||||
# Se è stata superata l'umidità indicata in EVx_SENSOR_MOISTURE ritorna l'umidità attuale del sensore relativo all'elettrovalvola
|
||||
# in caso contrario ritorna 0, se no è impostato il parametro EV_xSENSOR_ALIAS o EVxSENSOR?MOISTURE ritorna il valore -1
|
||||
#
|
||||
@@ -186,7 +187,58 @@ function ev_check_moisture {
|
||||
fi
|
||||
|
||||
if [ $moisture -gt $max_moisture ]; then
|
||||
log_write "sensor" "info" "humidity of the \"$sa\" sensor reached: $moisture%"
|
||||
log_write "sensor" "info" "ev_check_moisture_autoclose: humidity of the \"$sa\" sensor reached: $moisture%"
|
||||
echo $moisture
|
||||
return $moisture
|
||||
fi
|
||||
|
||||
echo 0
|
||||
return 0
|
||||
}
|
||||
|
||||
#
|
||||
# Controlla se la zona comandata da un elettrovalvola ha raggiunto l'umidità necessaria per essere chiusa in automatico
|
||||
# Se è stata superata l'umidità indicata in EVx_SENSOR_MOISTURE ritorna l'umidità attuale del sensore relativo all'elettrovalvola
|
||||
# in caso contrario ritorna 0, se no è impostato il parametro EV_xSENSOR_ALIAS, EVxSENSOR_MOISTURE o
|
||||
# EVxSENSOR_MOISTURE_AUTOCLOSE ritorna il valore -1
|
||||
#
|
||||
# $1 numero elettrovalvola da controllare
|
||||
#
|
||||
function ev_check_moisture_autoclose {
|
||||
|
||||
local s=EV"$1"_SENSOR_ALIAS
|
||||
local sa=${!s}
|
||||
|
||||
if [[ -z $sa ]]; then
|
||||
echo -1
|
||||
return
|
||||
fi
|
||||
|
||||
local moisture=$(sensor_status $sa moisture)
|
||||
|
||||
local s=EV"$1"_SENSOR_MOISTURE
|
||||
local max_moisture=${!s}
|
||||
|
||||
if [ -z $max_moisture ]; then
|
||||
echo -1
|
||||
return
|
||||
fi
|
||||
|
||||
local s=EV"$1"_SENSOR_MOISTURE_AUTOCLOSE
|
||||
local autoclose=${!s}
|
||||
|
||||
if [ -z $autoclose ]; then
|
||||
echo -1
|
||||
return
|
||||
fi
|
||||
|
||||
if [ $autoclose -ne 1 ]; then
|
||||
echo -1
|
||||
return
|
||||
fi
|
||||
|
||||
if [ $moisture -gt $max_moisture ]; then
|
||||
log_write "sensor" "info" "ev_check_moisture_autoclose: humidity of the \"$sa\" sensor reached: $moisture%"
|
||||
echo $moisture
|
||||
return $moisture
|
||||
fi
|
||||
|
||||
@@ -256,7 +256,7 @@ function socket_server_command {
|
||||
if [ "empty$arg2" == "empty" ]; then
|
||||
json_error 0 "Alias sensor not specified"
|
||||
else
|
||||
sensor_status_set $arg2 $arg3 &> /dev/null
|
||||
sensor_status_set $arg2 $arg3 $arg4 &> /dev/null
|
||||
json_status
|
||||
fi
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user