Skip to content

Commit 3ec44a6

Browse files
fix: add safety check for empty forecast data
- Prevent crash when forecast.current is undefined or empty - Show loading message instead of attempting to access invalid data
1 parent 3eaa4be commit 3ec44a6

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

MMM-OneCallWeather.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,13 @@ Module.register("MMM-OneCallWeather", {
312312
this.config.decimalSymbol = ".";
313313
}
314314

315+
// Check if we have forecast data
316+
if (!this.forecast || !this.forecast.current || this.forecast.current.length === 0) {
317+
wrapper.innerHTML = this.translate("LOADING");
318+
wrapper.className = "dimmed light small";
319+
return wrapper;
320+
}
321+
315322
// Forecast layout: "rows" - days as rows (vertical list)
316323
if (this.config.forecastLayout === "rows") {
317324
// eslint-disable-next-line prefer-destructuring

0 commit comments

Comments
 (0)