17 Commits

Author SHA1 Message Date
lejubila
a125ff31d8 Aggiornato changelog alla version 0.5.14 2019-09-24 17:12:25 +02:00
lejubila
bb435f0ee6 Merge branch 'rainsensorqty' into develop
Eseguito merge del brench rainsensorqty nel brench develop
2019-09-24 17:06:25 +02:00
lejubila
b8daa7acab Cambiato numero di versione 2019-09-24 17:05:50 +02:00
lejubila
dd289f8b31 Adattato alla versione 0.3.3 i nomi zone presente nelle schedulazione mostrate nello stato in formato json 2019-09-24 16:58:23 +02:00
lejubila
c527702c72 Aggiunto elenco elettrovalvole con relativi alias nello status json 2019-09-01 22:22:42 +02:00
lejubila
b6de96debe Aggiunto api per gestire le schedulazioni di piGardenSched 2019-08-29 19:00:42 +02:00
lejubila
ea681816fe Aggiunto nello status json la lettura delle schedulazioni gestite con piGardenSched 2019-08-25 17:25:12 +02:00
lejubila
8ca698d4ee rimosso alcune linee commentate 2019-08-24 10:04:46 +02:00
lejubila
70943c5f5e Rimosso alcune linee commentate 2019-08-24 09:59:18 +02:00
lejubila
aa9799cdaf Rimosso alcune linee commentate 2019-08-24 09:52:46 +02:00
lejubila
6d4f522f21 Aggiunto changelog per nuova versione, e file di configurazione di esempio per il nuovo driver rainsensorqty 2019-08-12 08:40:55 +02:00
lejubila
51e4391237 Merge branch 'rainsensorqty' into develop 2019-08-12 08:26:28 +02:00
lejubila
aa12f5a8a5 Aggiunto compressione file di log dei driver 2019-06-23 12:44:33 +02:00
lejubila
9d9ef42679 Aggiornato numero versione 2018-11-13 12:47:26 +01:00
lejubila
70c4e063f8 corretto bug su driver openweathermap che in alcuni casi causa una malformazione dello status json e impediva la comunicazione con piGardenWeb 2018-11-13 12:45:28 +01:00
lejubila
4d4b35c3cc corretto bug su driver openweathermap che in alcuni casi causa una malformazione dello status json e impediva la comunicazione con piGardenWeb 2018-11-13 12:43:26 +01:00
lejubila
71e91cc861 Corretto bug che impediva la pubblicazione del topic mqtt per ogni evento 2018-11-12 23:15:34 +01:00
12 changed files with 145 additions and 32 deletions

View File

@@ -1,3 +1,17 @@
# 0.5.14 - 24/09/2019
- Updated rainsensorqty driver to version 0.2.3
- Added api and command for manage piGardenSched scheduling
# 0.5.13 - 12/08/2019
- Added driver rainsensorqty for menage rainfall detection based on quantity
# 0.5.12.1 - 23/06/2019
- Added zip log drver file when exceeding the size limit
# 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

View File

@@ -57,6 +57,9 @@ STAT="/usr/bin/stat"
# # Installare con apt install mosquitto-clients
MOSQUITTO_PUB="/usr/bin/mosquitto_pub"
# Percorso di piGardenSched, se non definito non verranno gestire le schedulazioni di piGardenSched tramite api
#PIGARDENSCHED_PATH="/home/pi/piGardenSched/piGardenSched.sh"
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
# se impostato a 0 il sistema gestirà elettrovalvole bistabili

View File

@@ -57,6 +57,9 @@ STAT="/usr/bin/stat"
# # Installare con apt install mosquitto-clients
MOSQUITTO_PUB="/usr/bin/mosquitto_pub"
# Percorso di piGardenSched, se non definito non verranno gestire le schedulazioni di piGardenSched tramite api
#PIGARDENSCHED_PATH="/home/pi/piGardenSched/piGardenSched.sh"
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
# se impostato a 0 il sistema gestirà elettrovalvole bistabili
@@ -79,15 +82,18 @@ RELE_GPIO_CLOSE=0
RELE_GPIO_OPEN=1
# Id del gpio usato per collegare il sensore di rilevamento pioggia
# attraverso il driver rainsensorqty
RAIN_GPIO="drv:rainsensorqty:25" # Physical 22 - wPi 6
# Valore in ingresso sul gpio definito in RAIN_GPIO che indica lo stato di pioggia
# variabile usata anche da drv:rainsensorqty, se e' a 1, significa che il reed contact e' collegato ad un circuito pull-down, vuol dire che attende l'impulso a 1 per contare le vaschette, normalmente e' a 0.
# se e' a 0, significa che il reed contact e' collegato ad un circuito pull-up, vuol dire che attende l'impulso a 0 per contare le vaschette, normalmente e' a 0.
RAIN_GPIO_STATE=0
RAINSENSORQTY_LOOPSFORSETRAINING=16 # dopo 16 impulsi, 16 vaschette riempite si considera pioggia
RAINSENSORQTY_SECSBETWEENRAINEVENT=10800 # =3h, significa che dopo 3 ore si resetta il numero di vaschette riempire e solo dopo un nuovo ciclo di riempimento si considera una nuova pioggia
RAINSENSORQTY_LOOPSFORSETRAINING=10 # dopo 10 impulsi, 10 vaschette riempite si considera pioggia
RAINSENSORQTY_SECSBETWEENRAINEVENT=10800 # =3h, significa che dopo 3 si resetta il numero di vaschette da riempire e solo dopo il riempimento del numero di vaschette si considera una nuova pioggia
RAINSENSORQTY_MMEACH=0.33 # see RAINSENSORQTY driver readme for details

View File

@@ -57,6 +57,9 @@ STAT="/usr/bin/stat"
# Installare con apt install mosquitto-clients
MOSQUITTO_PUB="/usr/bin/mosquitto_pub"
# Percorso di piGardenSched, se non definito non verranno gestire le schedulazioni di piGardenSched tramite api
#PIGARDENSCHED_PATH="/home/pi/piGardenSched/piGardenSched.sh"
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili

View File

@@ -57,6 +57,9 @@ STAT="/usr/bin/stat"
# # Installare con apt install mosquitto-clients
MOSQUITTO_PUB="/usr/bin/mosquitto_pub"
# Percorso di piGardenSched, se non definito non verranno gestire le schedulazioni di piGardenSched tramite api
#PIGARDENSCHED_PATH="/home/pi/piGardenSched/piGardenSched.sh"
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili

View File

@@ -57,6 +57,9 @@ STAT="/usr/bin/stat"
# Installare con apt install mosquitto-clients
MOSQUITTO_PUB="/usr/bin/mosquitto_pub"
# Percorso di piGardenSched, se non definito non verranno gestire le schedulazioni di piGardenSched tramite api
#PIGARDENSCHED_PATH="/home/pi/piGardenSched/piGardenSched.sh"
# Se impostato con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
# se impostato a 0 il sistema gestirà elettrovalvole bisstabili

View File

@@ -34,11 +34,11 @@ function drv_openweathermap_rain_online_get {
"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"),
"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_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": "--",

4
drv/rainsensorqty/.gitignore vendored Normal file
View File

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

View File

@@ -2,8 +2,8 @@
# Driver rainsensorqty - driver for measure the rain volume
# Author: androtto
# file README.md
# Version: 0.2.0
# Data: 11/Aug/2019
# Version: 0.2.30
# Data: 21/Sep/2019
FILE DI CONFIGURAZIONE /etc/piGarden.conf:

View File

@@ -94,10 +94,12 @@ function trigger_event {
local ec=$?
#echo "$EVENT ec=$ec" >> /tmp/piGarden.testevent
CURRENT_EVENT="$EVENT"
mqtt_status &
#CURRENT_EVENT="$EVENT"
#mqtt_status &
if [ $ec -ne 0 ]; then
CURRENT_EVENT="$EVENT"
mqtt_status &
log_write "Stop events chain for exit code $ec in $current_event_dir/$f"
return $ec
fi
@@ -106,6 +108,9 @@ function trigger_event {
fi
CURRENT_EVENT="$EVENT"
mqtt_status &
}

View File

@@ -205,6 +205,21 @@ function socket_server_command {
;;
cmd_pigardensched)
local vret=""
vret=`cmd_pigardensched $arg2 $arg3 $arg4 $arg5 $arg6`
if [[ ! -z $vret ]]; then
json_error 0 "piGardenSched command failed"
log_write "piGardenSched command failed: $vret"
else
message_write "success" "Schedule set successfull"
json_status
fi
;;
reboot)
message_write "warning" "System reboot is started"
json_status

View File

@@ -223,9 +223,6 @@ function ev_open_in {
trigger_event "ev_open_in_after" "$3" "$4" "$cron_start" "$cron_stop"
#echo $cron_start
#echo $cron_stop
}
@@ -299,6 +296,14 @@ function log_write {
fi
fi
if [ -e "$LOG_OUTPUT_DRV_FILE" ]; then
local actualsize=$($WC -c <"$LOG_OUTPUT_DRV_FILE")
if [ $actualsize -ge $LOG_FILE_MAX_SIZE ]; then
$GZIP $LOG_OUTPUT_DRV_FILE
$MV $LOG_OUTPUT_DRV_FILE.gz $LOG_OUTPUT_DRV_FILE.`date +%Y%m%d%H%M`.gz
fi
fi
echo -e "`date`\t\t$1" >> $LOG_FILE
}
@@ -498,8 +503,9 @@ function list_alias {
#
# Stampa un json contanente lo status della centralina
# $1 .. $6 parametri opzionali
# - get_cron: aggiunge i dati relativi ai crontab delle scehdulazioni di apertura/chisura delle elettrovalvole
# - get_cron: aggiunge i dati relativi ai crontab delle scehdulazioni di apertura/chisura
# - get_cron_open_in: aggiunge i dati relativi ai crontab degli avvii ritardati eseguiti con il comando open_in
# - get_schedule: aggiunge i dati relativi alle schedulazioni di piGardenSched
#
function json_status {
local json=""
@@ -513,6 +519,7 @@ function json_status {
local last_success=""
local with_get_cron="0"
local with_get_cron_open_in="0"
local with_get_schedule="0"
local current_pid=$!
local json_event="\"event\": {\"event\": \"$CURRENT_EVENT\", \"alias\": \"$CURRENT_EVENT_ALIAS\"}"
@@ -531,9 +538,12 @@ function json_status {
with_get_cron_open_in="1"
elif [[ "$i" == get_cron_open_in:* ]]; then
with_get_cron_open_in="${i#get_cron_open_in:}"
elif [ $i = "get_schedule" ] && [[ $PIGARDENSCHED == "1" ]]; then
with_get_schedule="1"
fi
done
local json_ev=""
for i in $(seq $EV_TOTAL)
do
local a=EV"$i"_ALIAS
@@ -543,10 +553,14 @@ function json_status {
if [ -n "$json" ]; then
json="$json,"
fi
#json="$json\"$i\":{\"name\":\"$av\",\"state\":$sv}"
json="$json\"$av\":{\"name\":\"$av\",\"state\":$sv}"
if [ -n "$json_ev" ]; then
json_ev="$json_ev,"
fi
json_ev="$json_ev\"$a\":{\"alias\":\"$av\"}"
done
json="\"zones\":{$json}"
json="\"zones\":{$json},\"ev\":{$json_ev}"
local last_rain_sensor=`cat "$STATUS_DIR/last_rain_sensor" 2> /dev/null`
local last_rain_online=`cat "$STATUS_DIR/last_rain_online" 2> /dev/null`
@@ -555,15 +569,7 @@ function json_status {
if [[ ! -z "$last_weather_online" ]]; then
json_last_weather_online=$last_weather_online
fi
#if [ -f "$LAST_INFO_FILE.$current_pid" ]; then
# last_info=`cat "$LAST_INFO_FILE.$current_pid"`
#fi
#if [ -f "$LAST_WARNING_FILE.$current_pid" ]; then
# last_warning=`cat "$LAST_WARNING_FILE.$current_pid"`
#fi
#if [ -f "$LAST_SUCCESS_FILE.$current_pid" ]; then
# last_success=`cat "$LAST_SUCCESS_FILE.$current_pid"`
#fi
last_info="$MESSAGE_INFO"
last_warning="$MESSAGE_WARNING"
last_success="$MESSAGE_SUCCESS"
@@ -607,6 +613,24 @@ function json_status {
fi
local json_cron="\"cron\":{$json_get_cron}"
local json_get_schedule=""
local json_schedule=""
if [ $with_get_schedule != "0" ]; then
json_get_schedule=""
for scheduled in `$PIGARDENSCHED_PATH sched`
do
local ev=$(echo $scheduled|$CUT -f1 -d";")
local evcomplete="$ev"_ALIAS
local al=${!evcomplete}
local json_get_schedule="\"$ev\": {\"alias\": \"$al\", \"entry\": \"$scheduled\"}, $json_get_schedule"
done
if [[ ! -z $json_get_schedule ]]; then
json_get_schedule="${json_get_schedule::-2}"
fi
local json_schedule=", \"schedule\":{$json_get_schedule}"
fi
local json_get_cron_open_in=""
if [ $with_get_cron_open_in != "0" ]; then
local values_open_in=""
@@ -641,7 +665,7 @@ function json_status {
local json_cron_open_in="\"cron_open_in\":{$json_get_cron_open_in}"
local json_timestamp="\"timestamp\": $(date +%s)"
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}"
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 $json_schedule}"
echo "$json"
@@ -683,7 +707,7 @@ function show_usage {
echo -e "\t$NAME_SCRIPT list_alias view list of aliases 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 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|get_schedule] 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_sensor check rain from hardware sensor"
@@ -715,6 +739,8 @@ function show_usage {
echo -e "\t$NAME_SCRIPT del_cron_close alias remove all crontab for close a solenoid"
echo -e "\t$NAME_SCRIPT get_cron_close alias get all crontab for close a solenoid"
echo -e "\n"
echo -e "\t$NAME_SCRIPT cmd_pigardensched [prm1 [prm2 [prm3]...]] performs a pigardensched command"
echo -e "\n"
echo -e "\t$NAME_SCRIPT debug1 [parameter]|[parameter]|..] Run debug code 1"
echo -e "\t$NAME_SCRIPT debug2 [parameter]|[parameter]|..] Run debug code 2"
}
@@ -835,6 +861,31 @@ function exec_reboot {
trigger_event "exec_reboot_after"
}
#
# Esegue un comando con piGardenSched
#
# $1 parametro 1
# $2 parametro 2
# $3 parametro 3
# $4 parametro 4
# $5 parametro 5
function cmd_pigardensched {
local foo="bar"
if [ $PIGARDENSCHED == 0 ]; then
echo "piGardenSched not configured in piGarden" >&2
log_write "piGardenSched not configured in piGarden"
return
fi
$PIGARDENSCHED_PATH $1 $2 $3 $4 $5
if [ $? -ne 0 ]; then
echo "piGardenSched command failed"
fi
}
#
# Converte da gradi a direzione
@@ -933,7 +984,7 @@ function debug2 {
VERSION=0
SUB_VERSION=5
RELEASE_VERSION=11
RELEASE_VERSION=14
DIR_SCRIPT=`dirname $0`
NAME_SCRIPT=${0##*/}
@@ -961,9 +1012,6 @@ fi
. "$DIR_SCRIPT/include/rain.include.sh"
. "$DIR_SCRIPT/include/events.include.sh"
#LAST_INFO_FILE="$STATUS_DIR/last_info"
#LAST_WARNING_FILE="$STATUS_DIR/last_warning"
#LAST_SUCCESS_FILE="$STATUS_DIR/last_success"
MESSAGE_INFO=""
MESSAGE_WARNING=""
MESSAGE_SUCCESS=""
@@ -987,6 +1035,11 @@ elif [ "$WEATHER_SERVICE" != "none" ]; then
WEATHER_SERVICE="drv:$WEATHER_SERVICE"
fi
PIGARDENSCHED="0"
if [[ -x "$PIGARDENSCHED_PATH" ]]; then
PIGARDENSCHED="1"
fi
# Elimina il file di lock se più vecchio di 11 secondi
if [ -f "$LOCK_FILE" ]; then
max_age_lock_file=11
@@ -1160,6 +1213,10 @@ case "$1" in
get_cron_close $2
;;
cmd_pigardensched)
cmd_pigardensched $2 $3 $4 $5
;;
reboot)
exec_reboot
;;