Merge pull request #1489 from fewieden/feature/weather-module-improvements

WIP: weather module improvements
This commit is contained in:
Michael Teeuw 2018-12-29 10:49:18 +01:00 committed by GitHub
commit b9f75bf7d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,11 @@ WeatherProvider.register("darksky", {
// Not strictly required, but helps for debugging.
providerName: "Dark Sky",
units: {
imperial: 'us',
metric: 'ca'
},
fetchCurrentWeather: function() {
this.fetchData(this.getUrl())
.then(data => {
@ -46,7 +51,8 @@ WeatherProvider.register("darksky", {
// Create a URL from the config and base URL.
getUrl: function() {
return `${this.config.apiBase}${this.config.weatherEndpoint}/${this.config.apiKey}/${this.config.lat},${this.config.lon}`;
var units = this.units[this.config.units] || 'auto';
return `${this.config.apiBase}${this.config.weatherEndpoint}/${this.config.apiKey}/${this.config.lat},${this.config.lon}?units=${units}&lang=${this.config.lang}`;
},
// Implement WeatherDay generator.