From 745a5f037661651f4eeb4636e19c1a1e0c8488e0 Mon Sep 17 00:00:00 2001 From: rejas Date: Sun, 1 Aug 2021 09:39:07 +0200 Subject: [PATCH] Move ignoreToday logic into template to fix undefined forecast --- modules/default/weather/forecast.njk | 7 +++++-- modules/default/weather/weather.js | 4 ---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/default/weather/forecast.njk b/modules/default/weather/forecast.njk index 92a575cf..32a2e4a6 100644 --- a/modules/default/weather/forecast.njk +++ b/modules/default/weather/forecast.njk @@ -2,6 +2,9 @@ {% set numSteps = forecast | calcNumSteps %} {% set currentStep = 0 %} + {% if config.ignoreToday %} + {% set forecast = forecast.splice(1) %} + {% endif %} {% set forecast = forecast.slice(0, numSteps) %} {% for f in forecast %} @@ -20,10 +23,10 @@ {{ f.minTemperature | roundValue | unit("temperature") | decimalSymbol }} {% if config.showPrecipitationAmount %} - {% if f.precipitationUnits %} + {% if f.precipitationUnits %} + {% else %}
{{ f.precipitation }}{{ f.precipitationUnits }} - {{ f.precipitation | unit("precip") }} diff --git a/modules/default/weather/weather.js b/modules/default/weather/weather.js index 3386277c..62182211 100644 --- a/modules/default/weather/weather.js +++ b/modules/default/weather/weather.js @@ -132,10 +132,6 @@ Module.register("weather", { getTemplateData: function () { const forecast = this.weatherProvider.weatherForecast(); - if (this.config.ignoreToday) { - forecast.splice(0, 1); - } - return { config: this.config, current: this.weatherProvider.currentWeather(),