owmweather - Get weather on boot if older than refresh period

master
Martin Boonk 2022-07-02 15:24:11 +02:00
parent 37df546df0
commit 27062fdbc0
1 changed files with 8 additions and 4 deletions

View File

@ -11,8 +11,8 @@
"location": "London"
};
var pullWeather = function() {
if (responsePromise){
Bangle.pullOwmWeather = function(force) {
if (!force && responsePromise){
print("Waiting for response");
return;
}
@ -65,10 +65,14 @@
require("weather").emit("update", json.weather);
}
};
let weather = require("Storage").readJSON('weather.json') || {};
if (weather.time + settings.refresh * 1000 * 60 < Date.now()){
Bangle.pullOwmWeather();
}
console.log("Setting interval");
setInterval(() => {
pullWeather();
Bangle.pullOwmWeather();
}, settings.refresh * 1000 * 60);
}
})();