Hallo,
mit folgenden Script lassen sich die Wetterdaten von Wunderground.com abrufen. Voraussetzung ist, das man einen APIKey besitzt.
Die Daten lassen sich nach dieser API konfigurieren.
mfG
Mario
let WGID = "Your Station"; //StationID
let WGKey= "Your APIKey"; //APIKey
let WGUnit= "m"; //Units: m=metric e=english h=hybrid (UK)
let WGUrl = "https://api.weather.com/v2/pws/observations/current?stationId=" + WGID +"&format=json&units=" + WGUnit + "&apiKey=" + WGKey;
Shelly.call("http.get",{url: WGUrl},
function (response, error_code, error_message, ud) {
let weatherData = JSON.parse(response.body);
//print(JSON.stringify(response.body));
print("-----------------------------------------------------------------------------------------");
print("stationID : " , JSON.stringify(weatherData["observations"][0]["stationID"]));
print("obsTimeUtc : " , JSON.stringify(weatherData["observations"][0]["obsTimeUtc"]));
print("obsTimeLocal : " , JSON.stringify(weatherData["observations"][0]["obsTimeLocal"]));
print("neighborhood : " , JSON.stringify(weatherData["observations"][0]["neighborhood"]));
print("softwareType : " , JSON.stringify(weatherData["observations"][0]["softwareType"]));
print("country : " , JSON.stringify(weatherData["observations"][0]["country"]));
print("solarRadiation : " , JSON.stringify(weatherData["observations"][0]["solarRadiation"]));
print("lon : " , JSON.stringify(weatherData["observations"][0]["lon"]));
print("realtimeFrequency : " , JSON.stringify(weatherData["observations"][0]["realtimeFrequency"]));
print("epoch : " , JSON.stringify(weatherData["observations"][0]["epoch"]));
print("lat : " , JSON.stringify(weatherData["observations"][0]["lat"]));
print("uv : " , JSON.stringify(weatherData["observations"][0]["uv"]));
print("winddir : " , JSON.stringify(weatherData["observations"][0]["winddir"]));
print("humidity : " , JSON.stringify(weatherData["observations"][0]["humidity"]));
print("qcStatus : " , JSON.stringify(weatherData["observations"][0]["qcStatus"]));
print("metric.temp : " , JSON.stringify(weatherData["observations"][0]["metric"]["temp"]));
print("metric.heatIndex : " , JSON.stringify(weatherData["observations"][0]["metric"]["heatIndex"]));
print("metric.dewpt : " , JSON.stringify(weatherData["observations"][0]["metric"]["dewpt"]));
print("metric.windChill : " , JSON.stringify(weatherData["observations"][0]["metric"]["windChill"]));
print("metric.windSpeed : " , JSON.stringify(weatherData["observations"][0]["metric"]["windSpeed"]));
print("metric.windGust : " , JSON.stringify(weatherData["observations"][0]["metric"]["windGust"]));
print("metric.pressure : " , JSON.stringify(weatherData["observations"][0]["metric"]["pressure"]));
print("metric.precipRate : " , JSON.stringify(weatherData["observations"][0]["metric"]["precipRate"]));
print("metric.precipTotal : " , JSON.stringify(weatherData["observations"][0]["metric"]["precipTotal"]));
print("metric.elev : " , JSON.stringify(weatherData["observations"][0]["metric"]["elev"]));
print("-----------------------------------------------------------------------------------------");
},
null
);
Alles anzeigen