Add support for sensor: moisture, temperature, fertility, illuminance. Add event ev_not_open_for_moisture, sensor_set_state_before, sensor_set_state_after. Added zone humidity management: when a zone has reached the humidity defined in EVx_SENSOR_MOISTURE it does not start irrigation or interrupts it if it is already active. In case of rain it does not stop irrigation if the soil humidity has not reached the configured value.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
# 0.6.4 - xx/xx/2021
|
||||
- Add support for sensor mi flora
|
||||
- Add support for sensor: moisture, temperature, fertility, illuminance
|
||||
- Add command line: sensor_status, sensor_status_all, sensor_status_set
|
||||
- Add api command: sensor_status_set
|
||||
- Add event ev_not_open_for_moisture, sensor_set_state_before, sensor_set_state_after
|
||||
- Added zone humidity management: when a zone has reached the humidity defined in EVx_SENSOR_MOISTURE it does not start irrigation or interrupts it if it is already active. In case of rain it does not stop irrigation if the soil humidity has not reached the configured value
|
||||
|
||||
# 0.6.3 - 10/08/2021
|
||||
- Add command last_rain_sensor_timestamp, last_rain_online_timestamp, reset_last_rain_sensor_timestamp, reset_last_rain_online_timestamp
|
||||
|
||||
@@ -75,11 +75,32 @@ function check_rain_sensor {
|
||||
}
|
||||
|
||||
#
|
||||
# Chiude tutte le elettrovalvole se sta piovendo
|
||||
# Chiude tutte le elettrovalvole se sta piovendo oppure chiude quelle che hanno raggiunto l'mudità massima impostata
|
||||
# Eseguie il controllo in tempo reale sul sensore hardware e sui dati dell'ultima chiamata eseguita online
|
||||
#
|
||||
function close_all_for_rain {
|
||||
|
||||
#
|
||||
# Chiude le elettrovalvole che hanno raggiunto l'umidità del terreno impostata in EVx_SENSOR_MOISTURE
|
||||
#
|
||||
|
||||
for i in $(seq $EV_TOTAL)
|
||||
do
|
||||
local a=EV"$i"_ALIAS
|
||||
local al=${!a}
|
||||
ev_status $al
|
||||
local state=$?
|
||||
local moisture=$(ev_check_moisture $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"
|
||||
fi
|
||||
done
|
||||
|
||||
#
|
||||
# Chiude le elettrovalvole in caso di pioggia
|
||||
#
|
||||
|
||||
local close_all=0
|
||||
local now=`date +%s`
|
||||
|
||||
@@ -102,6 +123,12 @@ function close_all_for_rain {
|
||||
fi
|
||||
|
||||
if [ "$close_all" = "1" ]; then
|
||||
|
||||
#
|
||||
# PIOVE
|
||||
# Valuta se la sciare aperte le elettrovalvole in caso l'umidità del sensore non sia stata raggiunta
|
||||
#
|
||||
|
||||
for i in $(seq $EV_TOTAL)
|
||||
do
|
||||
local a=EV"$i"_ALIAS
|
||||
@@ -110,14 +137,17 @@ function close_all_for_rain {
|
||||
local evnorain=${!a}
|
||||
ev_status $al
|
||||
local state=$?
|
||||
local moisture=$(ev_check_moisture $i)
|
||||
#echo "$al = $state"
|
||||
if [ "$state" = "1" ] && [ "$evnorain" != "1" ]; then
|
||||
if [ "$state" = "1" ] && [ "$evnorain" != "1" ] && [ "$moisture" -ne 0 ]; then
|
||||
ev_close $al
|
||||
log_write "irrigate" "warning" "close_all_for_rain - Close solenoid '$al' for rain"
|
||||
fi
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
# $3 stato da scrivere
|
||||
#
|
||||
function sensor_set_state {
|
||||
trigger_event "sensor_set_state_before" $1 $2 $3
|
||||
echo "$3" > "$STATUS_DIR/sensor$1_$2"
|
||||
trigger_event "sensor_set_state_after" $1 $2 $3
|
||||
}
|
||||
|
||||
#
|
||||
@@ -155,3 +157,42 @@ function json_sensor_status_all {
|
||||
js="\"sensor\": {$js_item}"
|
||||
echo $js
|
||||
}
|
||||
|
||||
#
|
||||
# Controlla se la zona comandata da un elettrovalvola ha raggiunto l'umidità necessaria per interrompere l'irrigazione
|
||||
# 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
|
||||
#
|
||||
# $1 numero elettrovalvola da controllare
|
||||
#
|
||||
function ev_check_moisture {
|
||||
|
||||
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
|
||||
|
||||
if [ $moisture -gt $max_moisture ]; then
|
||||
log_write "sensor" "info" "humidity of the \"$sa\" sensor reached: $moisture%"
|
||||
echo $moisture
|
||||
return $moisture
|
||||
fi
|
||||
|
||||
echo 0
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
19
piGarden.sh
19
piGarden.sh
@@ -88,13 +88,24 @@ function ev_open {
|
||||
local EV_IS_MONOSTABLE_VAR=EV"$EVNUM"_MONOSTABLE
|
||||
local EV_IS_MONOSTABLE=${!EV_IS_MONOSTABLE_VAR}
|
||||
|
||||
if [ ! "$2" = "force" ] && [ "$EVNORAIN" != "1" ]; then
|
||||
if [ ! "$2" = "force" ]; then
|
||||
|
||||
local moisture=$(ev_check_moisture $EVNUM)
|
||||
if [ $moisture -gt 0 ]; then
|
||||
message_write "warning" "solenoid not open because maximum soil moisture has been reached"
|
||||
trigger_event "ev_not_open_for_moisture" "$1"
|
||||
log_write "irrigate" "warning" "Solenoid '$1' not open because maximum soil moisture has been reached"
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "$EVNORAIN" != "1" ]; then
|
||||
|
||||
if [[ "$NOT_IRRIGATE_IF_RAIN_ONLINE" -gt 0 && -f $STATUS_DIR/last_rain_online ]]; then
|
||||
local last_rain=`cat $STATUS_DIR/last_rain_online`
|
||||
local now=`date +%s`
|
||||
local dif=0
|
||||
let "dif = now - last_rain"
|
||||
if [ $dif -lt $NOT_IRRIGATE_IF_RAIN_ONLINE ]; then
|
||||
if [ $dif -lt $NOT_IRRIGATE_IF_RAIN_ONLINE ] && [ $moisture -ne 0 ]; then
|
||||
message_write "warning" "Solenoid not open for rain"
|
||||
trigger_event "ev_not_open_for_rain_online" "$1"
|
||||
trigger_event "ev_not_open_for_rain" "$1"
|
||||
@@ -104,7 +115,7 @@ function ev_open {
|
||||
fi
|
||||
|
||||
check_rain_sensor
|
||||
if [[ "$NOT_IRRIGATE_IF_RAIN_SENSOR" -gt 0 && -f $STATUS_DIR/last_rain_sensor ]]; then
|
||||
if [[ "$NOT_IRRIGATE_IF_RAIN_SENSOR" -gt 0 && -f $STATUS_DIR/last_rain_sensor && $moisture -ne 0 ]]; then
|
||||
local last_rain=`cat $STATUS_DIR/last_rain_sensor`
|
||||
local now=`date +%s`
|
||||
local dif=0
|
||||
@@ -119,6 +130,8 @@ function ev_open {
|
||||
fi
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
local state=1
|
||||
if [ "$2" = "force" ]; then
|
||||
state=2
|
||||
|
||||
Reference in New Issue
Block a user