forked from Sirus10/domoticz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_rain_probability.sh
61 lines (51 loc) · 2.2 KB
/
get_rain_probability.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#######################################################################################
# This script will get weather date from wunderground API and then add the
# rain propability into domoticz % devices.
# Site : http://domotique.web2diz.net/
# Details : http://domotique.web2diz.net/?p=392
# Source : https://github.com/Sirus10/domoticz/blob/master/get_rain_probability.sh
# License : CC BY-SA 4.0
#
# Usage:
# ./get_rain_probability.sh
#
#######################################################################################
# Setup START
COUNTRY=FRANCE
APIKEY= # put your api key here
TOWN=PARIS # put your town here
IDX_1h=144 # Update according to your domoticz % divices
IDX_5h=153 # Update according to your domoticz % divices
IDX_12h=189 # Update according to your domoticz % divices
IDX_24h=190 # Update according to your domoticz % divices
DOMO_HTTP=192.168.1.16:8080
# Setup END
curl -f "http://api.wunderground.com/api/$APIKEY/hourly/lang:FR/q/France/$TOWN.xml" -o /tmp/weather$TOWN.out
x=1 # Hour
proba_rain=`grep "pop" /tmp/weather$TOWN.out | sed "s/<pop>// "|sed "s/<\/pop>//" |awk 'NR==1' `
echo Proba Rain in $x h : $proba_rain %
url="http://$DOMO_HTTP/json.htm?type=command¶m=udevice&idx=$IDX_1h&nvalue=0&svalue="$proba_rain
url=`echo $url |sed "s/ //"`
echo $url
curl -f $url
x=5 # Hour
proba_rain=`grep "pop" /tmp/weather$TOWN.out | sed "s/<pop>// "|sed "s/<\/pop>//" |awk 'NR==5' `
echo Proba Rain in $x h : $proba_rain %
url="http://$DOMO_HTTP/json.htm?type=command¶m=udevice&idx=$IDX_5h&nvalue=0&svalue="$proba_rain
url=`echo $url |sed "s/ //"`
echo $url
curl -f $url
x=12 # Hour
proba_rain=`grep "pop" /tmp/weather$TOWN.out | sed "s/<pop>// "|sed "s/<\/pop>//" |awk 'NR==12' `
echo Probal Rain in $x h : $proba_rain %
url="http://$DOMO_HTTP/json.htm?type=command¶m=udevice&idx=$IDX_12h&nvalue=0&svalue="$proba_rain
url=`echo $url |sed "s/ //"`
echo $url
curl -f $url
x=24 # Hour
proba_rain=`grep "pop" /tmp/weather$TOWN.out | sed "s/<pop>// "|sed "s/<\/pop>//" |awk 'NR==24' `
echo Probal pluie dans $x h : $proba_rain %
url="http://$DOMO_HTTP/json.htm?type=command¶m=udevice&idx=$IDX_24h&nvalue=0&svalue="$proba_rain
url=`echo $url |sed "s/ //"`
echo $url
curl -f $url