diff --git a/functions.js b/functions.js index dfbfee6..a2eb058 100644 --- a/functions.js +++ b/functions.js @@ -264,24 +264,31 @@ const functions = { tests: { vacuum(gpio) { return new Promise((resolve, reject) => { - if (process.env.ONPI == 'true') { - gpio.read(vacuumPin, (err, status) => { - if (err) reject(err); - resolve(status); - }); - } else { - switch (config.status.vacuum) { - case 0: - resolve(false); - break; - case 1: - resolve(true); - break; - default: - reject('Unable to determine vacuum status.'); - break; + if (config.status.blower == 1) { + if (process.env.ONPI == 'true') { + gpio.read(vacuumPin, (err, status) => { + if (err) reject(err); + config.status.vacuum = status; + resolve(status); + }); + } else { + switch (config.status.vacuum) { + case 0: + resolve(false); + break; + case 1: + resolve(true); + break; + default: + reject('Unable to determine vacuum status.'); + break; + } } + } else { + // If the blower isn't on, the vacuum doesn't matter so always return true + resolve(true); } + }); }, pof(gpio) { @@ -289,6 +296,7 @@ const functions = { if (process.env.ONPI == 'true') { gpio.read(pofPin, (err, status) => { if (err) reject(err); + config.status.pof = status; resolve(status); }); } else { diff --git a/main.js b/main.js index 30d3b04..0b080d4 100644 --- a/main.js +++ b/main.js @@ -124,6 +124,7 @@ async function main(fn, gpio) { } function statusCheck(fn, gpio) { + // Once per cycle, write the config variable to the file so it can be read by the web server fn.commands.writeConfig(); if (config.status.shutdown == 1) { console.log(fn.commands.shutdown(gpio) || 'Shutting down...');