15 Commits

Author SHA1 Message Date
lejubila
3239006922 Modificato file README dei driver, variato numero di versione di piGarden 2018-06-01 22:16:26 +02:00
lejubila
24baa97dad Corretto nome di funzione nel driver sonoff_tasmota_http 2018-05-24 22:06:12 +02:00
lejubila
c354f72c0c Eseguito correzioni su driver sonoff_tasmota_http 2018-05-23 17:57:24 +02:00
lejubila
6f80b8ea21 Corretto problema parsing json su driver sonoff_tasmota_http 2018-05-22 12:53:57 +02:00
lejubila
87edbbbe7a Eseguito correzioni su driver sonoff_tasmota_http 2018-05-21 22:21:27 +02:00
lejubila
3eb45fd1e9 Aggiunto prima implementazione del driver sonoff_tesmota_http, aggiunto implementazione parametro EVx_MONOSTABLE per potere definire singolarmente le elettrovamvole monostabili, corretto alcuni commenti 2018-05-20 17:14:58 +02:00
lejubila
7c96a6afd1 Modificato output di notifiche eventi dello script rpinotify.sh, aggiornato CHANGELOG per nuova versione 2018-05-04 21:17:32 +02:00
lejubila
c664bea16a corretto timestamp su eventi ev_not_open_for_rain, ev_not_open_for_rain_online, ev_not_open_for_rain_sensor 2018-05-03 12:02:48 +02:00
lejubila
78fa176848 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 2018-05-03 11:45:47 +02:00
lejubila
5c00853e39 Aggiunto driver 'remote' per gestire da un'installazione master di piGarden più installazioni remote 2018-03-25 12:32:39 +02:00
lejubila
dd3cab12c2 Aggiornaeto numero di release 2017-12-13 15:47:06 +01:00
lejubila
38ecd92d7a Corretto problema di inizializzazione variabile LOG_OUTPUT_DRV_FILE 2017-12-13 15:43:06 +01:00
lejubila
22ec16cc9d Aggunto eventi cron_add_before, cron_add_after, cron_del_before, cron_del_after, ev_open_in_before, ev_open_in_after, exec_poweroff_before, exec_poweroff_after, exec_reboot_before, exec_reboot_after ed eseguito bugfix vari 2017-11-19 23:24:48 +01:00
lejubila
8d4849db75 Merge branch 'master' into develop 2017-11-01 18:10:41 +01:00
lejubila
80bcbbc92a corretto parametri in sendmail.sh 2017-11-01 18:03:52 +01:00
42 changed files with 1080 additions and 50 deletions

View File

@@ -1,3 +1,24 @@
# 0.5.7 - 01/06/2018
- Added "sonoff_tasmota_http" driver for interfacin with Sonoff module with Tasmota firmware over http protocol
# 0.5.6 - 04/05/2018
- Added events ev_not_open_for_rain, ev_not_open_for_rain_sensor, ev_not_open_for_rain_online
- Added script rpinotify.sh for notificate events to telegram
# 0.5.5 - 25/03/2018
- Added "remote" driver to control remote pigarden
# 0.5.4 - 13/11/2017
- Fix bad initialization LOG_OUTPUT_DRV_FILE variable if not defined in config file
# 0.5.3 - 19/11/2017
- Fix send parameter on event init_before and init_after
- Added WEATHER argument in check_rain_sensor_after and check_rain_sensor_change event
- Added events cron_add_before, cron_add_after, cron_del_before, cron_del_after, ev_open_in_before, ev_open_in_after, exec_poweroff_before, exec_poweroff_after, exec_reboot_before, exec_reboot_after
- Added to sendmail.sh argument passed form check_rain_sensor_after and check_rain_sensor_change event
- Added to sendmail.sh new events
- Fix wrong state on event script sendmail.sh
# 0.5.2 - 01/11/2017
- Fix problem inconsistent return value in drv_rain_sensor_get
- Fix get parameter in event script sendmail.sh

View File

@@ -4,7 +4,7 @@ Bash script to manage an irrigation system built with a Raspberry Pi
## Official documentation
Documentation of piGarden and build system irrigation with Raspberry Pi can be found on the [www.lejubila.net/tag/pigarden/](http://www.lejubila.net/tag/pigarden/)
Documentation of piGarden and build system irrigation with Raspberry Pi can be found on the [www.lejubila.net/pigarden/](http://www.lejubila.net/pigarden/)
## License
@@ -66,5 +66,3 @@ sudo cp piGarden/conf/piGarden.conf.example /etc/piGarden.conf
Customize the configuration file.
For more information see
[www.lejubila.net/2015/12/impianto-di-irrigazione-con-raspberry-pi-pigarden-lo-script-di-gestione-quinta-parte/](https://www.lejubila.net/2015/12/impianto-di-irrigazione-con-raspberry-pi-pigarden-lo-script-di-gestione-quinta-parte/)
and
[www.lejubila.net/2017/04/pigarden-0-2-easter-egg/](https://www.lejubila.net/2017/04/pigarden-0-2-easter-egg/)

View File

@@ -90,6 +90,7 @@ EV_TOTAL=6
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_MONOSTAVLE=1 # L'elettrovalvola è monostabile
EV2_ALIAS="2" #
EV2_GPIO=27 # Physical 13 - wPi 2

View File

@@ -0,0 +1,142 @@
# Log file
LOG_FILE="/home/pi/piGarden/log/piGarden.log"
LOG_FILE_MAX_SIZE=1048576 # 1MB
# Log file for driver output
#LOG_OUTPUT_DRV_FILE="/tmp/piGarden.drv.log"
# Status directory
STATUS_DIR="/home/pi/piGarden/state"
# Event directory
EVENT_DIR="/home/pi/piGarden/events"
# Posizione gpio
GPIO="/usr/local/bin/gpio"
# Posizione js
JQ="/usr/local/bin/jq"
# Percorso curl
CURL="/usr/bin/curl"
# Percorso wc
WC="/usr/bin/wc"
# Percorso gzip
GZIP="/bin/gzip"
# Percorso mv
MV="/bin/mv"
# Percorso di tr
TR="/usr/bin/tr"
# Percorso di cut
CUT="/usr/bin/cut"
# Percorso tcpserver
TCPSERVER="/usr/bin/tcpserver"
# Percorso cron
CRONTAB="/usr/bin/crontab"
# Percorso grep
GREP="/bin/grep"
# Percorsp sed
SED="/bin/sed"
# Percorso readlink
READLINK="/bin/readlink"
# Percorso stat
STAT="/usr/bin/stat"
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili
EV_MONOSTABLE=0
# Id gpio usati per simulare il doppio deviatore con cui eseguire l'alimentazione alle elettrovalvole
SUPPLY_GPIO_1=2
SUPPLY_GPIO_2=3
# Stato dei due gpio per impartire l'alimentazione positiva alle elettrovalvole (aperta)
SUPPLY_GPIO_POS=0
# Stato dei due gpio per impartire l'alimentazione negativa alle elettrovalvole (chiusa)
SUPPLY_GPIO_NEG=1
# Stato di ingresso da assegnare al gpio per chiudere il rele
RELE_GPIO_CLOSE=0
# Stato di ingresso da assegnare al gpio per aprire il rele
RELE_GPIO_OPEN=1
# Id del gpio usato per collegare il sensore di rilevamento pioggia
RAIN_GPIO=25 # Physical 22 - wPi 6
# Valore in ingresso sul gpio definito in RAIN_GPIO che indica lo stato di pioggia
RAIN_GPIO_STATE=0
# Numero totale di elettrovalvole
EV_TOTAL=4
# Definizione delle elettrovalvole
EV1_ALIAS="Giardino_Posteriore_DX" #
EV1_GPIO="drv:remote:PIREMOTE1:Giardino_Posteriore_DX"
#EV1_NORAIN=1 # Non interrompe l'irrigazione di questa zona in caso di pioggia
EV2_ALIAS="Giardino_Posteriore_CN" #
EV2_GPIO="drv:remote:PIREMOTE2:Giardino_Posteriore_CN"
EV3_ALIAS="Giardino_Posteriore_SX" #
EV3_GPIO="drv:remote:PIREMOTE2:Giardino_Posteriore_SX"
EV4_ALIAS="Giardino_Posteriore_GPIO" #
EV4_GPIO="18"
# Definisce l'api key e il luogo per recuperare lo stato meteo online
WUNDERGROUND_KEY=""
WUNDERGROUND_LOCATION="IT/Pieve%20a%20Nievole" # http://www.wunderground.com/weather/api/d/docs?d=resources/country-to-iso-matching&MR=1
# Blocca l'irrigazione se l'ultima pioggia rilevata online è avvenuta nell'ultima quantità di tempo inserita.
# Il tempo è espresso in secondi. Quindi inserendo 86400, se nelle ultime 24 ore ha piovuto viene bloccata l'irrigazione. Inserendo il valore zero non viene eseguito nessun controllo.
NOT_IRRIGATE_IF_RAIN_ONLINE=86400
# Il parametro è simile a quello precedente, il controllo però anziché essere fatto attingendo a wunderground, viene eseguito direttamente sul sensore se installato. Inserendo il valore zero non viene eseguito nessun controllo.
NOT_IRRIGATE_IF_RAIN_SENSOR=86400
# Indirizzo ip e porta di ascolto del socket server
TCPSERVER_IP="127.0.0.1"
TCPSERVER_PORT="8084"
# Utente e password che i clients devono utilizzare per stabilire una connessione tramite socket server
TCPSERVER_USER=""
TCPSERVER_PWD=""
# Con impostato il valore 1 non invia l'identificativi per statistiche di utilizzo
NO_SEND_IDENTIFIER=0
#
# Configurazione piGarden remoti
#
PIREMOTE1_IP="192.168.1.51"
PIREMOTE1_PORT="8084"
PIREMOTE1_USER=""
PIREMOTE1_PWD=""
PIREMOTE2_IP="192.168.1.52"
PIREMOTE2_PORT="8084"
PIREMOTE2_USER=""
PIREMOTE2_PWD=""

View File

@@ -0,0 +1,141 @@
# Log file
LOG_FILE="/home/pi/piGarden/log/piGarden.log"
LOG_FILE_MAX_SIZE=1048576 # 1MB
# Log file for driver output
#LOG_OUTPUT_DRV_FILE="/tmp/piGarden.drv.log"
# Status directory
STATUS_DIR="/home/pi/piGarden/state"
# Event directory
EVENT_DIR="/home/pi/piGarden/events"
# Posizione gpio
GPIO="/usr/local/bin/gpio"
# Posizione js
JQ="/usr/local/bin/jq"
# Percorso curl
CURL="/usr/bin/curl"
# Percorso wc
WC="/usr/bin/wc"
# Percorso gzip
GZIP="/bin/gzip"
# Percorso mv
MV="/bin/mv"
# Percorso di tr
TR="/usr/bin/tr"
# Percorso di cut
CUT="/usr/bin/cut"
# Percorso tcpserver
TCPSERVER="/usr/bin/tcpserver"
# Percorso cron
CRONTAB="/usr/bin/crontab"
# Percorso grep
GREP="/bin/grep"
# Percorsp sed
SED="/bin/sed"
# Percorso readlink
READLINK="/bin/readlink"
# Percorso stat
STAT="/usr/bin/stat"
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili
EV_MONOSTABLE=0
# Id gpio usati per simulare il doppio deviatore con cui eseguire l'alimentazione alle elettrovalvole
SUPPLY_GPIO_1=2
SUPPLY_GPIO_2=3
# Stato dei due gpio per impartire l'alimentazione positiva alle elettrovalvole (aperta)
SUPPLY_GPIO_POS=0
# Stato dei due gpio per impartire l'alimentazione negativa alle elettrovalvole (chiusa)
SUPPLY_GPIO_NEG=1
# Stato di ingresso da assegnare al gpio per chiudere il rele
RELE_GPIO_CLOSE=0
# Stato di ingresso da assegnare al gpio per aprire il rele
RELE_GPIO_OPEN=1
# Id del gpio usato per collegare il sensore di rilevamento pioggia
RAIN_GPIO=25 # Physical 22 - wPi 6
# Valore in ingresso sul gpio definito in RAIN_GPIO che indica lo stato di pioggia
RAIN_GPIO_STATE=0
# Numero totale di elettrovalvole
EV_TOTAL=4
# Definizione delle elettrovalvole
EV1_ALIAS="Giardino_Posteriore_DX"
EV1_GPIO="drv:sonoff_tasmota_http:SONOFF1:Power1"
EV1_MONOSTABLE=1
EV2_ALIAS="Giardino_Posteriore_CN"
EV2_GPIO="drv:sonoff_tasmota_http:SONOFF1:Power2"
EV2_MONOSTABLE=1
EV3_ALIAS="Giardino_Posteriore_SX"
EV3_GPIO="drv:sonoff_tasmota_http:SONOFF1:Power3"
EV3_MONOSTABLE=1
EV4_ALIAS="Giardino_Anteriore"
EV4_GPIO="drv:sonoff_tasmota_http:SONOFF2:Power1"
# Definisce l'api key e il luogo per recuperare lo stato meteo online
WUNDERGROUND_KEY=""
WUNDERGROUND_LOCATION="IT/Pieve%20a%20Nievole" # http://www.wunderground.com/weather/api/d/docs?d=resources/country-to-iso-matching&MR=1
# Blocca l'irrigazione se l'ultima pioggia rilevata online è avvenuta nell'ultima quantità di tempo inserita.
# Il tempo è espresso in secondi. Quindi inserendo 86400, se nelle ultime 24 ore ha piovuto viene bloccata l'irrigazione. Inserendo il valore zero non viene eseguito nessun controllo.
NOT_IRRIGATE_IF_RAIN_ONLINE=86400
# Il parametro è simile a quello precedente, il controllo però anziché essere fatto attingendo a wunderground, viene eseguito direttamente sul sensore se installato. Inserendo il valore zero non viene eseguito nessun controllo.
NOT_IRRIGATE_IF_RAIN_SENSOR=86400
# Indirizzo ip e porta di ascolto del socket server
TCPSERVER_IP="127.0.0.1"
TCPSERVER_PORT="8084"
# Utente e password che i clients devono utilizzare per stabilire una connessione tramite socket server
TCPSERVER_USER=""
TCPSERVER_PWD=""
# Con impostato il valore 1 non invia l'identificativi per statistiche di utilizzo
NO_SEND_IDENTIFIER=0
#
# Configurazione moduli sonoff
#
SONOFF1_IP="192.168.1.1"
SONOFF1_USER="user"
SONOFF1_PWD="pwd"
SONOFF2_IP="192.168.1.21"
SONOFF2_USER=""
SONOFF2_PWD=""

13
drv/remote/README.md Normal file
View File

@@ -0,0 +1,13 @@
# Driver for controlling remote pigarden on the network from a pigarden master installation
For more information see https://www.lejubila.net/2018/03/pigardent-0-5-5-driver-master-per-implementare-un-architettura-master-slave/
# Example of zone configuration in piGarden.conf
EV1_ALIAS="Giarino_Posteriore_DX" #
EV1_GPIO="drv:remote:PIREMOTE1:Giardino_Posteriore_DX"
PIREMOTE1_IP="192.168.1.51"
PIREMOTE1_PORT="8084"
PIREMOTE1_USER=""
PIREMOTE1_PWD=""

View File

@@ -0,0 +1,38 @@
#
# Funzioni comuni utilizzate dal driver
#
#
# Esegue un comando su un pigarden remoto tramite socket
#
# $1 identificativo pigarden remoto
# $2 comando da eseguire
#
function drv_remote_command {
local remote="$1"
local command="$2"
local remote_ip_var=$remote"_IP"
local remote_port_var=$remote"_PORT"
local remote_user_var=$remote"_USER"
local remote_pwd_var=$remote"_PWD"
local remote_ip="${!remote_ip_var}"
local remote_port="${!remote_port_var}"
local remote_user="${!remote_user_var}"
local remote_pwd="${!remote_pwd_var}"
exec 5<>/dev/tcp/$remote_ip/$remote_port
if [[ ! -z $remote_user ]] && [[ ! -z $remote_pwd ]]; then
command="$remote_user\n$remote_pwd\n$command"
fi
echo -e "$command" >&5
cat <&5
}

View File

@@ -0,0 +1,7 @@
#
# File di configurazione del driver
#
# Dichiarazione variabile di esempio
#declare -g SAMPLE_FOO
#SAMPLE_FOO="bar"

View File

@@ -0,0 +1,9 @@
#
# Questa funzione viene inviocata dalla funzione "init" di piGarden se sono presenti elettrovalvole o sensori che utilizzano questo driver
#
function drv_remote_init {
local FOO=bar
}

View File

@@ -0,0 +1,23 @@
#
# Inizializza il sensore di rilevamento pioggia
#
# $i identificativo gpio del sensore di pioggia
#
function drv_remote_rain_sensor_init {
local FOO="bar"
}
#
# Ritorna lo stato del sensore di rilevamento pioggia
#
# $i identificativo gpio del sensore di pioggia
#
function drv_remote_rain_sensor_get {
local FOO="bar"
}

View File

@@ -0,0 +1,76 @@
#
# Inizializzazione rele
#
# $1 identificativo relè da inizializzare
#
function drv_remote_rele_init {
drv_remote_rele_open "$1"
}
#
# Apertura rele
#
# $1 identificativo relè da aprire (chiude l'elettrovalvola)
#
function drv_remote_rele_open {
local remote=`echo $1 | $CUT -d':' -f3,3`
local remote_alias=`echo $1 | $CUT -d':' -f4,4`
local command="close $remote_alias"
echo "remote=$remote"
echo "remote_alias=$remote_alias"
echo "command=$command"
local response=$(drv_remote_command "$remote" "$command")
echo "response=$response"
local result=$(echo $response|$JQ -M ".error.description")
echo "result=$result"
if [[ "$result" != "\"\"" ]]; then
local error=$result
error="${error%\"}"
error="${error#\"}"
echo "error=$error"
log_write "Remote rele open error: $error"
message_write "warning" "Remote rele open error: $error"
return 1
fi
}
#
# Chiusura rele
#
# $1 identificativo relè da chiudere (apre l'elettrovalvola)
#
function drv_remote_rele_close {
local remote=`echo $1 | $CUT -d':' -f3,3`
local remote_alias=`echo $1 | $CUT -d':' -f4,4`
local command="open $remote_alias force"
echo "remote=$remote"
echo "remote_alias=$remote_alias"
echo "command=$command"
local response=$(drv_remote_command "$remote" "$command")
echo "response=$response"
local result=`echo $response|$JQ -M ".error.description"`
echo "result=$result"
if [[ "$result" != "\"\"" ]]; then
local error=$result
error="${error%\"}"
error="${error#\"}"
echo "error=$error"
log_write "Remote rele close error: $error"
message_write "warning" "Remote rele close error: $error"
return 1
fi
}

View File

@@ -0,0 +1,27 @@
#
# Questa funzione viene invocata dalla funzione "setup_drv" di piGarden ad ogni avvio dello script
# e serve per eseguire l'eventuale setup del driver se necessario
#
function drv_remote_setup {
local all_remote=0
# Imposta le zone come remote
for i in $(seq $EV_TOTAL)
do
local a=EV"$i"_GPIO
local gpio="${!a}"
if [[ "$gpio" == drv:remote:* ]]; then
local varname=EV"$i"_REMOTE
declare -g $varname=1
all_remote=$((all_remote+1))
fi
done
# Se tutte le zone sono remote disabilita la gestione dell'alimentazione bistabile
if [ $all_remote -eq $EV_TOTAL ]; then
EV_MONOSTABLE=1
fi
}

View File

@@ -0,0 +1,34 @@
#
# Inizializza i rele che gestiscono l'alimentazione per le valvole bistabili
#
# $1 identificativo relè
#
function drv_remote_supply_bistable_init {
local FOO="bar"
}
#
# Imposta l'alimentazione delle elettrovalvole con voltaggio positivo
#
# $1 identificativo relè
#
function drv_remote_supply_positive {
local FOO="bar"
}
#
# Imposta l'alimentazione delle elettrovalvole con voltaggio negativo
#
# $1 identificativo relè
#
function drv_remote_supply_negative {
local FOO="bar"
}

View File

@@ -1,6 +1,6 @@
#
# Questa funzione viene invocata dalla funzione "setup_drv" di piGarden ad ogni avvio dello script
# e serve per eseguire l'evenutale setup del driver se necessario
# e serve per eseguire l'eventuale setup del driver se necessario
#
function drv_sample_setup {

View File

@@ -0,0 +1,21 @@
# Driver for controlling Sonoff remote relays with Tasmota firmware via http protocol
More information on Sonoff Tasmota firmware: https://github.com/arendst/Sonoff-Tasmota
# Example of zone configuration in piGarden.conf
EV1_ALIAS="Giardino_Posteriore_DX"
EV1_GPIO="drv:sonoff_tasmota_http:SONOFF1:Power1"
EV1_MONOSTABLE=1
EV2_ALIAS="Giardino_Posteriore_CN"
EV2_GPIO="drv:sonoff_tasmota_http:SONOFF1:Power2"
EV2_MONOSTABLE=1
SONOFF1_IP="192.168.1.1"
SONOFF1_USER="user"
SONOFF1_PWD="pwd"
More information for configuration: https://www.lejubila.net/2018/06/pigarden-0-5-7-gestisci-le-tue-elettrovalvole-con-i-moduli-sonoff-grazie-al-nuovo-driver-sonoff_tasmota_http

View File

@@ -0,0 +1,50 @@
#
# Funzioni comuni utilizzate dal driver
#
#
# Invia un comando al modulo sonoff tramite http
#
# $1 identificativo modulo sonoff
# $2 comando da eseguire
#
function drv_sonoff_tasmota_http_command {
local remote="$1"
local command="$2"
local remote_ip_var=$remote"_IP"
local remote_user_var=$remote"_USER"
local remote_pwd_var=$remote"_PWD"
local remote_ip="${!remote_ip_var}"
local remote_user="${!remote_user_var}"
local remote_pwd="${!remote_pwd_var}"
local url="http://$remote_ip/cm"
local credentials=""
local response=""
if [[ ! -z $remote_user ]] && [[ ! -z $remote_pwd ]]; then
credentials="user=$remote_user&password=$remote_pwd&"
fi
url="$url?$credentials$command"
echo "url api sonoff: $url" >> "$LOG_OUTPUT_DRV_FILE"
$CURL --connect-timeout 5 -sb -H "$url"
local res=$?
echo "curl code response: $res" >> "$LOG_OUTPUT_DRV_FILE"
if [ "$res" != "0" ]; then
echo "The curl command failed with: $res - url: $url"
fi
#echo "{\"POWER1\":\"ON\"}"
}

View File

@@ -0,0 +1,7 @@
#
# File di configurazione del driver
#
# Dichiarazione variabile di esempio
#declare -g SAMPLE_FOO
#SAMPLE_FOO="bar"

View File

@@ -0,0 +1,9 @@
#
# Questa funzione viene inviocata dalla funzione "init" di piGarden se sono presenti elettrovalvole o sensori che utilizzano questo driver
#
function drv_sonoff_tasmota_http_init {
local FOO=bar
}

View File

@@ -0,0 +1,23 @@
#
# Inizializza il sensore di rilevamento pioggia
#
# $i identificativo gpio del sensore di pioggia
#
function drv_sonoff_tasmota_http_rain_sensor_init {
local FOO="bar"
}
#
# Ritorna lo stato del sensore di rilevamento pioggia
#
# $i identificativo gpio del sensore di pioggia
#
function drv_sonoff_tasmota_http_rain_sensor_get {
local FOO="bar"
}

View File

@@ -0,0 +1,78 @@
#
# Inizializzazione rele
#
# $1 identificativo relè da inizializzare
#
function drv_sonoff_tasmota_http_rele_init {
drv_sonoff_tasmota_http_rele_open "$1"
}
#
# Apertura rele
#
# $1 identificativo relè da aprire (chiude l'elettrovalvola)
#
function drv_sonoff_tasmota_http_rele_open {
local remote=`echo $1 | $CUT -d':' -f3,3`
local remote_alias=`echo $1 | $CUT -d':' -f4,4`
local command="cmnd=$remote_alias%20Off"
echo "remote=$remote"
echo "remote_alias=$remote_alias"
echo "command=$command"
local response=$(drv_sonoff_tasmota_http_command "$remote" "$command")
echo "response=$response"
local jskey=${remote_alias^^}
local result=$(echo $response|$JQ -M ".$jskey")
echo "result=$result"
if [[ "$result" != "\"OFF\"" ]]; then
local error="Command error: $response"
error="${error%\"}"
error="${error#\"}"
echo "error=$error"
log_write "Remote rele open error: $error"
message_write "warning" "Remote rele open error: $error"
return 1
fi
}
#
# Chiusura rele
#
# $1 identificativo relè da chiudere (apre l'elettrovalvola)
#
function drv_sonoff_tasmota_http_rele_close {
local remote=`echo $1 | $CUT -d':' -f3,3`
local remote_alias=`echo $1 | $CUT -d':' -f4,4`
local command="cmnd=$remote_alias%20On"
echo "remote=$remote"
echo "remote_alias=$remote_alias"
echo "command=$command"
local response=$(drv_sonoff_tasmota_http_command "$remote" "$command")
echo "response=$response"
local jskey=${remote_alias^^}
local result=$(echo $response|$JQ -M ".$jskey")
echo "result=$result"
if [[ "$result" != "\"ON\"" ]]; then
local error="Command error: $response"
error="${error%\"}"
error="${error#\"}"
echo "error=$error"
log_write "Remote rele close error: $error"
message_write "warning" "Remote rele close error: $error"
return 1
fi
}

View File

@@ -0,0 +1,10 @@
#
# Questa funzione viene invocata dalla funzione "setup_drv" di piGarden ad ogni avvio dello script
# e serve per eseguire l'eventuale setup del driver se necessario
#
function drv_sonoff_tasmota_http_setup {
local FOO="bar"
}

View File

@@ -0,0 +1,34 @@
#
# Inizializza i rele che gestiscono l'alimentazione per le valvole bistabili
#
# $1 identificativo relè
#
function drv_sonoff_tasmota_http_supply_bistable_init {
drv_sonoff_tasmota_http_supply_negative "$1"
}
#
# Imposta l'alimentazione delle elettrovalvole con voltaggio positivo
#
# $1 identificativo relè
#
function drv_sonoff_tasmota_http_supply_positive {
drv_sonoff_tasmota_http_rele_open "$1"
}
#
# Imposta l'alimentazione delle elettrovalvole con voltaggio negativo
#
# $1 identificativo relè
#
function drv_sonoff_tasmota_http_supply_negative {
drv_sonoff_tasmota_http_rele_close "$1"
}

4
events/cron_add_after/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/cron_add_before/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/cron_del_after/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/cron_del_before/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/ev_open_in_after/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/ev_open_in_before/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/exec_poweroff_after/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/exec_reboot_after/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

4
events/exec_reboot_before/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

111
events/scripts/rpinotify.sh Executable file
View File

@@ -0,0 +1,111 @@
#!/bin/bash
#
# Send telegram notificacion on triggered event
#
# $1 = event
# $2 = cause
# $3 = time
#
# To use this script, you must get your hash. Register for the rpinotify service. Get the hash and enter it below
#
# rpinotify token
TOKEN=""
EVENT="$1"
TO="mail@destination.com"
FROM="piGarden@your_domain.com"
SUBJECT="[piGarden notification mail] event $EVENT"
BODY=""
case "$EVENT" in
"init_before" | "init_after")
TIME=$2
BODY="PiGarden triggered new event --- EVENT: $EVENT --- TIME: $(/bin/date -d@$TIME)"
;;
"ev_open_before" | "ev_open_after")
ALIAS="$2"
FORCE="$3"
TIME=$4
BODY="PiGarden triggered new event --- EVENT: $EVENT --- ZONE: $ALIAS --- FORCED IRRIGATION: $FORCE --- TIME: $(/bin/date -d@$TIME)"
;;
"ev_open_in_before")
ALIAS="$2"
FORCE="$3"
MINUTE_START="$4"
MINUTE_STOP="$5"
TIME=$6
BODY="PiGarden triggered new event --- EVENT: $EVENT --- ZONE: $ALIAS --- FORCED IRRIGATION: $FORCE --- MINUTE START: $MINUTE_START --- MINUTE STOP: $MINUTE_STOP --- TIME: $(/bin/date -d@$TIME)"
;;
"ev_open_in_after")
ALIAS="$2"
FORCE="$3"
CRON_START="$4"
CRON_STOP="$5"
TIME=$6
BODY="PiGarden triggered new event --- EVENT: $EVENT --- ZONE: $ALIAS --- FORCED IRRIGATION: $FORCE --- CRON START: $CRON_START --- CRON STOP: $CRON_STOP --- TIME: $(/bin/date -d@$TIME)"
;;
"ev_close_before" | "ev_close_after")
ALIAS="$2"
TIME=$3
BODY="PiGarden triggered new event --- EVENT: $EVENT --- ZONE: $ALIAS --- TIME: $(/bin/date -d@$TIME);"
;;
"ev_not_open_for_rain" | "ev_not_open_for_rain_online" | "ev_not_open_for_rain_sensor")
ALIAS="$2"
TIME=$3
BODY="PiGarden triggered new event --- EVENT: $EVENT --- ZONE: $ALIAS --- TIME: $(/bin/date -d@$TIME)"
;;
"check_rain_sensor_before" | "check_rain_sensor_after" | "check_rain_sensor_change")
STATE="$2"
TIME=$3
BODY="PiGarden triggered new event --- EVENT: $EVENT --- STATE: $STATE --- TIME: $(/bin/date -d@$TIME)"
;;
"check_rain_online_before")
STATE="$2"
TIME=$3
BODY="PiGarden triggered new event --- EVENT: $EVENT --- STATE: $STATE --- TIME: $(/bin/date -d@$TIME)"
;;
"check_rain_online_after" | "check_rain_online_change")
STATE="$2"
WEATHER="$3"
TIME=$4
BODY="PiGarden triggered new event --- EVENT: $EVENT --- STATE: $STATE --- WEATHER: $WEARTHER --- TIME: $(/bin/date -d@$TIME)"
;;
"cron_add_before" | "cron_add_after")
CRON_TYPE="$2"
CRON_ARG="$3"
CRON_ELEMENT="$4"
TIME=$5
BODY="PiGarden triggered new event --- EVENT: $EVENT --- CRON TYPE: $CRON_TYPE --- CRON ARG: $CRON_ARG --- CRON ELEMENT: $CRON_ELEMENT\nTIME: $(/bin/date -d@$TIME)"
;;
"cron_del_before" | "cron_del_after")
CRON_TYPE="$2"
CRON_ARG="$3"
TIME=$4
BODY="PiGarden triggered new event --- EVENT: $EVENT --- CRON TYPE: $CRON_TYPE --- CRON ARG: $CRON_ARG --- TIME: $(/bin/date -d@$TIME)"
;;
"exec_poweroff_before" | "exec_poweroff_after" | "exec_reboot_before" | "exec_reboot_after")
TIME=$2
BODY="PiGarden triggered new event --- EVENT: $EVENT --- TIME: $(/bin/date -d@$TIME)"
;;
*)
exit
;;
esac
curl -X POST -F "text=$BODY" https://api.rpinotify.it/message/$TOKEN/

View File

@@ -24,13 +24,12 @@ EVENT="$1"
TO="mail@destination.com"
FROM="piGarden@your_domain.com"
SUBJECT="piGarden notification mail: event $EVENT"
SUBJECT="[piGarden notification mail] event $EVENT"
BODY=""
case "$EVENT" in
"init_before" | "init_after")
STATE="$2"
TIME=$3
TIME=$2
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nTIME: $(/bin/date -d@$TIME)"
;;
@@ -41,22 +40,74 @@ case "$EVENT" in
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nZONE: $ALIAS\nFORCED IRRIGATION: $FORCE\nTIME: $(/bin/date -d@$TIME)"
;;
"ev_open_in_before")
ALIAS="$2"
FORCE="$3"
MINUTE_START="$4"
MINUTE_STOP="$5"
TIME=$6
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nZONE: $ALIAS\nFORCED IRRIGATION: $FORCE\nMINUTE START: $MINUTE_START\nMINUTE STOP: $MINUTE_STOP\nTIME: $(/bin/date -d@$TIME)"
;;
"ev_open_in_after")
ALIAS="$2"
FORCE="$3"
CRON_START="$4"
CRON_STOP="$5"
TIME=$6
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nZONE: $ALIAS\nFORCED IRRIGATION: $FORCE\nCRON START: $CRON_START\nCRON STOP: $CRON_STOP\nTIME: $(/bin/date -d@$TIME)"
;;
"ev_close_before" | "ev_close_after")
ALIAS="$2"
TIME=$3
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"
TIME=$3
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nZONE: $ALIAS\nTIME: $(/bin/date -d@$TIME)"
;;
"check_rain_sensor_before" | "check_rain_sensor_after" | "check_rain_sensor_change")
STATE="$2"
TIME=$3
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nSTATE: $ALIAS\nTIME: $(/bin/date -d@$TIME)"
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nSTATE: $STATE\nTIME: $(/bin/date -d@$TIME)"
;;
"check_rain_online_before" | "check_rain_online_after" | "check_rain_online_change")
"check_rain_online_before")
STATE="$2"
TIME=$3
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nSTATE: $ALIAS\nTIME: $(/bin/date -d@$TIME)"
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nSTATE: $STATE\nTIME: $(/bin/date -d@$TIME)"
;;
"check_rain_online_after" | "check_rain_online_change")
STATE="$2"
WEATHER="$3"
TIME=$4
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nSTATE: $STATE\nWEATHER: $WEARTHER\nTIME: $(/bin/date -d@$TIME)"
;;
"cron_add_before" | "cron_add_after")
CRON_TYPE="$2"
CRON_ARG="$3"
CRON_ELEMENT="$4"
TIME=$5
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nCRON TYPE: $CRON_TYPE\nCRON ARG: $CRON_ARG\nCRON ELEMENT: $CRON_ELEMENT\nTIME: $(/bin/date -d@$TIME)"
;;
"cron_del_before" | "cron_del_after")
CRON_TYPE="$2"
CRON_ARG="$3"
TIME=$4
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nCRON TYPE: $CRON_TYPE\nCRON ARG: $CRON_ARG\nTIME: $(/bin/date -d@$TIME)"
;;
"exec_poweroff_before" | "exec_poweroff_after" | "exec_reboot_before" | "exec_reboot_after")
TIME=$2
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nTIME: $(/bin/date -d@$TIME)"
;;
*)

View File

@@ -39,10 +39,10 @@ function cron_del {
return 1
fi
trigger_event "cron_del_before" "$1" "$2"
$SED "$START,${END}d" "$TMP_CRON_FILE" | $SED '$!N; /^\(.*\)\n\1$/!P; D' | $CRONTAB -
#$CRONTAB "$TMP_CRON_FILE"
rm "$TMP_CRON_FILE"
trigger_event "cron_del_after" "$1" "$2"
}
@@ -206,8 +206,10 @@ function cron_add {
echo "$CRON_DISABLED$CRON_M $CRON_H $CRON_DOM $CRON_MON $CRON_DOW $CRON_COMMAND" >> "$TMP_CRON_FILE2"
echo "# END cron $CRON_TYPE $CRON_ARG" >> "$TMP_CRON_FILE2"
trigger_event "cron_add_before" "$CRON_TYPE" "$CRON_ARG" "$CRON_DISABLED$CRON_M $CRON_H $CRON_DOM $CRON_MON $CRON_DOW $CRON_COMMAND"
$CRONTAB "$TMP_CRON_FILE2"
rm "$TMP_CRON_FILE" "$TMP_CRON_FILE2"
trigger_event "cron_add_after" "$CRON_TYPE" "$CRON_ARG" "$CRON_DISABLED$CRON_M $CRON_H $CRON_DOM $CRON_MON $CRON_DOW $CRON_COMMAND"
}

View File

@@ -111,9 +111,13 @@ function drv_rele_close {
elif [ "$fnc" == "drvnotfound" ]; then
log_write "Driver not found: $idx"
message_write "warning" "Driver not found: $idx"
return 1
else
echo "$(date) $fnc arg:$idx" >> "$LOG_OUTPUT_DRV_FILE"
$fnc "$idx" >> "$LOG_OUTPUT_DRV_FILE" 2>&1
if [ $? -eq 1 ]; then
return 1
fi
fi
}
@@ -133,9 +137,13 @@ function drv_rele_open {
elif [ "$fnc" == "drvnotfound" ]; then
log_write "Driver not found: $idx"
message_write "warning" "Driver not found: $idx"
return 1
else
echo "$(date) $fnc arg:$idx" >> "$LOG_OUTPUT_DRV_FILE"
$fnc "$idx" >> "$LOG_OUTPUT_DRV_FILE" 2>&1
if [ $? -eq 1 ]; then
return 1
fi
fi
}

View File

@@ -5,19 +5,6 @@
function trigger_event {
# check_rain_online_after
# check_rain_online_before
# check_rain_online_change
# check_rain_sensor_after
# check_rain_sensor_before
# check_rain_sensor_change
# ev_close_after
# ev_close_before
# ev_open_after
# ev_open_before
# init_after
# init_before
local EVENT="$1"
local CAUSE="$2"
local current_event_dir="$EVENT_DIR/$EVENT"
@@ -34,6 +21,22 @@ function trigger_event {
$f "$EVENT" "$ALIAS" "$FORCE" `date +%s` &> /dev/null
;;
"ev_open_in_before")
ALIAS="$2"
FORCE="$3"
local MINUTE_START="$4"
local MINUTE_STOP="$5"
$f "$EVENT" "$ALIAS" "$FORCE" "$MINUTE_START" "$MINUTE_STOP" `date +%s` &> /dev/null
;;
"ev_open_in_after")
ALIAS="$2"
FORCE="$3"
local CRON_START="$4"
local CRON_STOP="$5"
$f "$EVENT" "$ALIAS" "$FORCE" "$CRON_START" "$CRON_STOP" `date +%s` &> /dev/null
;;
"ev_close_before" | "ev_close_after")
ALIAS="$2"
$f "$EVENT" "$ALIAS" `date +%s` &> /dev/null
@@ -45,11 +48,40 @@ function trigger_event {
$f "$EVENT" "$STATE" `date +%s` &> /dev/null
;;
"check_rain_online_before" | "check_rain_online_after" | "check_rain_online_change")
"check_rain_online_before")
STATE="$2"
$f "$EVENT" "$STATE" `date +%s` &> /dev/null
;;
"check_rain_online_after" | "check_rain_online_change")
STATE="$2"
WEATHER="$3"
$f "$EVENT" "$STATE" "$WEATHER" `date +%s` &> /dev/null
;;
"init_before" | "init_after")
STATE="$2"
$f "$EVENT" `date +%s` &> /dev/null
;;
"cron_add_before" | "cron_add_after")
local CRON_TYPE="$2"
local CRON_ARG="$3"
local CRON_ELEMENT="$4"
$f "$EVENT" "$CRON_TYPE" "$CRON_ARG" "$CRON_ELEMENT" `date +%s` &> /dev/null
;;
"cron_del_before" | "cron_del_after")
local CRON_TYPE="$2"
local CRON_ARG="$3"
$f "$EVENT" "$CRON_TYPE" "$CRON_ARG" `date +%s` &> /dev/null
;;
"exec_poweroff_before" | "exec_poweroff_after" | "exec_reboot_before" | "exec_reboot_after" )
$f "$EVENT" `date +%s` &> /dev/null
;;
*)
$f "$EVENT" "$CAUSE" `date +%s` &> /dev/null
;;

View File

@@ -35,11 +35,11 @@ function check_rain_online {
echo "$current_observation" > "$STATUS_DIR/last_weather_online"
if [ "$current_state_rain_online" != "$last_state_rain_online" ]; then
echo "$current_state_rain_online" > "$STATUS_DIR/last_state_rain_online"
trigger_event "check_rain_online_change" "$current_state_rain_online"
trigger_event "check_rain_online_change" "$current_state_rain_online" "$weather"
fi
fi
trigger_event "check_rain_online_after" "$current_state_rain_online"
trigger_event "check_rain_online_after" "$current_state_rain_online" "$weather"
}
#

View File

@@ -26,10 +26,6 @@ function initialize {
# Imposta l'alimentazione con voltaggio negativo e setta i gpio in scrittura per le elettrovalvole bistabili
if [ "$EV_MONOSTABLE" != "1" ]; then
drv_supply_bistable_init "$SUPPLY_GPIO_1" "$SUPPLY_GPIO_2"
#$GPIO -g write $SUPPLY_GPIO_1 0
#$GPIO -g write $SUPPLY_GPIO_2 0
#$GPIO -g mode $SUPPLY_GPIO_1 out
#$GPIO -g mode $SUPPLY_GPIO_2 out
fi
# Elimina tutti gli stati delle elettrovalvole preesistenti
@@ -40,8 +36,6 @@ function initialize {
do
g=EV"$i"_GPIO
drv_rele_init "${!g}"
#$GPIO -g write ${!g} RELE_GPIO_OPEN # chiude l'alimentazione all'elettrovalvole
#$GPIO -g mode ${!g} out # setta il gpio nella modalita di scrittura
ev_set_state $i 0
done
@@ -56,7 +50,6 @@ function initialize {
# Inizializza il sensore di rilevamento pioggia
if [ -n "$RAIN_GPIO" ]; then
drv_rain_sensor_init "$RAIN_GPIO"
#$GPIO -g mode $RAIN_GPIO in
log_write "Rain sensor initialized"
else
log_write "Rain sensor not present"
@@ -90,6 +83,10 @@ function ev_open {
local EVNUM=$?
local g=`ev_number2gpio $EVNUM`
local EVNORAIN=`ev_number2norain $EVNUM`
local EV_IS_REMOTE_VAR=EV"$EVNUM"_REMOTE
local EV_IS_REMOTE=${!EV_IS_REMOTE_VAR}
local EV_IS_MONOSTAVLE_VAR=EV"$EVNUM"_MONOSTABLE
local EV_IS_MONOSTAVLE=${!EV_IS_MONOSTAVLE_VAR}
if [ ! "$2" = "force" ] && [ "$EVNORAIN" != "1" ]; then
if [[ "$NOT_IRRIGATE_IF_RAIN_ONLINE" -gt 0 && -f $STATUS_DIR/last_rain_online ]]; then
@@ -98,6 +95,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"
trigger_event "ev_not_open_for_rain" "$1"
log_write "Solenoid '$1' not open for rain (online check)"
message_write "warning" "Solenoid not open for rain"
return
@@ -111,6 +110,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"
trigger_event "ev_not_open_for_rain" "$1"
log_write "Solenoid '$1' not open for rain (sensor check)"
message_write "warning" "Solenoid not open for rain"
return
@@ -133,15 +134,16 @@ function ev_open {
lock
# Gestisce l'apertura dell'elettrovalvola in base alla tipologia (monostabile / bistabile)
if [ "$EV_MONOSTABLE" == "1" ]; then
#$GPIO -g write $g $RELE_GPIO_CLOSE
if [ "$EV_MONOSTABLE" == "1" ] || [ "$EV_IS_REMOTE" == "1" ] || [ "$EV_IS_MONOSTABLE" == "1" ]; then
drv_rele_close "$g"
if [ $? -eq 1 ]; then
unlock
return
fi
else
supply_positive
#$GPIO -g write $g $RELE_GPIO_CLOSE
drv_rele_close "$g"
sleep 1
#$GPIO -g write $g $RELE_GPIO_OPEN
drv_rele_open "$g"
fi
@@ -190,6 +192,9 @@ function ev_open_in {
message_write "warning" "Alias solenoid not specified"
return 1
fi
trigger_event "ev_open_in_before" "$3" "$4" "$1" "$2"
gpio_alias2number $alias > /dev/null 2>&1
minute_start=$(($minute_start + 1))
@@ -201,6 +206,7 @@ function ev_open_in {
if [ "$minute_start" -eq "1" ]; then
ev_open $alias $force
cron_start="- - - - -"
else
cron_add open_in $cron_start "$alias" "$force"
fi
@@ -210,6 +216,8 @@ function ev_open_in {
message_write "success" "Scheduled start successfully performed"
trigger_event "ev_open_in_after" "$3" "$4" "$cron_start" "$cron_stop"
#echo $cron_start
#echo $cron_stop
@@ -226,21 +234,24 @@ function ev_close {
ev_alias2number $1
EVNUM=$?
g=`ev_number2gpio $EVNUM`
local EV_IS_REMOTE_VAR=EV"$EVNUM"_REMOTE
local EV_IS_REMOTE=${!EV_IS_REMOTE_VAR}
trigger_event "ev_close_before" "$1"
lock
# Gestisce l'apertura dell'elettrovalvola in base alla tipologia (monostabile / bistabile)
if [ "$EV_MONOSTABLE" == "1" ]; then
#$GPIO -g write $g $RELE_GPIO_OPEN
if [ "$EV_MONOSTABLE" == "1" ] || [ "$EV_IS_REMOTE" == "1" ]; then
drv_rele_open "$g"
if [ $? -eq 1 ]; then
unlock
return
fi
else
supply_negative
#$GPIO -g write $g $RELE_GPIO_CLOSE
drv_rele_close "$g"
sleep 1
#$GPIO -g write $g $RELE_GPIO_OPEN
drv_rele_open "$g"
fi
@@ -261,8 +272,6 @@ function ev_close {
#
function supply_positive {
drv_supply_positive "$SUPPLY_GPIO_1" "$SUPPLY_GPIO_2"
#$GPIO -g write $SUPPLY_GPIO_1 $SUPPLY_GPIO_POS
#$GPIO -g write $SUPPLY_GPIO_2 $SUPPLY_GPIO_POS
}
#
@@ -270,8 +279,6 @@ function supply_positive {
#
function supply_negative {
drv_supply_negative "$SUPPLY_GPIO_1" "$SUPPLY_GPIO_2"
#$GPIO -g write $SUPPLY_GPIO_1 $SUPPLY_GPIO_NEG
#$GPIO -g write $SUPPLY_GPIO_2 $SUPPLY_GPIO_NEG
}
#
@@ -757,19 +764,22 @@ function send_identifier {
# Spenge il sistema
#
function exec_poweroff {
trigger_event "exec_poweroff_before"
local PATH_SCRIPT=`$READLINK -f "$DIR_SCRIPT/scripts/poweroff.sh"`
echo "$PATH_SCRIPT" > tmp/prova.txt
sleep 15
. $PATH_SCRIPT
trigger_event "exec_poweroff_after"
}
#
# Spenge il sistema
#
function exec_reboot {
trigger_event "exec_reboot_before"
local PATH_SCRIPT=`$READLINK -f "$DIR_SCRIPT/scripts/reboot.sh"`
sleep 15
. $PATH_SCRIPT
trigger_event "exec_reboot_after"
}
function debug1 {
@@ -782,7 +792,7 @@ function debug2 {
VERSION=0
SUB_VERSION=5
RELEASE_VERSION=3
RELEASE_VERSION=7
DIR_SCRIPT=`dirname $0`
NAME_SCRIPT=${0##*/}
@@ -815,7 +825,7 @@ LAST_WARNING_FILE="$STATUS_DIR/last_warning"
LAST_SUCCESS_FILE="$STATUS_DIR/last_success"
if [ -z $LOG_OUTPUT_DRV_FILE ]; then
$LOG_OUTPUT_DRV_FILE="/dev/null"
LOG_OUTPUT_DRV_FILE="/dev/null"
fi
if [ -z "$EVENT_DIR" ]; then
@@ -836,6 +846,8 @@ fi
send_identifier &
setup_drv
#echo "EV_MONOSTABLE=$EV_MONOSTABLE"
case "$1" in
init)
initialize