diff --git a/conf/piGarden.conf.example b/conf/piGarden.conf.example index 529b70c..bfbf92b 100644 --- a/conf/piGarden.conf.example +++ b/conf/piGarden.conf.example @@ -113,8 +113,10 @@ EV6_ALIAS="6" # EV6_GPIO=24 # Physical 18 - wPi 5 -# Definisci il servizio online da utilizzare per il controllo delle condizioni meteo, puoi scegliere openweathermap oppure wunderground +# 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="" diff --git a/conf/piGarden.conf.remote.example b/conf/piGarden.conf.remote.example index 834a973..d2ff493 100644 --- a/conf/piGarden.conf.remote.example +++ b/conf/piGarden.conf.remote.example @@ -105,8 +105,10 @@ EV4_ALIAS="Giardino_Posteriore_GPIO" # EV4_GPIO="18" -# Definisci il servizio online da utilizzare per il controllo delle condizioni meteo, puoi scegliere openweathermap oppure wunderground +# 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="" diff --git a/conf/piGarden.conf.sonoff_tasmota_http.example b/conf/piGarden.conf.sonoff_tasmota_http.example index caa0438..ba31783 100644 --- a/conf/piGarden.conf.sonoff_tasmota_http.example +++ b/conf/piGarden.conf.sonoff_tasmota_http.example @@ -107,8 +107,10 @@ 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 +# 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="" diff --git a/conf/piGarden.conf.spb16ch.example b/conf/piGarden.conf.spb16ch.example index f74ac80..f177769 100644 --- a/conf/piGarden.conf.spb16ch.example +++ b/conf/piGarden.conf.spb16ch.example @@ -477,8 +477,10 @@ EV128_ALIAS="Zona_128" # EV128_GPIO="drv:spb16ch:128" -# Definisci il servizio online da utilizzare per il controllo delle condizioni meteo, puoi scegliere openweathermap oppure wunderground +# 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="" diff --git a/include/rain.include.sh b/include/rain.include.sh index 08c2b4a..7c1263d 100644 --- a/include/rain.include.sh +++ b/include/rain.include.sh @@ -1,61 +1,13 @@ # -# Controlla se se piove tramite http://api.wunderground.com/ -# -function check_rain_online_old { - - trigger_event "check_rain_online_before" "" - - # 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"` - local current_state_rain_online="" - local last_state_rain_online=`cat "$STATUS_DIR/last_state_rain_online" 2> /dev/null` - #echo $weather - #weather="[Light/Heavy] Drizzle" - if [ "$weather" = "null" ]; then - log_write "check_rain_online - failed read online data" - else - log_write "check_rain_online - weather=$weather, local_epoch=$local_epoch" - #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' - echo $local_epoch > "$STATUS_DIR/last_rain_online" - else - current_state_rain_online='norain' - fi - echo "$current_observation" > "$STATUS_DIR/last_weather_online" - if [ "$current_state_rain_online" != "$last_state_rain_online" ]; then - echo "$current_state_rain_online" > "$STATUS_DIR/last_state_rain_online" - trigger_event "check_rain_online_change" "$current_state_rain_online" "$weather" - fi - fi - - trigger_event "check_rain_online_after" "$current_state_rain_online" "$weather" -} - - - - - - - - - - -# -# Controlla se se piove tramite http://api.wunderground.com/ +# Esegue controllo meteo tramite servizio online configurato in WEATHER_SERVICE # 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" "" local local_epoch=`drv_rain_online_get $WEATHER_SERVICE` diff --git a/piGarden.sh b/piGarden.sh index a59ba34..70e78fe 100755 --- a/piGarden.sh +++ b/piGarden.sh @@ -983,7 +983,7 @@ fi if [ -z $WEATHER_SERVICE ]; then WEATHER_SERVICE="drv:wunderground" -else +elif [ "$WEATHER_SERVICE" != "none" ]; then WEATHER_SERVICE="drv:$WEATHER_SERVICE" fi