Fixes getting only full day forecasts

This commit is contained in:
oemel09 2020-07-08 10:19:49 +02:00
parent 862bf78e63
commit a1708a1469

View File

@ -297,8 +297,8 @@ Module.register("weatherforecast", {
let numberOfDays; let numberOfDays;
if (this.config.forecastEndpoint === "forecast") { if (this.config.forecastEndpoint === "forecast") {
numberOfDays = this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 5 ? 5 : this.config.maxNumberOfDays; numberOfDays = this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 5 ? 5 : this.config.maxNumberOfDays;
// don't get forecasts for the 6th day, as it would not represent the whole day // don't get forecasts for the next day, as it would not represent the whole day
numberOfDays = numberOfDays * 8 - (Math.floor(new Date().getHours() / 3) % 8); numberOfDays = numberOfDays * 8 - (Math.round(new Date().getHours() / 3) % 8);
} else { } else {
numberOfDays = this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 17 ? 7 : this.config.maxNumberOfDays; numberOfDays = this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 17 ? 7 : this.config.maxNumberOfDays;
} }