Better logging and add fun to panel

This commit is contained in:
Skylar Grant 2024-11-30 12:48:26 -05:00
parent ee56a6e620
commit 518f45731a
3 changed files with 15 additions and 8 deletions

View File

@ -21,6 +21,7 @@ while true; do
echo "# 6. Stop Auger Loop #" echo "# 6. Stop Auger Loop #"
echo "# #" echo "# #"
echo "# 7. Restart Auger Loop #" echo "# 7. Restart Auger Loop #"
echo "# 8. Edit ENV Variables #"
echo "###################################" echo "###################################"
echo "# 0. Exit #" echo "# 0. Exit #"
echo "###################################" echo "###################################"
@ -65,6 +66,11 @@ while true; do
echo "Restarting Auger Loop" echo "Restarting Auger Loop"
pm2 restart hestia-emr pm2 restart hestia-emr
;; ;;
8)
echo "Editing ENV Variables"
cd $ROOT_PATH
nano .env
;;
0) 0)
echo "Exiting" echo "Exiting"
exit exit

View File

@ -1,6 +1,6 @@
{ {
"mqtt": { "mqtt": {
"address": "wss://127.0.0.1", "address": "wss://192.168.0.12",
"port": 9001, "port": 9001,
"topics": { "topics": {
"igniter": "hestia/status/igniter", "igniter": "hestia/status/igniter",
@ -62,6 +62,6 @@
"exhaustDelay": 600000 "exhaustDelay": 600000
} }
}, },
"gpioScript": "src/python/gpio_interface.py", "gpioScript": "src/python/fake_gpio_interface.py",
"augerTotalCycleTime": 2000 "augerTotalCycleTime": 2000
} }

View File

@ -47,11 +47,12 @@ module.exports = {
const promises = pins.map(pin => { const promises = pins.map(pin => {
if (pin.mode === 'OUT') { if (pin.mode === 'OUT') {
return gpio.setPin(pin.board, pin.defaultState).then(() => { return gpio.setPin(pin.board, pin.defaultState).then(() => {
stateChanges.push(`Set ${pin.key} pin to ${pin.defaultState}.`); stateChanges.push(` -- Set Defaults: Set ${pin.key} pin to ${pin.defaultState}.`);
state[pin.key].power(comlink, pin.defaultState); state[pin.key].power(comlink, pin.defaultState);
// Wait a second and check the pin states
setTimeout(() => { setTimeout(() => {
gpio.readPin(pin.board).then(pinState => { gpio.readPin(pin.board).then(pinState => {
module.exports.log(`Read Pin: ${pin.key} is ${pinState}`); module.exports.log(`Set Defaults: Confirm Pin: ${pin.key} is ${pinState}`, 'DEBUG');
}).catch(e => console.error(e)); }).catch(e => console.error(e));
}, 1000); }, 1000);
}).catch(e => console.error(e)); }).catch(e => console.error(e));
@ -60,7 +61,7 @@ module.exports = {
const boolState = pinState === '1' ? true : false; const boolState = pinState === '1' ? true : false;
state[pin.key].on = boolState; state[pin.key].on = boolState;
comlink.send(config.mqtt.topics[pin.key], JSON.stringify(state[pin.key])); comlink.send(config.mqtt.topics[pin.key], JSON.stringify(state[pin.key]));
stateChanges.push(`${pin.key}: ${state}`); stateChanges.push(` -- Set Defaults: Read: ${pin.key}: ${pinState} [Old: ${state[pin.key].on}]`);
}).catch(e => console.error(e)); }).catch(e => console.error(e));
} }
}); });
@ -72,10 +73,10 @@ module.exports = {
}); });
}, },
async init(comlink, state) { async init(comlink, state) {
module.exports.log('Resetting all output pins.'); module.exports.log('GPIO Init: Resetting all output pins.');
module.exports.gpio.setDefaults(comlink, state).then((changes) => { module.exports.gpio.setDefaults(comlink, state).then((changes) => {
module.exports.log(changes); module.exports.log(`GPIO Init:\n${changes}`);
}).catch(e => console.error(e)); }).catch(e => console.error(`GPIO Init: ${e}`));
} }
}, },
routines: { routines: {