PB script probabilité de pluie

Forum dédié aux problématiques concernant les scripts pour DomoticZ.
Entourez votre code et les logs avec les balises nommées code grâce au bouton <\>.
atlantis007
Messages : 65
Inscription : 11 janv. 2015, 22:31
Localisation : biarritz (64)

PB script probabilité de pluie

Message par atlantis007 »

bonjour a tous

voila j ai problème avec ce script que j ai modifié pour mon installation
le script a été trouve sur ce site

http://domotique.web2diz.net/?p=392

*******************************************************************************************



#######################################################################################
# This script will get weather date from wunderground API and then add the
# propability of rain into domoticz % devices.
# Site : http://domotique.web2diz.net/
# Details : http://domotique.web2diz.net/?p=392
# Source : https://github.com/Sirus10/domoticz/blo ... ability.sh
# License : CC BY-SA 4.0
#
# Usage:
# ./get_rain_probability.sh
#
#######################################################################################
# Setup START
COUNTRY=FRANCE
APIKEY=42f1177dc06dd2db # put your api key here
TOWN=BAYONNE # put your town here
IDX_1h=884 # Update according to your domoticz % divices
IDX_5h=885 # Update according to your domoticz % divices
IDX_12h=886 # Update according to your domoticz % divices
IDX_24h=887 # Update according to your domoticz % divices

DOMO_HTTP=192.168.0.30:8080
# Setup END

curl -f "http://api.wunderground.com/api/$APIKEY ... /$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&param=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&param=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&param=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&param=udevice&idx=$IDX_24h&nvalue=0&svalue="$proba_rain

url=`echo $url |sed "s/ //"`
echo $url
curl -f $url



*****************************************************************************
voila le message d erreur que j obtiens
***************************************************************************

/root/scripts/get_rain_probability.sh: line 21: $'\r': command not found
/root/scripts/get_rain_probability.sh: line 24: $'\r': command not found
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 67815 0 67815 0 0 44157 0 --:--:-- 0:00:01 --:--:-- 46226
/root/scripts/get_rain_probability.sh: line 26: $'\r': command not found
grep: /tmp/weatherBAYONNE.out: No such file or directory
%oba Rain in 1 h :
/root/scripts/get_rain_probability.sh: line 31: $'\r': command not found
/json.htm?type=command&param=udevice&idx=884&nvalue=0&svalue=
curl: (3) Illegal characters found in URL
/root/scripts/get_rain_probability.sh: line 35: $'\r': command not found
grep: /tmp/weatherBAYONNE.out: No such file or directory
%oba Rain in 5 h :
/root/scripts/get_rain_probability.sh: line 40: $'\r': command not found
/json.htm?type=command&param=udevice&idx=885&nvalue=0&svalue=
curl: (3) Illegal characters found in URL
/root/scripts/get_rain_probability.sh: line 44: $'\r': command not found
grep: /tmp/weatherBAYONNE.out: No such file or directory
%obal Rain in 12 h :
/root/scripts/get_rain_probability.sh: line 49: $'\r': command not found
/json.htm?type=command&param=udevice&idx=886&nvalue=0&svalue=
curl: (3) Illegal characters found in URL
/root/scripts/get_rain_probability.sh: line 53: $'\r': command not found
grep: /tmp/weatherBAYONNE.out: No such file or directory
%obal pluie dans 24 h :
/root/scripts/get_rain_probability.sh: line 58: $'\r': command not found
/json.htm?type=command&param=udevice&idx=887&nvalue=0&svalue=
curl: (3) Illegal characters found in URL
root@raspberrypi:~# /root/scripts/get_rain_probability.sh
/root/scripts/get_rain_probability.sh: line 21: $'\r': command not found
/root/scripts/get_rain_probability.sh: line 24: $'\r': command not found
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 67815 0 67815 0 0 69105 0 --:--:-- --:--:-- --:--:-- 78217
/root/scripts/get_rain_probability.sh: line 26: $'\r': command not found
grep: /tmp/weatherBAYONNE.out: No such file or directory
%oba Rain in 1 h :
/root/scripts/get_rain_probability.sh: line 31: $'\r': command not found
/json.htm?type=command&param=udevice&idx=884&nvalue=0&svalue=
curl: (3) Illegal characters found in URL
/root/scripts/get_rain_probability.sh: line 35: $'\r': command not found
grep: /tmp/weatherBAYONNE.out: No such file or directory
%oba Rain in 5 h :
/root/scripts/get_rain_probability.sh: line 40: $'\r': command not found
/json.htm?type=command&param=udevice&idx=885&nvalue=0&svalue=
curl: (3) Illegal characters found in URL
/root/scripts/get_rain_probability.sh: line 44: $'\r': command not found
grep: /tmp/weatherBAYONNE.out: No such file or directory
%obal Rain in 12 h :
/root/scripts/get_rain_probability.sh: line 49: $'\r': command not found
/json.htm?type=command&param=udevice&idx=886&nvalue=0&svalue=
curl: (3) Illegal characters found in URL
/root/scripts/get_rain_probability.sh: line 53: $'\r': command not found
grep: /tmp/weatherBAYONNE.out: No such file or directory
%obal pluie dans 24 h :
/root/scripts/get_rain_probability.sh: line 58: $'\r': command not found
/json.htm?type=command&param=udevice&idx=887&nvalue=0&svalue=
curl: (3) Illegal characters found in URL
root@raspberrypi:~#
********************************************************************************************************

si quel qu un a une idée je suis preneur

merci avance :o
Neutrino
Messages : 2662
Inscription : 10 juil. 2015, 15:42
Localisation : Les Herbiers(85)

Re: PB script probabilité de pluie

Message par Neutrino »

C'est un problème d'encodage, ton fichier est au format DOS et non UNIX.
Ouvre le dans nano, puis fais CTRL+O et ATL+D puis ENTRER pour l'enregistrer au bon format.
Ma maison à plein d'IP ! :mrgreen:
SAV Bonjour. Vous avez vidé le cache ?
atlantis007
Messages : 65
Inscription : 11 janv. 2015, 22:31
Localisation : biarritz (64)

Re: PB script probabilité de pluie

Message par atlantis007 »

MERCI CA MARCHE NICKEL CA FAIT 3 JOURS QUE JE SUIS DESSUS :D
Répondre