Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d9ef42679 | ||
|
|
70c4e063f8 | ||
|
|
4d4b35c3cc | ||
|
|
71e91cc861 | ||
|
|
a76c797b22 | ||
|
|
07a594e799 | ||
|
|
dfa68c2b83 | ||
|
|
e284bbcb25 | ||
|
|
d324faf8bb | ||
|
|
383cbc44a9 | ||
|
|
9864709b44 | ||
|
|
6d8c82f0a3 | ||
|
|
a997081aa9 | ||
|
|
c145171306 | ||
|
|
e9a676188f | ||
|
|
0d748031fd | ||
|
|
3ed46d80ad | ||
|
|
05a73720bb | ||
|
|
2ea6588c32 | ||
|
|
fc717f18a2 | ||
|
|
50117a5a96 | ||
|
|
309c209b1b | ||
|
|
9a81f0fbba | ||
|
|
419695b420 | ||
|
|
3239006922 | ||
|
|
24baa97dad | ||
|
|
c354f72c0c | ||
|
|
6f80b8ea21 | ||
|
|
87edbbbe7a | ||
|
|
3eb45fd1e9 | ||
|
|
7c96a6afd1 | ||
|
|
c664bea16a | ||
|
|
78fa176848 |
23
CHANGELOG.md
23
CHANGELOG.md
@@ -1,3 +1,26 @@
|
|||||||
|
# 0.5.12 - 13/11/2018
|
||||||
|
- Fixed a bug that prevented the publication of the mqtt topic for each event
|
||||||
|
- Fixed a bug on openweathermap driver which in some cases causes a malformation of the json status and prevented communication with piGardenWeb
|
||||||
|
|
||||||
|
# 0.5.11 - 11/11/2018
|
||||||
|
- Added ability to disable online weather service by defining WEATHER_SERVICE="none" in the configuration file
|
||||||
|
|
||||||
|
# 0.5.10 - 11/11/2018
|
||||||
|
- Fix bug in single monostable solenodid management caused from wrong variable name EV_IS_MONOSTAVLE
|
||||||
|
|
||||||
|
# 0.5.9 - 01/11/2018
|
||||||
|
- Added mqtt support for publishing status to broker
|
||||||
|
|
||||||
|
# 0.5.8 - 19/07/2018
|
||||||
|
- Added "openweathermap" driver for impement check weather condition from openweatermap api
|
||||||
|
|
||||||
|
# 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
|
# 0.5.5 - 25/03/2018
|
||||||
- Added "remote" driver to control remote pigarden
|
- Added "remote" driver to control remote pigarden
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,13 @@ READLINK="/bin/readlink"
|
|||||||
# Percorso stat
|
# Percorso stat
|
||||||
STAT="/usr/bin/stat"
|
STAT="/usr/bin/stat"
|
||||||
|
|
||||||
|
# Percorso mosquito_pub
|
||||||
|
# # Installare con apt install mosquitto-clients
|
||||||
|
MOSQUITTO_PUB="/usr/bin/mosquitto_pub"
|
||||||
|
|
||||||
|
|
||||||
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
|
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
|
||||||
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili
|
# se impostato a 0 il sistema gestirà elettrovalvole bistabili
|
||||||
EV_MONOSTABLE=0
|
EV_MONOSTABLE=0
|
||||||
|
|
||||||
# Id gpio usati per simulare il doppio deviatore con cui eseguire l'alimentazione alle elettrovalvole
|
# Id gpio usati per simulare il doppio deviatore con cui eseguire l'alimentazione alle elettrovalvole
|
||||||
@@ -90,6 +95,7 @@ EV_TOTAL=6
|
|||||||
EV1_ALIAS="1" #
|
EV1_ALIAS="1" #
|
||||||
EV1_GPIO=17 # Physical 11 - wPi 0
|
EV1_GPIO=17 # Physical 11 - wPi 0
|
||||||
#EV1_NORAIN=1 # Non interrompe l'irrigazione di questa zona in caso di pioggia
|
#EV1_NORAIN=1 # Non interrompe l'irrigazione di questa zona in caso di pioggia
|
||||||
|
#EV1_MONOSTABLE=1 # L'elettrovalvola è monostabile
|
||||||
|
|
||||||
EV2_ALIAS="2" #
|
EV2_ALIAS="2" #
|
||||||
EV2_GPIO=27 # Physical 13 - wPi 2
|
EV2_GPIO=27 # Physical 13 - wPi 2
|
||||||
@@ -106,9 +112,21 @@ EV5_GPIO=23 # Physical 16 - wPi 4
|
|||||||
EV6_ALIAS="6" #
|
EV6_ALIAS="6" #
|
||||||
EV6_GPIO=24 # Physical 18 - wPi 5
|
EV6_GPIO=24 # Physical 18 - wPi 5
|
||||||
|
|
||||||
# Definisce l'api key e il luogo per recuperare lo stato meteo online
|
|
||||||
|
# Definisci il servizio online da utilizzare per il controllo delle condizioni meteo, puoi scegliere openweathermap oppure wunderground.
|
||||||
|
# Se non vuoi configurare nessun servizio imposta il vale "none"
|
||||||
|
WEATHER_SERVICE="openweathermap"
|
||||||
|
#WEATHER_SERVICE="none" # Nessun servizio configurato
|
||||||
|
|
||||||
|
# Parametri di openweathermap, definisce l'api key e il luogo per recuperare lo stato meteo online
|
||||||
|
OPENWEATHERMAP_KEY=""
|
||||||
|
OPENWEATHERMAP_LOCATION="q=Pieve%20a%20Nievole,it" # https://openweathermap.org/current
|
||||||
|
OPENWEATHERMAP_TZ="Europe/Rome" # Time zone
|
||||||
|
|
||||||
|
# Parametri di wunderground, definisce l'api key e il luogo per recuperare lo stato meteo online
|
||||||
WUNDERGROUND_KEY=""
|
WUNDERGROUND_KEY=""
|
||||||
WUNDERGROUND_LOCATION="IY/Monsummano" # http://www.wunderground.com/weather/api/d/docs?d=resources/country-to-iso-matching&MR=1
|
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.
|
# 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.
|
# 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.
|
||||||
@@ -128,3 +146,12 @@ TCPSERVER_PWD=""
|
|||||||
# Con impostato il valore 1 non invia l'identificativi per statistiche di utilizzo
|
# Con impostato il valore 1 non invia l'identificativi per statistiche di utilizzo
|
||||||
NO_SEND_IDENTIFIER=0
|
NO_SEND_IDENTIFIER=0
|
||||||
|
|
||||||
|
# Parametri connessione al broker mqtt
|
||||||
|
MQTT_ENABLE=0 # set 1 to enable
|
||||||
|
MQTT_HOST=you_host_mqtt
|
||||||
|
MQTT_PORT=1883
|
||||||
|
MQTT_USER=your_user_mqtt
|
||||||
|
MQTT_PWD=yout_password_mqtt
|
||||||
|
MQTT_TOPIC="pigarden/result"
|
||||||
|
MQTT_CLIENT_ID=piGarden
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,11 @@ READLINK="/bin/readlink"
|
|||||||
# Percorso stat
|
# Percorso stat
|
||||||
STAT="/usr/bin/stat"
|
STAT="/usr/bin/stat"
|
||||||
|
|
||||||
|
# Percorso mosquito_pub
|
||||||
|
# Installare con apt install mosquitto-clients
|
||||||
|
MOSQUITTO_PUB="/usr/bin/mosquitto_pub"
|
||||||
|
|
||||||
|
|
||||||
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
|
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
|
||||||
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili
|
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili
|
||||||
EV_MONOSTABLE=0
|
EV_MONOSTABLE=0
|
||||||
@@ -100,11 +105,21 @@ EV4_ALIAS="Giardino_Posteriore_GPIO" #
|
|||||||
EV4_GPIO="18"
|
EV4_GPIO="18"
|
||||||
|
|
||||||
|
|
||||||
|
# Definisci il servizio online da utilizzare per il controllo delle condizioni meteo, puoi scegliere openweathermap oppure wunderground.
|
||||||
|
# Se non vuoi configurare nessun servizio imposta il vale "none"
|
||||||
|
WEATHER_SERVICE="openweathermap"
|
||||||
|
#WEATHER_SERVICE="none" # Nessun servizio configurato
|
||||||
|
|
||||||
# Definisce l'api key e il luogo per recuperare lo stato meteo online
|
# Parametri di openweathermap, definisce l'api key e il luogo per recuperare lo stato meteo online
|
||||||
|
OPENWEATHERMAP_KEY=""
|
||||||
|
OPENWEATHERMAP_LOCATION="q=Pieve%20a%20Nievole,it" # https://openweathermap.org/current
|
||||||
|
OPENWEATHERMAP_TZ="Europe/Rome" # Time zone
|
||||||
|
|
||||||
|
# Parametri di wunderground, definisce l'api key e il luogo per recuperare lo stato meteo online
|
||||||
WUNDERGROUND_KEY=""
|
WUNDERGROUND_KEY=""
|
||||||
WUNDERGROUND_LOCATION="IT/Pieve%20a%20Nievole" # http://www.wunderground.com/weather/api/d/docs?d=resources/country-to-iso-matching&MR=1
|
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.
|
# 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.
|
# 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
|
NOT_IRRIGATE_IF_RAIN_ONLINE=86400
|
||||||
@@ -123,6 +138,15 @@ TCPSERVER_PWD=""
|
|||||||
# Con impostato il valore 1 non invia l'identificativi per statistiche di utilizzo
|
# Con impostato il valore 1 non invia l'identificativi per statistiche di utilizzo
|
||||||
NO_SEND_IDENTIFIER=0
|
NO_SEND_IDENTIFIER=0
|
||||||
|
|
||||||
|
# Parametri connessione al broker mqtt
|
||||||
|
MQTT_ENABLE=0 # set 1 to enable
|
||||||
|
MQTT_HOST=you_host_mqtt
|
||||||
|
MQTT_PORT=1883
|
||||||
|
MQTT_USER=your_user_mqtt
|
||||||
|
MQTT_PWD=yout_password_mqtt
|
||||||
|
MQTT_TOPIC="pigarden/result"
|
||||||
|
MQTT_CLIENT_ID=piGarden
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Configurazione piGarden remoti
|
# Configurazione piGarden remoti
|
||||||
|
|||||||
166
conf/piGarden.conf.sonoff_tasmota_http.example
Normal file
166
conf/piGarden.conf.sonoff_tasmota_http.example
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
# 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"
|
||||||
|
|
||||||
|
# Percorso mosquito_pub
|
||||||
|
# # Installare con apt install mosquitto-clients
|
||||||
|
MOSQUITTO_PUB="/usr/bin/mosquitto_pub"
|
||||||
|
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
|
||||||
|
# Definisci il servizio online da utilizzare per il controllo delle condizioni meteo, puoi scegliere openweathermap oppure wunderground.
|
||||||
|
# Se non vuoi configurare nessun servizio imposta il vale "none"
|
||||||
|
WEATHER_SERVICE="openweathermap"
|
||||||
|
#WEATHER_SERVICE="none" # Nessun servizio configurato
|
||||||
|
|
||||||
|
# Parametri di openweathermap, definisce l'api key e il luogo per recuperare lo stato meteo online
|
||||||
|
OPENWEATHERMAP_KEY=""
|
||||||
|
OPENWEATHERMAP_LOCATION="q=Pieve%20a%20Nievole,it" # https://openweathermap.org/current
|
||||||
|
OPENWEATHERMAP_TZ="Europe/Rome" # Time zone
|
||||||
|
|
||||||
|
# Parametri di wunderground, 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
|
||||||
|
|
||||||
|
# Parametri connessione al broker mqtt
|
||||||
|
MQTT_ENABLE=0 # set 1 to enable
|
||||||
|
MQTT_HOST=you_host_mqtt
|
||||||
|
MQTT_PORT=1883
|
||||||
|
MQTT_USER=your_user_mqtt
|
||||||
|
MQTT_PWD=yout_password_mqtt
|
||||||
|
MQTT_TOPIC="pigarden/result"
|
||||||
|
MQTT_CLIENT_ID=piGarden
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# 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=""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -53,6 +53,11 @@ READLINK="/bin/readlink"
|
|||||||
# Percorso stat
|
# Percorso stat
|
||||||
STAT="/usr/bin/stat"
|
STAT="/usr/bin/stat"
|
||||||
|
|
||||||
|
# Percorso mosquito_pub
|
||||||
|
# Installare con apt install mosquitto-clients
|
||||||
|
MOSQUITTO_PUB="/usr/bin/mosquitto_pub"
|
||||||
|
|
||||||
|
|
||||||
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
|
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
|
||||||
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili
|
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili
|
||||||
EV_MONOSTABLE=1
|
EV_MONOSTABLE=1
|
||||||
@@ -472,9 +477,20 @@ EV128_ALIAS="Zona_128" #
|
|||||||
EV128_GPIO="drv:spb16ch:128"
|
EV128_GPIO="drv:spb16ch:128"
|
||||||
|
|
||||||
|
|
||||||
# Definisce l'api key e il luogo per recuperare lo stato meteo online
|
# Definisci il servizio online da utilizzare per il controllo delle condizioni meteo, puoi scegliere openweathermap oppure wunderground.
|
||||||
|
# Se non vuoi configurare nessun servizio imposta il vale "none"
|
||||||
|
WEATHER_SERVICE="openweathermap"
|
||||||
|
#WEATHER_SERVICE="none" # Nessun servizio configurato
|
||||||
|
|
||||||
|
# Parametri di openweathermap, definisce l'api key e il luogo per recuperare lo stato meteo online
|
||||||
|
OPENWEATHERMAP_KEY=""
|
||||||
|
OPENWEATHERMAP_LOCATION="q=Pieve%20a%20Nievole,it" # https://openweathermap.org/current
|
||||||
|
OPENWEATHERMAP_TZ="Europe/Rome" # Time zone
|
||||||
|
|
||||||
|
# Parametri di wunderground, definisce l'api key e il luogo per recuperare lo stato meteo online
|
||||||
WUNDERGROUND_KEY=""
|
WUNDERGROUND_KEY=""
|
||||||
WUNDERGROUND_LOCATION="IY/Monsummano" # http://www.wunderground.com/weather/api/d/docs?d=resources/country-to-iso-matching&MR=1
|
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.
|
# 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.
|
# 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.
|
||||||
@@ -494,6 +510,15 @@ TCPSERVER_PWD=""
|
|||||||
# Con impostato il valore 1 non invia l'identificativi per statistiche di utilizzo
|
# Con impostato il valore 1 non invia l'identificativi per statistiche di utilizzo
|
||||||
NO_SEND_IDENTIFIER=0
|
NO_SEND_IDENTIFIER=0
|
||||||
|
|
||||||
|
# Parametri connessione al broker mqtt
|
||||||
|
MQTT_ENABLE=0 # set 1 to enable
|
||||||
|
MQTT_HOST=you_host_mqtt
|
||||||
|
MQTT_PORT=1883
|
||||||
|
MQTT_USER=your_user_mqtt
|
||||||
|
MQTT_PWD=yout_password_mqtt
|
||||||
|
MQTT_TOPIC="pigarden/result"
|
||||||
|
MQTT_CLIENT_ID=piGarden
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Configurazione schede spb16ch
|
# Configurazione schede spb16ch
|
||||||
|
|||||||
13
drv/openweathermap/README.md
Normal file
13
drv/openweathermap/README.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Driver for check wather condition with openweathermap online service
|
||||||
|
|
||||||
|
# Example of configuration in piGarden.conf
|
||||||
|
|
||||||
|
```bash
|
||||||
|
WEATHER_SERVICE="openweathermap"
|
||||||
|
|
||||||
|
OPENWEATHERMAP_KEY="d4d22ea805788420267971135563b4cc" # Set with your api key of openweathermap
|
||||||
|
OPENWEATHERMAP_LOCATION="q=Pieve%20a%20Nievole,it" # Set with location identify, see https://openweathermap.org/current
|
||||||
|
OPENWEATHERMAP_TZ="Europe/Rome" # Set with your time zone
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
123
drv/openweathermap/common.include.sh
Normal file
123
drv/openweathermap/common.include.sh
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
#
|
||||||
|
# Funzioni comuni utilizzate dal driver
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Recupera la descrizione della condizione meteo
|
||||||
|
#
|
||||||
|
# $1 condizione meteo recuperata dalle api
|
||||||
|
#
|
||||||
|
function drv_openweathermap_get_wather {
|
||||||
|
|
||||||
|
declare -A w
|
||||||
|
|
||||||
|
w["thunderstorm with light rain"]="Thunderstorms and Rain"
|
||||||
|
w["thunderstorm with rain"]="Thunderstorms and Rain"
|
||||||
|
w["thunderstorm with heavy rain"]="Thunderstorms and Rain"
|
||||||
|
w["light thunderstorm"]="Thunderstorm"
|
||||||
|
w["thunderstorm"]="Thunderstorm"
|
||||||
|
w["heavy thunderstorm"]="Thunderstorm"
|
||||||
|
w["ragged thunderstorm"]="Thunderstorm"
|
||||||
|
w["thunderstorm with light drizzle"]="Thunderstorms and Rain"
|
||||||
|
w["thunderstorm with drizzle"]="Thunderstorms and Rain"
|
||||||
|
w["thunderstorm with heavy drizzle"]="Thunderstorms and Rain"
|
||||||
|
|
||||||
|
w["light intensity drizzle"]="Drizzle"
|
||||||
|
w["drizzle"]="Drizzle"
|
||||||
|
w["heavy intensity drizzle"]="Drizzle"
|
||||||
|
w["light intensity drizzle rain"]="Drizzle"
|
||||||
|
w["drizzle rain"]="Drizzle"
|
||||||
|
w["heavy intensity drizzle rain"]="Drizzle"
|
||||||
|
w["shower rain and drizzle"]="Drizzle"
|
||||||
|
w["heavy shower rain and drizzle"]="Drizzle"
|
||||||
|
w["shower drizzle"]="Drizzle"
|
||||||
|
|
||||||
|
w["light rain"]="Rain Mist"
|
||||||
|
w["moderate rain"]="Rain"
|
||||||
|
w["heavy intensity rain"]="Rain"
|
||||||
|
w["very heavy rain"]="Rain"
|
||||||
|
w["extreme rain"]="Rain"
|
||||||
|
w["freezing rain"]="Freezing Rain"
|
||||||
|
w["light intensity shower rain"]="Rain"
|
||||||
|
w["shower rain"]="Rain"
|
||||||
|
w["heavy intensity shower rain"]="Rain"
|
||||||
|
w["ragged shower rain"]="Rain"
|
||||||
|
|
||||||
|
w["light snow"]="Snow"
|
||||||
|
w["snow"]="Snow"
|
||||||
|
w["heavy snow"]=""
|
||||||
|
w["sleet"]="Snow Grains"
|
||||||
|
w["shower sleet"]="Snow Grains"
|
||||||
|
w["light rain and snow"]="Snow"
|
||||||
|
w["rain and snow"]="Snow"
|
||||||
|
w["light shower snow"]="Snow"
|
||||||
|
w["shower snow"]="Snow"
|
||||||
|
w["heavy shower snow"]="Snow"
|
||||||
|
|
||||||
|
w["mist"]="Mist"
|
||||||
|
w["smoke"]="Smoke"
|
||||||
|
w["haze"]="Haze"
|
||||||
|
w["sand, dust whirls"]="Dust Whirls"
|
||||||
|
w["fog"]="Fog"
|
||||||
|
w["sand"]="Sand"
|
||||||
|
w["dust"]="Widespread Dust"
|
||||||
|
w["volcanic ash"]="Volcanic Ash"
|
||||||
|
w["squalls"]="Squalls"
|
||||||
|
w["tornado"]="Tornado"
|
||||||
|
|
||||||
|
w["clear sky"]="Clear"
|
||||||
|
|
||||||
|
w["few clouds"]="Partly Cloudy"
|
||||||
|
w["scattered clouds"]="Scattered Clouds"
|
||||||
|
w["broken clouds"]="Partly Cloudy"
|
||||||
|
w["overcast clouds"]="Mostly Cloudy"
|
||||||
|
|
||||||
|
local weather=${w[$1]}
|
||||||
|
|
||||||
|
if [ -z "$weather" ]; then
|
||||||
|
weather="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $weather
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Recupera la l'icona rappresentativa delle condizione meteo
|
||||||
|
#
|
||||||
|
# $1 nome dell'icona recuperato delle api weather.icon
|
||||||
|
#
|
||||||
|
function drv_openweathermap_get_ico {
|
||||||
|
|
||||||
|
declare -A w
|
||||||
|
|
||||||
|
w["01d"]="http://icons.wxug.com/i/c/k/clear.gif"
|
||||||
|
w["01n"]="http://icons.wxug.com/i/c/k/nt_clear.gif"
|
||||||
|
w["02d"]="http://icons.wxug.com/i/c/k/partlycloudy.gif"
|
||||||
|
w["02n"]="http://icons.wxug.com/i/c/k/nt_partlycloudy.gif"
|
||||||
|
w["03d"]="http://icons.wxug.com/i/c/k/cloudy.gif"
|
||||||
|
w["03n"]="http://icons.wxug.com/i/c/k/nt_cloudy.gif"
|
||||||
|
w["04d"]="http://icons.wxug.com/i/c/k/cloudy.gif"
|
||||||
|
w["04n"]="http://icons.wxug.com/i/c/k/nt_cloudy.gif"
|
||||||
|
w["09d"]="http://icons.wxug.com/i/c/k/sleet.gif"
|
||||||
|
w["09n"]="http://icons.wxug.com/i/c/k/nt_sleet.gif"
|
||||||
|
w["10d"]="http://icons.wxug.com/i/c/k/rain.gif"
|
||||||
|
w["10n"]="http://icons.wxug.com/i/c/k/nt_rain.gif"
|
||||||
|
w["11d"]="http://icons.wxug.com/i/c/k/tstorms.gif"
|
||||||
|
w["11n"]="http://icons.wxug.com/i/c/k/nt_tstorms.gif"
|
||||||
|
w["13d"]="http://icons.wxug.com/i/c/k/snow.gif"
|
||||||
|
w["13n"]="http://icons.wxug.com/i/c/k/nt_snow.gif"
|
||||||
|
w["50d"]="http://icons.wxug.com/i/c/k/fog.gif"
|
||||||
|
w["50n"]="http://icons.wxug.com/i/c/k/nt_fog.gif"
|
||||||
|
|
||||||
|
local ico=${w[$1]}
|
||||||
|
|
||||||
|
if [ -z "$ico" ]; then
|
||||||
|
ico="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $ico
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
74
drv/openweathermap/rainonline.include.sh
Normal file
74
drv/openweathermap/rainonline.include.sh
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#
|
||||||
|
# Ritorna lo stato delle condizioni meteo interrogando il servizio online
|
||||||
|
#
|
||||||
|
# $i identificativo gpio del sensore di pioggia
|
||||||
|
#
|
||||||
|
# return output: 0 - errore durante il recupero delle condizioni meteo
|
||||||
|
# >0 - rilevato pioggia, timestamp del rilevamento
|
||||||
|
# <0 - rilevato nessuna pioggia, timestamp del rilevamento
|
||||||
|
function drv_openweathermap_rain_online_get {
|
||||||
|
|
||||||
|
# http://www.wunderground.com/weather/api/d/docs?d=resources/phrase-glossary&MR=1
|
||||||
|
$CURL "http://api.openweathermap.org/data/2.5/weather?$OPENWEATHERMAP_LOCATION&units=metric&appid=$OPENWEATHERMAP_KEY" > $TMP_PATH/check_rain_online.openweathermap.json
|
||||||
|
local weather=`cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -M ".weather[0].main"`
|
||||||
|
|
||||||
|
local wind_deg=$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".wind.deg")
|
||||||
|
local wind_speed=$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".wind.speed")
|
||||||
|
if [ "$wind_speed" == "null" ]; then
|
||||||
|
#wind_speed=$($JQ -n $wind_speed*3600/1000)
|
||||||
|
wind_speed=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
local weather="$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".weather[0].description")"
|
||||||
|
local ico=$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".weather[0].icon")
|
||||||
|
weather=$(drv_openweathermap_get_wather "$weather")
|
||||||
|
ico=$(drv_openweathermap_get_ico "$ico")
|
||||||
|
|
||||||
|
local current_observation=$(cat <<EOF
|
||||||
|
{
|
||||||
|
"display_location": {
|
||||||
|
"city": "$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".name")"
|
||||||
|
},
|
||||||
|
"observation_epoch": "$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".dt")",
|
||||||
|
"local_epoch": "$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".dt")",
|
||||||
|
"local_tz_long": "$OPENWEATHERMAP_TZ",
|
||||||
|
"weather": "$weather",
|
||||||
|
"temp_c": "$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".main.temp")",
|
||||||
|
"relative_humidity": "$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".main.humidity")%",
|
||||||
|
"wind_dir": "$(deg2dir $wind_deg)",
|
||||||
|
"wind_degrees": "$wind_deg",
|
||||||
|
"wind_kph": "$wind_speed",
|
||||||
|
"wind_gust_kph": "--",
|
||||||
|
"pressure_mb": "$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".main.pressure")",
|
||||||
|
"dewpoint_c": "--",
|
||||||
|
"feelslike_c": "--",
|
||||||
|
"icon_url": "$ico"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
# "icon_url": "http://openweathermap.org/img/w/$(cat $TMP_PATH/check_rain_online.openweathermap.json | $JQ -r -M ".weather[0].icon").png"
|
||||||
|
|
||||||
|
#local current_observation=`cat $TMP_PATH/check_rain_online.json | $JQ -M ".current_observation"`
|
||||||
|
|
||||||
|
if [ "$weather" = "null" ]; then
|
||||||
|
echo "0"
|
||||||
|
else
|
||||||
|
echo "$current_observation" > "$STATUS_DIR/last_weather_online"
|
||||||
|
local local_epoch=`cat $STATUS_DIR/last_weather_online | $JQ -M -r ".local_epoch"`
|
||||||
|
if [[ "$weather" == *"Rain"* ]] ||
|
||||||
|
[[ "$weather" == *"Snow"* ]] ||
|
||||||
|
[[ "$weather" == *"Hail"* ]] ||
|
||||||
|
[[ "$weather" == *"Ice"* ]] ||
|
||||||
|
[[ "$weather" == *"Thunderstorm"* ]] ||
|
||||||
|
[[ "$weather" == *"Drizzle"* ]];
|
||||||
|
then
|
||||||
|
echo $local_epoch
|
||||||
|
else
|
||||||
|
echo "-$local_epoch"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1,4 +1,14 @@
|
|||||||
# Driver per controllare pigarden remoti in rete da un'installazione pigarden master
|
# Driver for controlling remote pigarden on the network from a pigarden master installation
|
||||||
|
|
||||||
Per maggiori informazioni consulta https://www.lejubila.net/2018/03/pigardent-0-5-5-driver-master-per-implementare-un-architettura-master-slave/
|
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
|
||||||
|
```bash
|
||||||
|
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=""
|
||||||
|
```
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ function drv_remote_rele_close {
|
|||||||
error="${error%\"}"
|
error="${error%\"}"
|
||||||
error="${error#\"}"
|
error="${error#\"}"
|
||||||
echo "error=$error"
|
echo "error=$error"
|
||||||
log_write "Remote rele open error: $error"
|
log_write "Remote rele close error: $error"
|
||||||
message_write "warning" "Remote rele open error: $error"
|
message_write "warning" "Remote rele close error: $error"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# Questa funzione viene invocata dalla funzione "setup_drv" di piGarden ad ogni avvio dello script
|
# 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_remote_setup {
|
function drv_remote_setup {
|
||||||
|
|
||||||
|
|||||||
13
drv/sample/rainonline.include.sh
Normal file
13
drv/sample/rainonline.include.sh
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#
|
||||||
|
# Ritorna lo stato delle condizioni meteo interrogando il servizio online
|
||||||
|
#
|
||||||
|
# return output: 0 - errore durante il recupero delle condizioni meteo
|
||||||
|
# >0 - rilevato pioggia, timestamp del rilevamento
|
||||||
|
# <0 - rilevato nessuna pioggia, timestamp del rilevamento
|
||||||
|
function drv_sample_rain_online_get {
|
||||||
|
|
||||||
|
local FOO="bar"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#
|
#
|
||||||
# Questa funzione viene invocata dalla funzione "setup_drv" di piGarden ad ogni avvio dello script
|
# 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 {
|
function drv_sample_setup {
|
||||||
|
|
||||||
|
|||||||
22
drv/sonoff_tasmota_http/README.md
Normal file
22
drv/sonoff_tasmota_http/README.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
# 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
|
||||||
|
|
||||||
|
```bash
|
||||||
|
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
|
||||||
|
|
||||||
50
drv/sonoff_tasmota_http/common.include.sh
Normal file
50
drv/sonoff_tasmota_http/common.include.sh
Normal 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\"}"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
7
drv/sonoff_tasmota_http/config.include.sh
Normal file
7
drv/sonoff_tasmota_http/config.include.sh
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#
|
||||||
|
# File di configurazione del driver
|
||||||
|
#
|
||||||
|
|
||||||
|
# Dichiarazione variabile di esempio
|
||||||
|
#declare -g SAMPLE_FOO
|
||||||
|
#SAMPLE_FOO="bar"
|
||||||
9
drv/sonoff_tasmota_http/init.include.sh
Normal file
9
drv/sonoff_tasmota_http/init.include.sh
Normal 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
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
23
drv/sonoff_tasmota_http/rainsensor.include.sh
Normal file
23
drv/sonoff_tasmota_http/rainsensor.include.sh
Normal 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"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
78
drv/sonoff_tasmota_http/rele.include.sh
Normal file
78
drv/sonoff_tasmota_http/rele.include.sh
Normal 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
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
10
drv/sonoff_tasmota_http/setup.include.sh
Normal file
10
drv/sonoff_tasmota_http/setup.include.sh
Normal 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"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
34
drv/sonoff_tasmota_http/supply.include.sh
Normal file
34
drv/sonoff_tasmota_http/supply.include.sh
Normal 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"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
12
drv/wunderground/README.md
Normal file
12
drv/wunderground/README.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Driver for check wather condition with wunderground online service
|
||||||
|
|
||||||
|
# Example of configuration in piGarden.conf
|
||||||
|
|
||||||
|
```bash
|
||||||
|
WEATHER_SERVICE="wunderground"
|
||||||
|
|
||||||
|
WUNDERGROUND_KEY="" # Set with your api key of wunderground
|
||||||
|
WUNDERGROUND_LOCATION="IY/Monsummano" # Set with your location indentify, see http://www.wunderground.com/weather/api/d/docs?d=resources/country-to-iso-matching&MR=1
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
12
drv/wunderground/common.include.sh
Normal file
12
drv/wunderground/common.include.sh
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#
|
||||||
|
# Funzioni comuni utilizzate dal driver
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Funzione di esempio
|
||||||
|
#
|
||||||
|
function sample_foo {
|
||||||
|
|
||||||
|
echo "bar"
|
||||||
|
|
||||||
|
}
|
||||||
36
drv/wunderground/rainonline.include.sh
Normal file
36
drv/wunderground/rainonline.include.sh
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
#
|
||||||
|
# Ritorna lo stato delle condizioni meteo interrogando il servizio online
|
||||||
|
#
|
||||||
|
# $i identificativo gpio del sensore di pioggia
|
||||||
|
#
|
||||||
|
# return output: 0 - errore durante il recupero delle condizioni meteo
|
||||||
|
# >0 - rilevato pioggia, timestamp del rilevamento
|
||||||
|
# <0 - rilevato nessuna pioggia, timestamp del rilevamento
|
||||||
|
function drv_wunderground_rain_online_get {
|
||||||
|
|
||||||
|
# http://www.wunderground.com/weather/api/d/docs?d=resources/phrase-glossary&MR=1
|
||||||
|
$CURL http://api.wunderground.com/api/$WUNDERGROUND_KEY/conditions/q/$WUNDERGROUND_LOCATION.json > $TMP_PATH/check_rain_online.json
|
||||||
|
local weather=`cat $TMP_PATH/check_rain_online.json | $JQ -M ".current_observation.weather"`
|
||||||
|
local current_observation=`cat $TMP_PATH/check_rain_online.json | $JQ -M ".current_observation"`
|
||||||
|
local local_epoch=`cat $TMP_PATH/check_rain_online.json | $JQ -M -r ".current_observation.local_epoch"`
|
||||||
|
|
||||||
|
if [ "$weather" = "null" ]; then
|
||||||
|
echo "0"
|
||||||
|
else
|
||||||
|
if [[ "$weather" == *"Rain"* ]] ||
|
||||||
|
[[ "$weather" == *"Snow"* ]] ||
|
||||||
|
[[ "$weather" == *"Hail"* ]] ||
|
||||||
|
[[ "$weather" == *"Ice"* ]] ||
|
||||||
|
[[ "$weather" == *"Thunderstorm"* ]] ||
|
||||||
|
[[ "$weather" == *"Drizzle"* ]];
|
||||||
|
then
|
||||||
|
echo $local_epoch
|
||||||
|
else
|
||||||
|
echo "-$local_epoch"
|
||||||
|
fi
|
||||||
|
echo "$current_observation" > "$STATUS_DIR/last_weather_online"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
4
events/ev_not_open_for_rain/.gitignore
vendored
Normal file
4
events/ev_not_open_for_rain/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file
|
||||||
|
!.gitignore
|
||||||
4
events/ev_not_open_for_rain_online/.gitignore
vendored
Normal file
4
events/ev_not_open_for_rain_online/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file
|
||||||
|
!.gitignore
|
||||||
4
events/ev_not_open_for_rain_sensor/.gitignore
vendored
Normal file
4
events/ev_not_open_for_rain_sensor/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file
|
||||||
|
!.gitignore
|
||||||
111
events/scripts/rpinotify.sh
Executable file
111
events/scripts/rpinotify.sh
Executable 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/
|
||||||
@@ -65,6 +65,12 @@ case "$EVENT" in
|
|||||||
BODY="PiGarden triggered new event\n\nEVENT: $EVENT\nZONE: $ALIAS\nTIME: $(/bin/date -d@$TIME)"
|
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")
|
"check_rain_sensor_before" | "check_rain_sensor_after" | "check_rain_sensor_change")
|
||||||
STATE="$2"
|
STATE="$2"
|
||||||
TIME=$3
|
TIME=$3
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function setup_drv {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Inizializza i driver per gli altri gpio
|
# Inizializza i driver per gli altri gpio
|
||||||
for gpio in "$SUPPLY_GPIO_1" "$SUPPLY_GPIO_2" "$RAIN_GPIO"
|
for gpio in "$SUPPLY_GPIO_1" "$SUPPLY_GPIO_2" "$RAIN_GPIO" "$WEATHER_SERVICE"
|
||||||
do
|
do
|
||||||
if [[ "$gpio" == drv:* ]]; then
|
if [[ "$gpio" == drv:* ]]; then
|
||||||
local drv=`echo $gpio | $CUT -d':' -f2,2`
|
local drv=`echo $gpio | $CUT -d':' -f2,2`
|
||||||
@@ -32,7 +32,7 @@ function setup_drv {
|
|||||||
local file_drv
|
local file_drv
|
||||||
for drv in "${list_drv[@]}"
|
for drv in "${list_drv[@]}"
|
||||||
do
|
do
|
||||||
for callback in config common init rele supply rainsensor setup
|
for callback in config common init rele supply rainsensor rainonline setup
|
||||||
do
|
do
|
||||||
file_drv="$DIR_SCRIPT/drv/$drv/$callback.include.sh"
|
file_drv="$DIR_SCRIPT/drv/$drv/$callback.include.sh"
|
||||||
if [ -f "$file_drv" ]; then
|
if [ -f "$file_drv" ]; then
|
||||||
@@ -315,3 +315,30 @@ function drv_rain_sensor_get {
|
|||||||
echo "$vret"
|
echo "$vret"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Legge lo stato le condizioni meteo dal servizio online
|
||||||
|
#
|
||||||
|
# $1 identificativo gpio sensore pioggia
|
||||||
|
#
|
||||||
|
function drv_rain_online_get {
|
||||||
|
local idx="$1"
|
||||||
|
local fnc=`get_driver_callback "rain_online_get" "$idx"`
|
||||||
|
local vret=""
|
||||||
|
|
||||||
|
# Nessun driver definito, esegue la lettura del sensore tramite gpio del raspberry
|
||||||
|
if [ -z "$fnc" ]; then
|
||||||
|
log_write "Driver not found: $idx"
|
||||||
|
message_write "warning" "Driver not found: $idx"
|
||||||
|
# Il driver definito non è stato trovato
|
||||||
|
elif [ "$fnc" == "drvnotfound" ]; then
|
||||||
|
log_write "Driver not found: $idx"
|
||||||
|
message_write "warning" "Driver not found: $idx"
|
||||||
|
else
|
||||||
|
echo "$(date) $fnc arg:$idx" >> "$LOG_OUTPUT_DRV_FILE"
|
||||||
|
vret=`$fnc "$idx"`
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$vret"
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,12 +17,14 @@ function trigger_event {
|
|||||||
case "$EVENT" in
|
case "$EVENT" in
|
||||||
"ev_open_before" | "ev_open_after")
|
"ev_open_before" | "ev_open_after")
|
||||||
ALIAS="$2"
|
ALIAS="$2"
|
||||||
|
CURRENT_EVENT_ALIAS="$ALIAS"
|
||||||
FORCE="$3"
|
FORCE="$3"
|
||||||
$f "$EVENT" "$ALIAS" "$FORCE" `date +%s` &> /dev/null
|
$f "$EVENT" "$ALIAS" "$FORCE" `date +%s` &> /dev/null
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"ev_open_in_before")
|
"ev_open_in_before")
|
||||||
ALIAS="$2"
|
ALIAS="$2"
|
||||||
|
CURRENT_EVENT_ALIAS="$ALIAS"
|
||||||
FORCE="$3"
|
FORCE="$3"
|
||||||
local MINUTE_START="$4"
|
local MINUTE_START="$4"
|
||||||
local MINUTE_STOP="$5"
|
local MINUTE_STOP="$5"
|
||||||
@@ -31,6 +33,7 @@ function trigger_event {
|
|||||||
|
|
||||||
"ev_open_in_after")
|
"ev_open_in_after")
|
||||||
ALIAS="$2"
|
ALIAS="$2"
|
||||||
|
CURRENT_EVENT_ALIAS="$ALIAS"
|
||||||
FORCE="$3"
|
FORCE="$3"
|
||||||
local CRON_START="$4"
|
local CRON_START="$4"
|
||||||
local CRON_STOP="$5"
|
local CRON_STOP="$5"
|
||||||
@@ -39,6 +42,7 @@ function trigger_event {
|
|||||||
|
|
||||||
"ev_close_before" | "ev_close_after")
|
"ev_close_before" | "ev_close_after")
|
||||||
ALIAS="$2"
|
ALIAS="$2"
|
||||||
|
CURRENT_EVENT_ALIAS="$ALIAS"
|
||||||
$f "$EVENT" "$ALIAS" `date +%s` &> /dev/null
|
$f "$EVENT" "$ALIAS" `date +%s` &> /dev/null
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -89,7 +93,13 @@ function trigger_event {
|
|||||||
|
|
||||||
local ec=$?
|
local ec=$?
|
||||||
#echo "$EVENT ec=$ec" >> /tmp/piGarden.testevent
|
#echo "$EVENT ec=$ec" >> /tmp/piGarden.testevent
|
||||||
|
|
||||||
|
#CURRENT_EVENT="$EVENT"
|
||||||
|
#mqtt_status &
|
||||||
|
|
||||||
if [ $ec -ne 0 ]; then
|
if [ $ec -ne 0 ]; then
|
||||||
|
CURRENT_EVENT="$EVENT"
|
||||||
|
mqtt_status &
|
||||||
log_write "Stop events chain for exit code $ec in $current_event_dir/$f"
|
log_write "Stop events chain for exit code $ec in $current_event_dir/$f"
|
||||||
return $ec
|
return $ec
|
||||||
fi
|
fi
|
||||||
@@ -98,6 +108,9 @@ function trigger_event {
|
|||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
CURRENT_EVENT="$EVENT"
|
||||||
|
mqtt_status &
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +1,48 @@
|
|||||||
#
|
#
|
||||||
# Controlla se se piove tramite http://api.wunderground.com/
|
# Esegue controllo meteo tramite servizio online configurato in WEATHER_SERVICE
|
||||||
#
|
#
|
||||||
function check_rain_online {
|
function check_rain_online {
|
||||||
|
|
||||||
|
if [ "$WEATHER_SERVICE" == "none" ]; then
|
||||||
|
log_write "check_rain_online - online service is disable"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
trigger_event "check_rain_online_before" ""
|
trigger_event "check_rain_online_before" ""
|
||||||
|
|
||||||
# http://www.wunderground.com/weather/api/d/docs?d=resources/phrase-glossary&MR=1
|
local local_epoch=`drv_rain_online_get $WEATHER_SERVICE`
|
||||||
$CURL http://api.wunderground.com/api/$WUNDERGROUND_KEY/conditions/q/$WUNDERGROUND_LOCATION.json > $TMP_PATH/check_rain_online.json
|
|
||||||
local weather=`cat $TMP_PATH/check_rain_online.json | $JQ -M ".current_observation.weather"`
|
|
||||||
local current_observation=`cat $TMP_PATH/check_rain_online.json | $JQ -M ".current_observation"`
|
|
||||||
local local_epoch=`cat $TMP_PATH/check_rain_online.json | $JQ -M -r ".current_observation.local_epoch"`
|
|
||||||
local current_state_rain_online=""
|
local current_state_rain_online=""
|
||||||
local last_state_rain_online=`cat "$STATUS_DIR/last_state_rain_online" 2> /dev/null`
|
local last_state_rain_online=`cat "$STATUS_DIR/last_state_rain_online" 2> /dev/null`
|
||||||
#echo $weather
|
local weather="null"
|
||||||
#weather="[Light/Heavy] Drizzle"
|
|
||||||
if [ "$weather" = "null" ]; then
|
if [[ $local_epoch =~ ^-?[0-9]+$ ]]; then
|
||||||
|
if [ $local_epoch -eq 0 ]; then
|
||||||
log_write "check_rain_online - failed read online data"
|
log_write "check_rain_online - failed read online data"
|
||||||
else
|
else
|
||||||
log_write "check_rain_online - weather=$weather, local_epoch=$local_epoch"
|
if [ $local_epoch -gt 0 ]; then
|
||||||
#if [[ "$weather" == *"Clear"* ]]; then
|
|
||||||
#if [[ "$weather" == *"Rain"* ]]; then
|
|
||||||
if [[ "$weather" == *"Rain"* ]] ||
|
|
||||||
[[ "$weather" == *"Snow"* ]] ||
|
|
||||||
[[ "$weather" == *"Hail"* ]] ||
|
|
||||||
[[ "$weather" == *"Ice"* ]] ||
|
|
||||||
[[ "$weather" == *"Thunderstorm"* ]] ||
|
|
||||||
[[ "$weather" == *"Drizzle"* ]];
|
|
||||||
then
|
|
||||||
current_state_rain_online='rain'
|
current_state_rain_online='rain'
|
||||||
echo $local_epoch > "$STATUS_DIR/last_rain_online"
|
echo $local_epoch > "$STATUS_DIR/last_rain_online"
|
||||||
else
|
else
|
||||||
current_state_rain_online='norain'
|
current_state_rain_online='norain'
|
||||||
fi
|
fi
|
||||||
echo "$current_observation" > "$STATUS_DIR/last_weather_online"
|
weather=$(cat "$STATUS_DIR/last_weather_online" | $JQ -M ".weather")
|
||||||
|
|
||||||
|
log_write "check_rain_online - weather=$weather, local_epoch=$local_epoch"
|
||||||
if [ "$current_state_rain_online" != "$last_state_rain_online" ]; then
|
if [ "$current_state_rain_online" != "$last_state_rain_online" ]; then
|
||||||
echo "$current_state_rain_online" > "$STATUS_DIR/last_state_rain_online"
|
echo "$current_state_rain_online" > "$STATUS_DIR/last_state_rain_online"
|
||||||
trigger_event "check_rain_online_change" "$current_state_rain_online" "$weather"
|
trigger_event "check_rain_online_change" "$current_state_rain_online" "$weather"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
log_write "check_rain_online - failed read online data"
|
||||||
|
fi
|
||||||
|
|
||||||
trigger_event "check_rain_online_after" "$current_state_rain_online" "$weather"
|
trigger_event "check_rain_online_after" "$current_state_rain_online" "$weather"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Controlla se se piove tramite sensore
|
# Controlla se se piove tramite sensore
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ function socket_server_command {
|
|||||||
|
|
||||||
log_write "socket connection from: $TCPREMOTEIP - command: $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 $arg7 $arg8"
|
log_write "socket connection from: $TCPREMOTEIP - command: $arg1 $arg2 $arg3 $arg4 $arg5 $arg6 $arg7 $arg8"
|
||||||
|
|
||||||
reset_messages &> /dev/null
|
#reset_messages &> /dev/null
|
||||||
|
|
||||||
case "$arg1" in
|
case "$arg1" in
|
||||||
status)
|
status)
|
||||||
@@ -225,7 +225,7 @@ function socket_server_command {
|
|||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
reset_messages &> /dev/null
|
#reset_messages &> /dev/null
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
216
piGarden.sh
216
piGarden.sh
@@ -63,7 +63,7 @@ function initialize {
|
|||||||
#
|
#
|
||||||
# Elimina i file contenente i messaggi da inserire nel json status
|
# Elimina i file contenente i messaggi da inserire nel json status
|
||||||
#
|
#
|
||||||
function reset_messages {
|
function reset_messages_old {
|
||||||
rm -f "$LAST_INFO_FILE.$!"
|
rm -f "$LAST_INFO_FILE.$!"
|
||||||
rm -f "$LAST_WARNING_FILE.$!"
|
rm -f "$LAST_WARNING_FILE.$!"
|
||||||
rm -f "$LAST_SUCCESS_FILE.$!"
|
rm -f "$LAST_SUCCESS_FILE.$!"
|
||||||
@@ -85,6 +85,8 @@ function ev_open {
|
|||||||
local EVNORAIN=`ev_number2norain $EVNUM`
|
local EVNORAIN=`ev_number2norain $EVNUM`
|
||||||
local EV_IS_REMOTE_VAR=EV"$EVNUM"_REMOTE
|
local EV_IS_REMOTE_VAR=EV"$EVNUM"_REMOTE
|
||||||
local EV_IS_REMOTE=${!EV_IS_REMOTE_VAR}
|
local EV_IS_REMOTE=${!EV_IS_REMOTE_VAR}
|
||||||
|
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" ] && [ "$EVNORAIN" != "1" ]; then
|
||||||
if [[ "$NOT_IRRIGATE_IF_RAIN_ONLINE" -gt 0 && -f $STATUS_DIR/last_rain_online ]]; then
|
if [[ "$NOT_IRRIGATE_IF_RAIN_ONLINE" -gt 0 && -f $STATUS_DIR/last_rain_online ]]; then
|
||||||
@@ -93,8 +95,10 @@ function ev_open {
|
|||||||
local dif=0
|
local dif=0
|
||||||
let "dif = now - last_rain"
|
let "dif = now - last_rain"
|
||||||
if [ $dif -lt $NOT_IRRIGATE_IF_RAIN_ONLINE ]; then
|
if [ $dif -lt $NOT_IRRIGATE_IF_RAIN_ONLINE ]; then
|
||||||
log_write "Solenoid '$1' not open for rain (online check)"
|
|
||||||
message_write "warning" "Solenoid not open for rain"
|
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"
|
||||||
|
log_write "Solenoid '$1' not open for rain (online check)"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -106,8 +110,10 @@ function ev_open {
|
|||||||
local dif=0
|
local dif=0
|
||||||
let "dif = now - last_rain"
|
let "dif = now - last_rain"
|
||||||
if [ $dif -lt $NOT_IRRIGATE_IF_RAIN_SENSOR ]; then
|
if [ $dif -lt $NOT_IRRIGATE_IF_RAIN_SENSOR ]; then
|
||||||
log_write "Solenoid '$1' not open for rain (sensor check)"
|
|
||||||
message_write "warning" "Solenoid not open for rain"
|
message_write "warning" "Solenoid not open for rain"
|
||||||
|
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)"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -122,13 +128,14 @@ function ev_open {
|
|||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
log_write "Solenoid '$1' not open due to external event"
|
log_write "Solenoid '$1' not open due to external event"
|
||||||
message_write 'warning' "Solenoid not open due to external event"
|
message_write 'warning' "Solenoid not open due to external event"
|
||||||
|
mqtt_status
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
lock
|
lock
|
||||||
|
|
||||||
# Gestisce l'apertura dell'elettrovalvola in base alla tipologia (monostabile / bistabile)
|
# Gestisce l'apertura dell'elettrovalvola in base alla tipologia (monostabile / bistabile)
|
||||||
if [ "$EV_MONOSTABLE" == "1" ] || [ "$EV_IS_REMOTE" == "1" ]; then
|
if [ "$EV_MONOSTABLE" == "1" ] || [ "$EV_IS_REMOTE" == "1" ] || [ "$EV_IS_MONOSTABLE" == "1" ]; then
|
||||||
drv_rele_close "$g"
|
drv_rele_close "$g"
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
unlock
|
unlock
|
||||||
@@ -143,12 +150,12 @@ function ev_open {
|
|||||||
|
|
||||||
ev_set_state $EVNUM $state
|
ev_set_state $EVNUM $state
|
||||||
|
|
||||||
|
log_write "Solenoid '$1' open"
|
||||||
|
message_write "success" "Solenoid open"
|
||||||
|
|
||||||
trigger_event "ev_open_after" "$1" "$2"
|
trigger_event "ev_open_after" "$1" "$2"
|
||||||
|
|
||||||
unlock
|
unlock
|
||||||
|
|
||||||
log_write "Solenoid '$1' open"
|
|
||||||
message_write "success" "Solenoid open"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -169,21 +176,25 @@ function ev_open_in {
|
|||||||
if ! [[ $minute_start =~ $re ]] ; then
|
if ! [[ $minute_start =~ $re ]] ; then
|
||||||
echo -e "Time start of irrigation is wrong or not specified"
|
echo -e "Time start of irrigation is wrong or not specified"
|
||||||
message_write "warning" "Time start of irrigation is wrong or not specified"
|
message_write "warning" "Time start of irrigation is wrong or not specified"
|
||||||
|
mqtt_status
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if ! [[ $minute_stop =~ $re ]] ; then
|
if ! [[ $minute_stop =~ $re ]] ; then
|
||||||
echo -e "Time stop of irrigation is wrong or not specified"
|
echo -e "Time stop of irrigation is wrong or not specified"
|
||||||
message_write "warning" "Time stop of irrigation is wrong or not specified"
|
message_write "warning" "Time stop of irrigation is wrong or not specified"
|
||||||
|
mqtt_status
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if [ $minute_stop -lt "1" ] ; then
|
if [ $minute_stop -lt "1" ] ; then
|
||||||
echo -e "Time stop of irrigation is wrong"
|
echo -e "Time stop of irrigation is wrong"
|
||||||
message_write "warning" "Time stop of irrigation is wrong"
|
message_write "warning" "Time stop of irrigation is wrong"
|
||||||
|
mqtt_status
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if [ "empty$alias" == "empty" ]; then
|
if [ "empty$alias" == "empty" ]; then
|
||||||
echo -e "Alias solenoid not specified"
|
echo -e "Alias solenoid not specified"
|
||||||
message_write "warning" "Alias solenoid not specified"
|
message_write "warning" "Alias solenoid not specified"
|
||||||
|
mqtt_status
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -251,13 +262,13 @@ function ev_close {
|
|||||||
|
|
||||||
ev_set_state $EVNUM 0
|
ev_set_state $EVNUM 0
|
||||||
|
|
||||||
|
log_write "Solenoid '$1' close"
|
||||||
|
message_write "success" "Solenoid close"
|
||||||
|
|
||||||
trigger_event "ev_close_after" "$1"
|
trigger_event "ev_close_after" "$1"
|
||||||
|
|
||||||
unlock
|
unlock
|
||||||
|
|
||||||
log_write "Solenoid '$1' close"
|
|
||||||
message_write "success" "Solenoid close"
|
|
||||||
|
|
||||||
cron_del open_in_stop $1 > /dev/null 2>&1
|
cron_del open_in_stop $1 > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,6 +308,20 @@ function log_write {
|
|||||||
# $2 messaggio
|
# $2 messaggio
|
||||||
#
|
#
|
||||||
function message_write {
|
function message_write {
|
||||||
|
local file_message=""
|
||||||
|
if [ "$1" = 'info' ]; then
|
||||||
|
MESSAGE_INFO="$2"
|
||||||
|
elif [ "$1" = "warning" ]; then
|
||||||
|
MESSAGE_WARNING="$2"
|
||||||
|
elif [ "$1" = "success" ]; then
|
||||||
|
MESSAGE_SUCCESS="$2"
|
||||||
|
else
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function message_write_old {
|
||||||
local file_message=""
|
local file_message=""
|
||||||
if [ "$1" = 'info' ]; then
|
if [ "$1" = 'info' ]; then
|
||||||
file_message="$LAST_INFO_FILE.$!"
|
file_message="$LAST_INFO_FILE.$!"
|
||||||
@@ -345,6 +370,7 @@ function gpio_alias2number {
|
|||||||
|
|
||||||
log_write "ERROR solenoid alias not found: $1"
|
log_write "ERROR solenoid alias not found: $1"
|
||||||
message_write "warning" "Solenoid alias not found"
|
message_write "warning" "Solenoid alias not found"
|
||||||
|
mqtt_status
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,6 +390,7 @@ function ev_alias2number {
|
|||||||
|
|
||||||
log_write "ERROR solenoid alias not found: $1"
|
log_write "ERROR solenoid alias not found: $1"
|
||||||
message_write "warning" "Solenoid alias not found"
|
message_write "warning" "Solenoid alias not found"
|
||||||
|
mqtt_status
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,6 +513,12 @@ function json_status {
|
|||||||
local last_success=""
|
local last_success=""
|
||||||
local with_get_cron="0"
|
local with_get_cron="0"
|
||||||
local with_get_cron_open_in="0"
|
local with_get_cron_open_in="0"
|
||||||
|
local current_pid=$!
|
||||||
|
local json_event="\"event\": {\"event\": \"$CURRENT_EVENT\", \"alias\": \"$CURRENT_EVENT_ALIAS\"}"
|
||||||
|
|
||||||
|
if [ "$PARENT_PID" -gt "0" ]; then
|
||||||
|
current_pid=$PARENT_PID
|
||||||
|
fi
|
||||||
|
|
||||||
local vret=""
|
local vret=""
|
||||||
for i in $1 $2 $3 $4 $5 $6
|
for i in $1 $2 $3 $4 $5 $6
|
||||||
@@ -510,7 +543,8 @@ function json_status {
|
|||||||
if [ -n "$json" ]; then
|
if [ -n "$json" ]; then
|
||||||
json="$json,"
|
json="$json,"
|
||||||
fi
|
fi
|
||||||
json="$json\"$i\":{\"name\":\"$av\",\"state\":$sv}"
|
#json="$json\"$i\":{\"name\":\"$av\",\"state\":$sv}"
|
||||||
|
json="$json\"$av\":{\"name\":\"$av\",\"state\":$sv}"
|
||||||
done
|
done
|
||||||
json="\"zones\":{$json}"
|
json="\"zones\":{$json}"
|
||||||
|
|
||||||
@@ -521,15 +555,18 @@ function json_status {
|
|||||||
if [[ ! -z "$last_weather_online" ]]; then
|
if [[ ! -z "$last_weather_online" ]]; then
|
||||||
json_last_weather_online=$last_weather_online
|
json_last_weather_online=$last_weather_online
|
||||||
fi
|
fi
|
||||||
if [ -f "$LAST_INFO_FILE.$!" ]; then
|
#if [ -f "$LAST_INFO_FILE.$current_pid" ]; then
|
||||||
last_info=`cat "$LAST_INFO_FILE.$!"`
|
# last_info=`cat "$LAST_INFO_FILE.$current_pid"`
|
||||||
fi
|
#fi
|
||||||
if [ -f "$LAST_WARNING_FILE.$!" ]; then
|
#if [ -f "$LAST_WARNING_FILE.$current_pid" ]; then
|
||||||
last_warning=`cat "$LAST_WARNING_FILE.$!"`
|
# last_warning=`cat "$LAST_WARNING_FILE.$current_pid"`
|
||||||
fi
|
#fi
|
||||||
if [ -f "$LAST_SUCCESS_FILE.$!" ]; then
|
#if [ -f "$LAST_SUCCESS_FILE.$current_pid" ]; then
|
||||||
last_success=`cat "$LAST_SUCCESS_FILE.$!"`
|
# last_success=`cat "$LAST_SUCCESS_FILE.$current_pid"`
|
||||||
fi
|
#fi
|
||||||
|
last_info="$MESSAGE_INFO"
|
||||||
|
last_warning="$MESSAGE_WARNING"
|
||||||
|
last_success="$MESSAGE_SUCCESS"
|
||||||
local json_last_weather_online="\"last_weather_online\":$json_last_weather_online"
|
local json_last_weather_online="\"last_weather_online\":$json_last_weather_online"
|
||||||
local json_last_rain_sensor="\"last_rain_sensor\":\"$last_rain_sensor\""
|
local json_last_rain_sensor="\"last_rain_sensor\":\"$last_rain_sensor\""
|
||||||
local json_last_rain_online="\"last_rain_online\":\"$last_rain_online\""
|
local json_last_rain_online="\"last_rain_online\":\"$last_rain_online\""
|
||||||
@@ -602,8 +639,9 @@ function json_status {
|
|||||||
json_get_cron_open_in="\"open_in\": {$values_open_in},\"open_in_stop\": {$values_open_in_stop}"
|
json_get_cron_open_in="\"open_in\": {$values_open_in},\"open_in_stop\": {$values_open_in_stop}"
|
||||||
fi
|
fi
|
||||||
local json_cron_open_in="\"cron_open_in\":{$json_get_cron_open_in}"
|
local json_cron_open_in="\"cron_open_in\":{$json_get_cron_open_in}"
|
||||||
|
local json_timestamp="\"timestamp\": $(date +%s)"
|
||||||
|
|
||||||
json="{$json_version,$json,$json_last_weather_online,$json_error,$json_last_info,$json_last_warning,$json_last_success,$json_last_rain_online,$json_last_rain_sensor,$json_cron,$json_cron_open_in}"
|
json="{$json_version,$json_timestamp,$json_event,$json,$json_last_weather_online,$json_error,$json_last_info,$json_last_warning,$json_last_success,$json_last_rain_online,$json_last_rain_sensor,$json_cron,$json_cron_open_in}"
|
||||||
|
|
||||||
echo "$json"
|
echo "$json"
|
||||||
|
|
||||||
@@ -611,6 +649,26 @@ function json_status {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Invia al broker mqtt il json contentente lo stato del sistema
|
||||||
|
#
|
||||||
|
# $1 parent pid (opzionale)
|
||||||
|
#
|
||||||
|
function mqtt_status {
|
||||||
|
|
||||||
|
if [ ! $MQTT_ENABLE -eq 1 ]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$1" ]; then
|
||||||
|
PARENT_PID=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local js=$(json_status)
|
||||||
|
$MOSQUITTO_PUB -h $MQTT_HOST -p $MQTT_PORT -u $MQTT_USER -P $MQTT_PWD -i $MQTT_CLIENT_ID -r -t "$MQTT_TOPIC" -m "$js"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Mostra il i parametri dello script
|
# Mostra il i parametri dello script
|
||||||
#
|
#
|
||||||
@@ -626,6 +684,7 @@ function show_usage {
|
|||||||
echo -e "\t$NAME_SCRIPT ev_status alias show status solenoid"
|
echo -e "\t$NAME_SCRIPT ev_status alias show status solenoid"
|
||||||
echo -e "\t$NAME_SCRIPT ev_status_all show status solenoids"
|
echo -e "\t$NAME_SCRIPT ev_status_all show status solenoids"
|
||||||
echo -e "\t$NAME_SCRIPT json_status [get_cron|get_cron_open_in] show status in json format"
|
echo -e "\t$NAME_SCRIPT json_status [get_cron|get_cron_open_in] show status in json format"
|
||||||
|
echo -e "\t$NAME_SCRIPT mqtt_status send status in json format to mqtt broker"
|
||||||
echo -e "\t$NAME_SCRIPT check_rain_online check rain from http://api.wunderground.com/"
|
echo -e "\t$NAME_SCRIPT check_rain_online check rain from http://api.wunderground.com/"
|
||||||
echo -e "\t$NAME_SCRIPT check_rain_sensor check rain from hardware sensor"
|
echo -e "\t$NAME_SCRIPT check_rain_sensor check rain from hardware sensor"
|
||||||
echo -e "\t$NAME_SCRIPT close_all_for_rain close all solenoid if it's raining"
|
echo -e "\t$NAME_SCRIPT close_all_for_rain close all solenoid if it's raining"
|
||||||
@@ -776,6 +835,94 @@ function exec_reboot {
|
|||||||
trigger_event "exec_reboot_after"
|
trigger_event "exec_reboot_after"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Converte da gradi a direzione
|
||||||
|
#
|
||||||
|
# $1 gradi
|
||||||
|
#
|
||||||
|
function deg2dir {
|
||||||
|
local deg=$(echo $1 | $SED 's/\..*$//')
|
||||||
|
local dir=""
|
||||||
|
|
||||||
|
if [ "$deg" == "null" ]; then
|
||||||
|
echo ""
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# N 348.75 - 11.25
|
||||||
|
if [ $deg -le 11 ]; then
|
||||||
|
dir="North"
|
||||||
|
|
||||||
|
# NNE 11.25 - 33.75
|
||||||
|
elif [ $deg -le 33 ]; then
|
||||||
|
dir="NNE"
|
||||||
|
|
||||||
|
# NE 33.75 - 56.25
|
||||||
|
elif [ $deg -le 56 ]; then
|
||||||
|
dir="NE"
|
||||||
|
|
||||||
|
# ENE 56.25 - 78.75
|
||||||
|
elif [ $deg -le 78 ]; then
|
||||||
|
dir="ENE"
|
||||||
|
|
||||||
|
# E 78.75 - 101.25
|
||||||
|
elif [ $deg -le 101 ]; then
|
||||||
|
dir="East"
|
||||||
|
|
||||||
|
# ESE 101.25 - 123.75
|
||||||
|
elif [ $deg -le 123 ]; then
|
||||||
|
dir="ESE"
|
||||||
|
|
||||||
|
# SE 123.75 - 146.25
|
||||||
|
elif [ $deg -le 146 ]; then
|
||||||
|
dir="SE"
|
||||||
|
|
||||||
|
# SSE 146.25 - 168.75
|
||||||
|
elif [ $deg -le 168 ]; then
|
||||||
|
dir="SSE"
|
||||||
|
|
||||||
|
# S 168.75 - 191.25
|
||||||
|
elif [ $deg -le 191 ]; then
|
||||||
|
dir="South"
|
||||||
|
|
||||||
|
# SSW 191.25 - 213.75
|
||||||
|
elif [ $deg -le 213 ]; then
|
||||||
|
dir="SSW"
|
||||||
|
|
||||||
|
# SW 213.75 - 236.25
|
||||||
|
elif [ $deg -le 236 ]; then
|
||||||
|
dir="SW"
|
||||||
|
|
||||||
|
# WSW 236.25 - 258.75
|
||||||
|
elif [ $deg -le 258 ]; then
|
||||||
|
dir="WSW"
|
||||||
|
|
||||||
|
# W 258.75 - 281.25
|
||||||
|
elif [ $deg -le 281 ]; then
|
||||||
|
dir="West"
|
||||||
|
|
||||||
|
# WNW 281.25 - 303.75
|
||||||
|
elif [ $deg -le 303 ]; then
|
||||||
|
dir="WNW"
|
||||||
|
|
||||||
|
# NW 303.75 - 326.25
|
||||||
|
elif [ $deg -le 326 ]; then
|
||||||
|
dir="NW"
|
||||||
|
|
||||||
|
# NNW 326.25 - 348.75
|
||||||
|
elif [ $deg -le 348 ]; then
|
||||||
|
dir="NNW"
|
||||||
|
|
||||||
|
# N 348.75 - 11.25
|
||||||
|
else
|
||||||
|
dir="North"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $dir
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function debug1 {
|
function debug1 {
|
||||||
. "$DIR_SCRIPT/debug/debug1.sh"
|
. "$DIR_SCRIPT/debug/debug1.sh"
|
||||||
}
|
}
|
||||||
@@ -786,7 +933,7 @@ function debug2 {
|
|||||||
|
|
||||||
VERSION=0
|
VERSION=0
|
||||||
SUB_VERSION=5
|
SUB_VERSION=5
|
||||||
RELEASE_VERSION=5
|
RELEASE_VERSION=12
|
||||||
|
|
||||||
DIR_SCRIPT=`dirname $0`
|
DIR_SCRIPT=`dirname $0`
|
||||||
NAME_SCRIPT=${0##*/}
|
NAME_SCRIPT=${0##*/}
|
||||||
@@ -814,9 +961,17 @@ fi
|
|||||||
. "$DIR_SCRIPT/include/rain.include.sh"
|
. "$DIR_SCRIPT/include/rain.include.sh"
|
||||||
. "$DIR_SCRIPT/include/events.include.sh"
|
. "$DIR_SCRIPT/include/events.include.sh"
|
||||||
|
|
||||||
LAST_INFO_FILE="$STATUS_DIR/last_info"
|
#LAST_INFO_FILE="$STATUS_DIR/last_info"
|
||||||
LAST_WARNING_FILE="$STATUS_DIR/last_warning"
|
#LAST_WARNING_FILE="$STATUS_DIR/last_warning"
|
||||||
LAST_SUCCESS_FILE="$STATUS_DIR/last_success"
|
#LAST_SUCCESS_FILE="$STATUS_DIR/last_success"
|
||||||
|
MESSAGE_INFO=""
|
||||||
|
MESSAGE_WARNING=""
|
||||||
|
MESSAGE_SUCCESS=""
|
||||||
|
|
||||||
|
CURRENT_EVENT=""
|
||||||
|
CURRENT_EVENT_ALIAS=""
|
||||||
|
|
||||||
|
PARENT_PID=0
|
||||||
|
|
||||||
if [ -z $LOG_OUTPUT_DRV_FILE ]; then
|
if [ -z $LOG_OUTPUT_DRV_FILE ]; then
|
||||||
LOG_OUTPUT_DRV_FILE="/dev/null"
|
LOG_OUTPUT_DRV_FILE="/dev/null"
|
||||||
@@ -826,6 +981,11 @@ if [ -z "$EVENT_DIR" ]; then
|
|||||||
EVENT_DIR="$DIR_SCRIPT/events"
|
EVENT_DIR="$DIR_SCRIPT/events"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z $WEATHER_SERVICE ]; then
|
||||||
|
WEATHER_SERVICE="drv:wunderground"
|
||||||
|
elif [ "$WEATHER_SERVICE" != "none" ]; then
|
||||||
|
WEATHER_SERVICE="drv:$WEATHER_SERVICE"
|
||||||
|
fi
|
||||||
|
|
||||||
# Elimina il file di lock se più vecchio di 11 secondi
|
# Elimina il file di lock se più vecchio di 11 secondi
|
||||||
if [ -f "$LOCK_FILE" ]; then
|
if [ -f "$LOCK_FILE" ]; then
|
||||||
@@ -882,6 +1042,10 @@ case "$1" in
|
|||||||
json_status $2 $3 $4 $5 $6
|
json_status $2 $3 $4 $5 $6
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
mqtt_status)
|
||||||
|
mqtt_status $2
|
||||||
|
;;
|
||||||
|
|
||||||
check_rain_online)
|
check_rain_online)
|
||||||
check_rain_online
|
check_rain_online
|
||||||
;;
|
;;
|
||||||
@@ -1023,4 +1187,4 @@ esac
|
|||||||
rm "$TMP_CRON_FILE" 2> /dev/null
|
rm "$TMP_CRON_FILE" 2> /dev/null
|
||||||
rm "$TMP_CRON_FILE-2" 2> /dev/null
|
rm "$TMP_CRON_FILE-2" 2> /dev/null
|
||||||
|
|
||||||
reset_messages &> /dev/null
|
#reset_messages &> /dev/null
|
||||||
|
|||||||
Reference in New Issue
Block a user