node-red-node-ademco
Two nodes used to work with the AD2USB Data stream either from a Serial Node or MQTT message.
Installation
$ npm i node-red-node-ademco
Documentation
AdemcoListener Node:
Parses the panel messages from the NuTech AD2USB via a serial port input node or MQTT node, converts it into a JavaScript object and either reports partition state changes or every input message; as defined in the node configuration, into the JavaScript object specified below.
partitionState ={
partitionNumber : 1,
messageLine1 : "",
messageLine2 : "",
lastUpdated : null,
systemState : AlarmStateEnum.NOT_READY,
lastTransitionDate : null,
lastSystemState : AlarmStateEnum.NOT_READY,
panels : [],
zoneFaults : [],
partitionReady : false,
partitionArmedAway : false,
partitionArmedStay : false,
backlight : false,
programmingMode : false,
beepCount : 0,
zoneBypass : false,
linePower : false,
chimeEnabled : false,
alarmOccurred : false,
alarmSounding : false,
batteryLow : false,
delayOff : false,
fireAlarm : false,
zoneFaulted : false,
perimeterOnly : false,
stateChange : false
};
The Partition state Enum Values:
var AlarmStateEnum = {
DISARMED : 0,
NOT_READY : 1,
READY : 2,
ARMED_AWAY : 3,
ARMED_STAY : 4,
ARMED_INSTANT : 5,
ALARM : 6,
FIRE_ALARM : 7
};
AdemcoStatus Node:
Using the current panel message state from the Listener Node, this will either use the message.partion == Partition Number or the Node Configuration to export the current partition state on the output message.payload. Use this node to query the current alarm panel state(s).
Example Flow
[{"id":"a019b186.5fe65","type":"AdemcoStatus","name":"","partition":"2","x":561,"y":426,"z":"88661d46.7799e","wires":[["a328679e.5cd798"]]},{"id":"a328679e.5cd798","type":"debug","name":"","active":true,"console":"false","complete":"true","x":726,"y":425,"z":"88661d46.7799e","wires":[]},{"id":"373bc3f2.c8c43c","type":"inject","name":"","topic":"","payload":"partition","payloadType":"date","repeat":"","crontab":"","once":false,"x":175,"y":425,"z":"88661d46.7799e","wires":[["6f7f728.f90808c"]]},{"id":"6f7f728.f90808c","type":"change","action":"replace","property":"partition","from":"","to":"1","reg":false,"name":"","x":349,"y":425,"z":"88661d46.7799e","wires":[["a019b186.5fe65"]]}]
If you have any questions, just open an issue.
To order a AD2USB Module for your Ademco Alarm Panel
And the Protocol/Strings exported from the Panel
Example Function
Example Nod-Red 'function' that formats Partition State Messages, and routes them according to importance:
var partition = msg.payload;
if( partition !== undefined ) {
var alarmText = "";
alarmText += "Partition ";
alarmText += partition.partitionNumber;
alarmText += " is ";
switch ( partition.systemState ) {
case 0:
alarmText += "DISARMED";
break;
case 1:
alarmText += "NOT READY";
break;
case 2:
alarmText += "DISARMED READY";
break;
case 3:
alarmText += "ARMED AWAY";
break;
case 4:
alarmText += "ARMED STAY";
break;
case 5:
alarmText += "ARMED INSTANT";
break;
case 6:
alarmText += "ALARM";
break;
case 7:
alarmText += "FIRE ALARM";
break;
default:
alarmText += "UNKNOWN";
break;
}
if( partition.systemState >= 6 || partition.systemState == 1 ) {
alarmText += "; ";
alarmText += partition.messageLine1.trim();
alarmText += " ";
alarmText += partition.messageLine2.trim();
}
msg.payload = alarmText;
if( partition.systemState > 2 ) {
return [ null, msg ];
} else {
if ( partition.systemState == 2 && partition.lastSystemState > 2 ) {
return [ null, msg ];
} else {
return [ msg, null ];
}
}
}
return [null, null];