Skip to content

Commit

Permalink
catch the error if wrong or no data had been received in the frontend…
Browse files Browse the repository at this point in the history
… now
  • Loading branch information
Tom-Hirschberger committed Dec 1, 2024
1 parent 654981d commit f8334cf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
38 changes: 19 additions & 19 deletions MMM-OpenWeatherForecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,29 +276,29 @@ Module.register("MMM-OpenWeatherForecast", {
socketNotificationReceived(notification, payload) {

if (notification == "OPENWEATHER_FORECAST_DATA" && payload.instanceId == this.identifier) {
if (typeof payload.current !== "undefined"){
//clear animated icon cache
if (this.config.useAnimatedIcons) {
this.clearIcons();
}

//clear animated icon cache
if (this.config.useAnimatedIcons) {
this.clearIcons();
}

//process weather data
this.weatherData = payload;
this.formattedWeatherData = this.processWeatherData();

this.updateDom(this.config.updateFadeSpeed);
//process weather data
this.weatherData = payload;
this.formattedWeatherData = this.processWeatherData();

//broadcast weather update
this.sendNotification("OPENWEATHER_FORECAST_WEATHER_UPDATE", payload);
this.updateDom(this.config.updateFadeSpeed);

//start icon playback
if (this.config.useAnimatedIcons) {
var self = this;
setTimeout(function () {
self.playIcons(self);
}, this.config.updateFadeSpeed + this.config.animatedIconStartDelay);
}
//broadcast weather update
this.sendNotification("OPENWEATHER_FORECAST_WEATHER_UPDATE", payload);

//start icon playback
if (this.config.useAnimatedIcons) {
var self = this;
setTimeout(function () {
self.playIcons(self);
}, this.config.updateFadeSpeed + this.config.animatedIconStartDelay);
}
}
}


Expand Down
4 changes: 3 additions & 1 deletion node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ module.exports = NodeHelper.create({
self.sendSocketNotification("OPENWEATHER_FORECAST_DATA", data);
}
})
.catch(error => Log.error("[MMM-OpenWeatherForecast] " + moment().format("D-MMM-YY HH:mm") + " ** ERROR ** " + error+"\n"+error.stack));
.catch(error => {
Log.error("[MMM-OpenWeatherForecast] " + moment().format("D-MMM-YY HH:mm") + " ** ERROR ** " + error+"\n"+error.stack)
});
}
} else if (notification === "CONFIG") {
self.config = payload
Expand Down

0 comments on commit f8334cf

Please sign in to comment.