Aggiunto nello status json la lettura delle schedulazioni gestite con piGardenSched
This commit is contained in:
@@ -57,6 +57,9 @@ STAT="/usr/bin/stat"
|
|||||||
# # Installare con apt install mosquitto-clients
|
# # Installare con apt install mosquitto-clients
|
||||||
MOSQUITTO_PUB="/usr/bin/mosquitto_pub"
|
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 con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
|
||||||
# se impostato a 0 il sistema gestirà elettrovalvole bistabili
|
# se impostato a 0 il sistema gestirà elettrovalvole bistabili
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ STAT="/usr/bin/stat"
|
|||||||
# # Installare con apt install mosquitto-clients
|
# # Installare con apt install mosquitto-clients
|
||||||
MOSQUITTO_PUB="/usr/bin/mosquitto_pub"
|
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 con il valore 1, indica che il sistema gestisce elettrovalvole monostabili,
|
||||||
# se impostato a 0 il sistema gestirà elettrovalvole bistabili
|
# se impostato a 0 il sistema gestirà elettrovalvole bistabili
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ STAT="/usr/bin/stat"
|
|||||||
# Installare con apt install mosquitto-clients
|
# Installare con apt install mosquitto-clients
|
||||||
MOSQUITTO_PUB="/usr/bin/mosquitto_pub"
|
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 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
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ STAT="/usr/bin/stat"
|
|||||||
# # Installare con apt install mosquitto-clients
|
# # Installare con apt install mosquitto-clients
|
||||||
MOSQUITTO_PUB="/usr/bin/mosquitto_pub"
|
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 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
|
||||||
|
|||||||
@@ -57,6 +57,9 @@ STAT="/usr/bin/stat"
|
|||||||
# Installare con apt install mosquitto-clients
|
# Installare con apt install mosquitto-clients
|
||||||
MOSQUITTO_PUB="/usr/bin/mosquitto_pub"
|
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 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
|
||||||
|
|||||||
35
piGarden.sh
35
piGarden.sh
@@ -503,8 +503,9 @@ function list_alias {
|
|||||||
#
|
#
|
||||||
# Stampa un json contanente lo status della centralina
|
# Stampa un json contanente lo status della centralina
|
||||||
# $1 .. $6 parametri opzionali
|
# $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_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 {
|
function json_status {
|
||||||
local json=""
|
local json=""
|
||||||
@@ -518,6 +519,7 @@ 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 with_get_schedule="0"
|
||||||
local current_pid=$!
|
local current_pid=$!
|
||||||
local json_event="\"event\": {\"event\": \"$CURRENT_EVENT\", \"alias\": \"$CURRENT_EVENT_ALIAS\"}"
|
local json_event="\"event\": {\"event\": \"$CURRENT_EVENT\", \"alias\": \"$CURRENT_EVENT_ALIAS\"}"
|
||||||
|
|
||||||
@@ -536,6 +538,8 @@ function json_status {
|
|||||||
with_get_cron_open_in="1"
|
with_get_cron_open_in="1"
|
||||||
elif [[ "$i" == get_cron_open_in:* ]]; then
|
elif [[ "$i" == get_cron_open_in:* ]]; then
|
||||||
with_get_cron_open_in="${i#get_cron_open_in:}"
|
with_get_cron_open_in="${i#get_cron_open_in:}"
|
||||||
|
elif [ $i = "get_schedule" ] && [[ $PIGARDENSCHED == "1" ]]; then
|
||||||
|
with_get_schedule="1"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -548,7 +552,6 @@ 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\"$av\":{\"name\":\"$av\",\"state\":$sv}"
|
json="$json\"$av\":{\"name\":\"$av\",\"state\":$sv}"
|
||||||
done
|
done
|
||||||
json="\"zones\":{$json}"
|
json="\"zones\":{$json}"
|
||||||
@@ -604,6 +607,23 @@ function json_status {
|
|||||||
fi
|
fi
|
||||||
local json_cron="\"cron\":{$json_get_cron}"
|
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 al=${!ev}
|
||||||
|
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=""
|
local json_get_cron_open_in=""
|
||||||
if [ $with_get_cron_open_in != "0" ]; then
|
if [ $with_get_cron_open_in != "0" ]; then
|
||||||
local values_open_in=""
|
local values_open_in=""
|
||||||
@@ -638,7 +658,7 @@ function json_status {
|
|||||||
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)"
|
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"
|
echo "$json"
|
||||||
|
|
||||||
@@ -680,7 +700,7 @@ function show_usage {
|
|||||||
echo -e "\t$NAME_SCRIPT list_alias view list of aliases solenoid"
|
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 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|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 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"
|
||||||
@@ -930,7 +950,7 @@ function debug2 {
|
|||||||
|
|
||||||
VERSION=0
|
VERSION=0
|
||||||
SUB_VERSION=5
|
SUB_VERSION=5
|
||||||
RELEASE_VERSION=13
|
RELEASE_VERSION=14
|
||||||
|
|
||||||
DIR_SCRIPT=`dirname $0`
|
DIR_SCRIPT=`dirname $0`
|
||||||
NAME_SCRIPT=${0##*/}
|
NAME_SCRIPT=${0##*/}
|
||||||
@@ -981,6 +1001,11 @@ elif [ "$WEATHER_SERVICE" != "none" ]; then
|
|||||||
WEATHER_SERVICE="drv:$WEATHER_SERVICE"
|
WEATHER_SERVICE="drv:$WEATHER_SERVICE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
PIGARDENSCHED="0"
|
||||||
|
if [[ -x "$PIGARDENSCHED_PATH" ]]; then
|
||||||
|
PIGARDENSCHED="1"
|
||||||
|
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
|
||||||
max_age_lock_file=11
|
max_age_lock_file=11
|
||||||
|
|||||||
Reference in New Issue
Block a user