Skip to content

Commit

Permalink
started work on new implemntation of Precipitation as succested by @v…
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Hirschberger committed Sep 15, 2024
1 parent d9b2dbb commit 9e1898a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2,725 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
package-lock.json
6 changes: 5 additions & 1 deletion MMM-OpenWeatherForecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Module.register("MMM-OpenWeatherForecast", {
requiresVersion: "2.2.0",

defaults: {
debug: false,
apiBaseURL: "https://api.openweathermap.org/data/2.5/onecall?",
apikey: "",
latitude: "",
Expand Down Expand Up @@ -429,7 +430,10 @@ Module.register("MMM-OpenWeatherForecast", {
}

// --------- Precipitation ---------
fItem.precipitation = this.formatPrecipitation(fData.pop, fData.rain ? fData.rain["1h"] : null, fData.snow ? fData.snow["1h"] : null);
//fItem.precipitation = this.formatPrecipitation(fData.pop, fData.rain ? fData.rain["1h"] : null, fData.snow ? fData.snow["1h"] : null);
var rain = fData.rain ? (Object.hasOwn(fData.rain, "1h") ? fData.rain["1h"] : fData.rain) : null;
var snow = fData.snow ? (Object.hasOwn(fData.snow, "1h") ? fData.snow["1h"] : fData.snow) : null;
fItem.precipitation = this.formatPrecipitation(fData.pop, rain, snow);

// --------- Wind ---------
fItem.wind = (this.formatWind(fData.wind_speed, fData.wind_deg, fData.wind_gust));
Expand Down
8 changes: 7 additions & 1 deletion node_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module.exports = NodeHelper.create({

socketNotificationReceived: function(notification, payload){
if (notification === "OPENWEATHER_FORECAST_GET") {

var self = this;

if (payload.apikey == null || payload.apikey == "") {
Expand All @@ -49,6 +48,11 @@ module.exports = NodeHelper.create({
"&units=" + payload.units +
"&lang=" + payload.language;

if (typeof self.config !== "undefined"){
if (self.config.debug){
console.log(url)
}
}
/*
Update 28-Feb-2021:
The old standby Request library has been deprecated.
Expand All @@ -67,6 +71,8 @@ module.exports = NodeHelper.create({


}
} else if (notification === "CONFIG") {
self.config = config
}
},

Expand Down
Loading

0 comments on commit 9e1898a

Please sign in to comment.