Changed logging to reduce clutter
This commit is contained in:
parent
4da7fd0fe8
commit
ee56a6e620
@ -50,12 +50,6 @@
|
|||||||
"board": 16,
|
"board": 16,
|
||||||
"bcm": 23,
|
"bcm": 23,
|
||||||
"mode": "IN"
|
"mode": "IN"
|
||||||
},
|
|
||||||
{
|
|
||||||
"key": "vacuum",
|
|
||||||
"board": 22,
|
|
||||||
"bcm": 25,
|
|
||||||
"mode": "IN"
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"power": {
|
"power": {
|
||||||
|
@ -32,10 +32,10 @@ setInterval(() => {
|
|||||||
for (const pin of config.pins) {
|
for (const pin of config.pins) {
|
||||||
// If pin is an input, read it
|
// If pin is an input, read it
|
||||||
if (pin.mode === 'IN') {
|
if (pin.mode === 'IN') {
|
||||||
fn.log(`Sensor Detection Loop: Reading pin ${pin.board}`, 'DEBUG');
|
// fn.log(`Sensor Detection Loop: Reading pin ${pin.board}`, 'DEBUG');
|
||||||
// Read pin
|
// Read pin
|
||||||
gpio.readPin(pin.board).then(state => {
|
gpio.readPin(pin.board).then(state => {
|
||||||
fn.log(`Sensor Detection Loop: Pin ${pin.board} is ${state}`, 'DEBUG');
|
// fn.log(`Sensor Detection Loop: Pin ${pin.board} is ${state}`, 'DEBUG');
|
||||||
// Convert the state from string to boolean
|
// Convert the state from string to boolean
|
||||||
const boolState = state === '1' ? true : false;
|
const boolState = state === '1' ? true : false;
|
||||||
// Compare the state to the last known state
|
// Compare the state to the last known state
|
||||||
@ -44,7 +44,7 @@ setInterval(() => {
|
|||||||
process.psState[pin.key].on = boolState;
|
process.psState[pin.key].on = boolState;
|
||||||
// Send the state to the MQTT broker
|
// Send the state to the MQTT broker
|
||||||
process.comlink.send(config.mqtt.topics[pin.key], JSON.stringify(process.psState[pin.key]));
|
process.comlink.send(config.mqtt.topics[pin.key], JSON.stringify(process.psState[pin.key]));
|
||||||
fn.log(`Sensor Detection Loop: ${pin.key}: ${state}`, 'DEBUG');
|
fn.log(`Sensor Detection Loop: State Change: ${pin.key}: ${state} [Old: ${process.psState[pin.key].on}]`, 'DEBUG');
|
||||||
}
|
}
|
||||||
}).catch(e => fn.log(`Sensor Detection Loop: ${e}`, 'ERROR'));
|
}).catch(e => fn.log(`Sensor Detection Loop: ${e}`, 'ERROR'));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user