Added mtnclock support for reading weather.json

This allows the use of owmweather or weather to provide weather updates
to mtnclock.
pull/2561/head
Sam Sorensen 2023-02-05 19:14:35 -07:00
parent f609c6d9a8
commit f4f07806a6
1 changed files with 6 additions and 0 deletions

View File

@ -323,6 +323,11 @@ function setWeather() {
draw(a);
}
function readWeather() {
data = require("Storage").readJSON('weather.json').weather;
require("Storage").write('mtnclock.json', data);
}
const _GB = global.GB;
global.GB = (event) => {
if (event.t==="weather") {
@ -340,6 +345,7 @@ function queueDraw() {
if (drawTimeout) clearTimeout(drawTimeout);
drawTimeout = setTimeout(function() {
drawTimeout = undefined;
readWeather();
setWeather();
queueDraw();
}, 60000 - (Date.now() % 60000));