Implementato driver subsistem per il controllo delle condizioni meteo tramite servizio online. Implementato driver 'wunderground' per il controllo meteo tramite il servizio wunderground
This commit is contained in:
2
drv/wunderground/README.md
Normal file
2
drv/wunderground/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# Fake driver for sample and testing
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user