owmweather - Get weather on boot if older than refresh period
parent
37df546df0
commit
27062fdbc0
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
@ -65,10 +65,14 @@
|
||||||
require("weather").emit("update", json.weather);
|
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");
|
console.log("Setting interval");
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
pullWeather();
|
Bangle.pullOwmWeather();
|
||||||
}, settings.refresh * 1000 * 60);
|
}, settings.refresh * 1000 * 60);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue