This commit is contained in:
fewieden
2018-12-27 19:37:02 +01:00
parent 1920f8158e
commit 10bc326490
7 changed files with 107 additions and 117 deletions

View File

@@ -17,30 +17,30 @@ WeatherProvider.register("darksky", {
fetchCurrentWeather: function() {
this.fetchData(this.getUrl())
.then(data => {
Log.log(data);
if(!data || !data.currently || typeof data.currently.temperature === "undefined") {
// No usable data?
return;
}
var currentWeather = this.generateWeatherDayFromCurrentWeather(data);
this.setCurrentWeather(currentWeather);
}).catch(function(request) {
Log.error("Could not load data!", request);
Log.error("Could not load data ... ", request);
});
},
fetchWeatherForecast: function() {
this.fetchData(this.getUrl())
.then(data => {
Log.log(data);
if(!data || !data.daily || !data.daily.data.length) {
// No usable data?
return;
}
var forecast = this.generateWeatherObjectsFromForecast(data.daily.data);
this.setWeatherForecast(forecast);
}).catch(function(request) {
Log.error("Could not load data!", request);
Log.error("Could not load data ... ", request);
});
},
@@ -99,4 +99,4 @@ WeatherProvider.register("darksky", {
};
return weatherTypes.hasOwnProperty(weatherType) ? weatherTypes[weatherType] : null;
}
});
});