I have been working on a problem for the past few days. I have searched the forum for answers using my limited knowledge but I was not able to solve my problem.
I'm working on an application that can connect to an ELK alarm system. I'm able to connect to the alarm panel and console.log the status of the panel using this code:
function establishConnection (elkCl) {
elkCl
.connect()
.then(() => client.getArmingStatus())
.then((events) => {
const area1 = events.getAreaStatus(1);
const state = area1.armUpState;
switch (state) {
case 49:
console.log("The system is disarmed");
break;
case 51:
console.log("Exit Delay");
break;
case 52:
console.log("ARMED - NO BYPASS");
break;
case 54:
console.log("ARMED - ZONES BYPASSED");
break;
case 53:
console.log("ARMED - FORCED");
break;
default:
}
})
.then(() => client.disconnect())
.then(() => {
console.log('Done!');
})
.catch((err) => {
console.error(err);
});
}
Instead of console logging the status of the alarm panel, I'm trying set a boolean value to "true/false" depending on the status of the system. I want to use this value in a React application and graphically show alarm systems that are armed/disarmed (red/green).
I have tried:
armingStatus;
switch (state) {
case 49:
armingStatus = false;
but it doesn't work. I have also tried to return the strings instead of console logging them but that doesn't work either. What am I doing wrong? I apologize if this question has already been answered somewhere in the forums. I was not able to find the answer for the past two days.
Thank you all for your help!