script prévision météo

Discussion et échanges de scripts pour la box eedomus

script prévision météo

Messagepar merou_95 » 26 Août 2015 21:51

Je n'ai pas pas reussi à intégrer la prévision météo dans l'eedomus.

Pour résumer j'ai suivi les conseils indiqués sur le site http://www.domo-blog.fr/les-previsions- ... c-eedomus/

La clé et l'xml ont été corretement générés

J'ai créé dans l'eedomus un capteur html

J'ai inséré l'url http://api.worldweatheronline.com/free/ ... orrow&key=<ma clé>

Chemin Xpath = /data/current_condition/temp_C

Je clique sur Test, un message d'erreur est généré de type Valeur lue vide.

Je pense que l'Xpath n'est pas correct, qu'en pensez vous?

Voici le résultat XML

{ "data": { "current_condition": [ {"cloudcover": "0", "FeelsLikeC": "20", "FeelsLikeF": "68", "humidity": "73", "observation_time": "08:41 PM", "precipMM": "0.1", "pressure": "1009", "temp_C": "20", "temp_F": "68", "visibility": "10", "weatherCode": "113", "weatherDesc": [ {"value": "Clear" } ], "weatherIconUrl": [ {"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0008_clear_sky_night.png" } ], "winddir16Point": "SW", "winddirDegree": "220", "windspeedKmph": "31", "windspeedMiles": "19" } ], "request": [ {"query": "Cergy, France", "type": "City" } ], "weather": [ { "astronomy": [ {"moonrise": "06:23 PM", "moonset": "02:57 AM", "sunrise": "06:59 AM", "sunset": "08:47 PM" } ], "date": "2015-08-26", "hourly": [ {"chanceoffog": "0", "chanceoffrost": "0", "chanceofhightemp": "0", "chanceofovercast": "0", "chanceofrain": "18", "chanceofremdry": "0", "chanceofsnow": "0", "chanceofsunshine": "6", "chanceofthunder": "0", "chanceofwindy": "0", "cloudcover": "53", "DewPointC": "15", "DewPointF": "60", "FeelsLikeC": "16", "FeelsLikeF": "61", "HeatIndexC": "16", "HeatIndexF": "61", "humidity": "95", "precipMM": "0.0", "pressure": "1015", "tempC": "18", "tempF": "65", "time": "100", "visibility": "10", "weatherCode": "116", "weatherDesc": [ {"value": "Partly Cloudy" } ], "weatherIconUrl": [ {"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0004_black_low_cloud.png" } ], "WindChillC": "16", "WindChillF": "61", "winddir16Point": "SSW", "winddirDegree": "204", "WindGustKmph": "36", "WindGustMiles": "23", "windspeedKmph": "18", "windspeedMiles": "11" }, {"chanceoffog": "0", "chanceoffrost": "0", "chanceofhightemp": "0", "chanceofovercast": "0", "chanceofrain": "0", "chanceofremdry": "0", "chanceofsnow": "0", "chanceofsunshine": "0", "chanceofthunder": "0", "chanceofwindy": "0", "cloudcover": "73", "DewPointC": "15", "DewPointF": "59", "FeelsLikeC": "15", "FeelsLikeF": "60", "HeatIndexC": "15", "HeatIndexF": "60", "humidity": "97", "precipMM": "0.0", "pressure": "1014", "tempC": "17", "tempF": "62", "time": "400", "visibility": "10", "weatherCode": "119", "weatherDesc": [ {"value": "Cloudy" } ], "weatherIconUrl": [ {"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0004_black_low_cloud.png" } ], "WindChillC": "15", "WindChillF": "60", "winddir16Point": "SSW", "winddirDegree": "198", "WindGustKmph": "33", "WindGustMiles": "21", "windspeedKmph": "15", "windspeedMiles": "9" }, {"chanceoffog": "0", "chanceoffrost": "0", "chanceofhightemp": "0", "chanceofovercast": "26", "chanceofrain": "0", "chanceofremdry": "0", "chanceofsnow": "0", "chanceofsunshine": "0", "chanceofthunder": "0", "chanceofwindy": "0", "cloudcover": "74", "DewPointC": "16", "DewPointF": "60", "FeelsLikeC": "17", "FeelsLikeF": "62", "HeatIndexC": "17", "HeatIndexF": "62", "humidity": "94", "precipMM": "0.0", "pressure": "1014", "tempC": "16", "tempF": "61", "time": "700", "visibility": "10", "weatherCode": "119", "weatherDesc": [ {"value": "Cloudy" } ], "weatherIconUrl": [ {"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0003_white_cloud.png" } ], "WindChillC": "17", "WindChillF": "62", "winddir16Point": "S", "winddirDegree": "188", "WindGustKmph": "26", "WindGustMiles": "16", "windspeedKmph": "13", "windspeedMiles": "8" }, {"chanceoffog": "0", "chanceoffrost": "0", "chanceofhightemp": "0", "chanceofovercast": "0", "chanceofrain": "0", "chanceofremdry": "0", "chanceofsnow": "0", "chanceofsunshine": "99", "chanceofthunder": "0", "chanceofwindy": "0", "cloudcover": "12", "DewPointC": "16", "DewPointF": "61", "FeelsLikeC": "23", "FeelsLikeF": "73", "HeatIndexC": "25", "HeatIndexF": "77", "humidity": "66", "precipMM": "0.0", "pressure": "1013", "tempC": "21", "tempF": "70", "time": "1000", "visibility": "10", "weatherCode": "113", "weatherDesc": [ {"value": "Sunny" } ], "weatherIconUrl": [ {"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png" } ], "WindChillC": "23", "WindChillF": "73", "winddir16Point": "S", "winddirDegree": "185", "WindGustKmph": "31", "WindGustMiles": "19", "windspeedKmph": "18", "windspeedMiles": "11" }, {"chanceoffog": "0", "chanceoffrost": "0", "chanceofhightemp": "98", "chanceofovercast": "0", "chanceofrain": "0", "chanceofremdry": "0", "chanceofsnow": "0", "chanceofsunshine": "98", "chanceofthunder": "0", "chanceofwindy": "0", "cloudcover": "20", "DewPointC": "13", "DewPointF": "56", "FeelsLikeC": "29", "FeelsLikeF": "83", "HeatIndexC": "29", "HeatIndexF": "83", "humidity": "39", "precipMM": "0.0", "pressure": "1010", "tempC": "27", "tempF": "80", "time": "1300", "visibility": "10", "weatherCode": "113", "weatherDesc": [ {"value": "Sunny" } ], "weatherIconUrl": [ {"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png" } ], "WindChillC": "29", "WindChillF": "84", "winddir16Point": "S", "winddirDegree": "179", "WindGustKmph": "43", "WindGustMiles": "27", "windspeedKmph": "26", "windspeedMiles": "16" }, {"chanceoffog": "0", "chanceoffrost": "0", "chanceofhightemp": "99", "chanceofovercast": "0", "chanceofrain": "0", "chanceofremdry": "0", "chanceofsnow": "0", "chanceofsunshine": "97", "chanceofthunder": "0", "chanceofwindy": "0", "cloudcover": "16", "DewPointC": "13", "DewPointF": "55", "FeelsLikeC": "29", "FeelsLikeF": "85", "HeatIndexC": "29", "HeatIndexF": "85", "humidity": "34", "precipMM": "0.0", "pressure": "1008", "tempC": "29", "tempF": "84", "time": "1600", "visibility": "10", "weatherCode": "113", "weatherDesc": [ {"value": "Sunny" } ], "weatherIconUrl": [ {"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0001_sunny.png" } ], "WindChillC": "30", "WindChillF": "86", "winddir16Point": "SSW", "winddirDegree": "196", "WindGustKmph": "45", "WindGustMiles": "28", "windspeedKmph": "27", "windspeedMiles": "17" }, {"chanceoffog": "0", "chanceoffrost": "0", "chanceofhightemp": "0", "chanceofovercast": "0", "chanceofrain": "84", "chanceofremdry": "0", "chanceofsnow": "0", "chanceofsunshine": "0", "chanceofthunder": "0", "chanceofwindy": "0", "cloudcover": "75", "DewPointC": "15", "DewPointF": "60", "FeelsLikeC": "24", "FeelsLikeF": "76", "HeatIndexC": "24", "HeatIndexF": "76", "humidity": "69", "precipMM": "0.3", "pressure": "1007", "tempC": "26", "tempF": "78", "time": "1900", "visibility": "5", "weatherCode": "263", "weatherDesc": [ {"value": "Patchy light drizzle" } ], "weatherIconUrl": [ {"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0009_light_rain_showers.png" } ], "WindChillC": "21", "WindChillF": "70", "winddir16Point": "SW", "winddirDegree": "222", "WindGustKmph": "42", "WindGustMiles": "26", "windspeedKmph": "18", "windspeedMiles": "11" }, {"chanceoffog": "0", "chanceoffrost": "0", "chanceofhightemp": "0", "chanceofovercast": "0", "chanceofrain": "34", "chanceofremdry": "0", "chanceofsnow": "0", "chanceofsunshine": "1", "chanceofthunder": "0", "chanceofwindy": "0", "cloudcover": "100", "DewPointC": "15", "DewPointF": "60", "FeelsLikeC": "19", "FeelsLikeF": "65", "HeatIndexC": "19", "HeatIndexF": "65", "humidity": "82", "precipMM": "0.1", "pressure": "1009", "tempC": "22", "tempF": "72", "time": "2200", "visibility": "10", "weatherCode": "176", "weatherDesc": [ {"value": "Patchy rain nearby" } ], "weatherIconUrl": [ {"value": "http:\/\/cdn.worldweatheronline.net\/images\/wsymbols01_png_64\/wsymbol_0025_light_rain_showers_night.png" } ], "WindChillC": "19", "WindChillF": "65", "winddir16Point": "SW", "winddirDegree": "226", "WindGustKmph": "45", "WindGustMiles": "28", "windspeedKmph": "21", "windspeedMiles": "13" } ], "maxtempC": "29", "maxtempF": "84", "mintempC": "17", "mintempF": "63", "uvIndex": "5" } ] }}
merou_95
 
Messages : 33
Inscription : 07 Août 2015

Re: script prévision météo

Messagepar vva » 27 Août 2015 08:48

Salut,
Ce résultat n'est pas du xml mais du json.
Essaie de remplacer format=json par format=xml dans l'url de ta requête.
vva
 
Messages : 383
Inscription : 12 Juin 2013

Re: script prévision météo

Messagepar xianghua » 27 Août 2015 13:33

L'adresse a changé, c'est api2.worldetc...
Sur ce sujet: viewtopic.php?f=50&t=1631&start=40 j'explique comment faire:

Il suffit de créer un capteur http de mettre cette url http://api2.worldweatheronline.com/free ... er.ashx?q=[VAR1]&format=xml&num_of_days=2&tp=24&lang=fr&key=[VAR2] comme requête.
N'oubliez pas de mettre votre ville dans [VAR1] et votre clé API dans [VAR2]

Exécutez cette requête (avec la ville et la clé) dans votre navigateur et vous aurez le fichier xml.
Pour le xpath, il suffit de suivre le chemin par exemple:
pour avoir le temps en ce moment c'est : /data/current_condition/weatherCode
pour avoir la température en ce moment c'est : /data/current_condition/temp_C

Pour avoir le temps de demain c'est: /data/weather[2]/hourly/weatherCode
xianghua
 
Messages : 305
Inscription : 11 Juil 2015

Re: script prévision météo

Messagepar merou_95 » 27 Août 2015 21:21

Merci beaucoup pour votre aide. C'est mon URL qui n'était pas correcte.
merou_95
 
Messages : 33
Inscription : 07 Août 2015


Retour vers Scripts & Périphériques du store

Qui est en ligne ?

Utilisateurs parcourant ce forum : Aucun utilisateur inscrit et 3 invité(s)