homebridge-weather
Advanced tools
Comparing version 1.6.7 to 1.7.0
20
index.js
@@ -157,5 +157,19 @@ "use strict"; | ||
if (this.type === "min") { | ||
temperature = parseFloat(this.cachedWeatherObj["list"][0]["temp"]["min"]); | ||
// Unfortunately we cannot use the "16 day weather forecast" API but the "5 day / 3 hour forecast" instead. | ||
// this API gives one min/max every 3 hours but we want the daily min/max so we have to iterate over all those data | ||
var min = parseFloat(this.cachedWeatherObj["list"][0]["main"]["temp_min"]); | ||
for (var i = 0, len = this.cachedWeatherObj["list"].length; i < len; i++) { | ||
if (parseFloat(this.cachedWeatherObj["list"][i]["main"]["temp_min"]) < min) { | ||
min = parseFloat(this.cachedWeatherObj["list"][i]["main"]["temp_min"]); | ||
} | ||
} | ||
temperature = min; | ||
} else if (this.type === "max") { | ||
temperature = parseFloat(this.cachedWeatherObj["list"][0]["temp"]["max"]); | ||
var max = parseFloat(this.cachedWeatherObj["list"][0]["main"]["temp_max"]); | ||
for (var i = 0, len = this.cachedWeatherObj["list"].length; i < len; i++) { | ||
if (parseFloat(this.cachedWeatherObj["list"][i]["main"]["temp_max"]) > max) { | ||
max = parseFloat(this.cachedWeatherObj["list"][i]["main"]["temp_max"]); | ||
} | ||
} | ||
temperature = max; | ||
} else { | ||
@@ -184,3 +198,3 @@ temperature = parseFloat(this.cachedWeatherObj["main"]["temp"]); | ||
// Min-/Max-sensors have different endpoint | ||
url += "forecast/daily" | ||
url += "forecast" | ||
} | ||
@@ -187,0 +201,0 @@ |
{ | ||
"name": "homebridge-weather", | ||
"version": "1.6.7", | ||
"version": "1.7.0", | ||
"description": "Homebridge plugin for displaying the weather from openweathermap.org", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
20275
291