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" "location": "London"
}; };
var pullWeather = function() { Bangle.pullOwmWeather = function(force) {
if (responsePromise){ if (!force && responsePromise){
print("Waiting for response"); print("Waiting for response");
return; return;
} }
@ -66,9 +66,13 @@
} }
}; };
let weather = require("Storage").readJSON('weather.json') || {};
if (weather.time + settings.refresh * 1000 * 60 < Date.now()){
Bangle.pullOwmWeather();
}
console.log("Setting interval"); console.log("Setting interval");
setInterval(() => { setInterval(() => {
pullWeather(); Bangle.pullOwmWeather();
}, settings.refresh * 1000 * 60); }, settings.refresh * 1000 * 60);
} }
})(); })();