The following code is not executing as expected. Can anyone spot the error?
If I set the hardcoded " || 1" to force the expression to be true, then the doorbell sound rings.
If I set the hardcoded " || 0" to have the evaluator check the UID of the card, it does not work.
The gateway is receiving the following message from the RFID Mot
[10-14-17_17:58:18.724] [LOG] >: [22] RFID UID:90a3e116 BAT:0.98v [RSSI:-49][ACK-sent]
[10-14-17_17:58:18.826] [LOG] post: /home/pi/gateway/data/db/0022_V.bin[1508003898,0.98]
[10-14-17_17:58:18.852] [LOG] post: /home/pi/gateway/data/db/0022_RSSI.bin[1508003898,-49]
[10-14-17_17:58:19.008] [LOG] [22] DB-Updates:1
So the gateway is getting the UID of 90a3e116 as expected.
The metric file should be getting that and mapping the value to "Card 01" then evaluating the event to ring the doorbell when there is a match for Card 01.
exports.metrics = {
RFID_UID : { name:'UID', regexp:/UID:90a3e116/i, value:'Card 01', logValue:1},
RFID_UID : { name:'UID', regexp:/UID:8008e616/i, value:'Card 02', logValue:2},
RFID_UID : { name:'UID', regexp:/UID:xxxx/i, value:'Card 03', logValue:3},
RFID_UID : { name:'UID', regexp:/UID:[0-9a-fA-F]+/i, value:"Unknown Card", logValue:0},
};
//example of overriding an event
exports.events = {
rfidSound : { label:'RFID : Xxx ', icon:'audio', descr:'Play either grant or denysound when RFID card is detected', serverExecute:function(node) { if (node.metrics['UID'] && (node.metrics['UID'].value == 'Card 01' || 0 )) { io.sockets.emit('PLAYSOUND', 'sounds/doorbell.wav'); }; } },
};
So the either the
mapping of the value to "Card 01" is not happening or the evaluation of
node.metrics['UID'].value == 'Card 01' is not triggering as TRUE.
I was thinking that maybe the string compare wasn't behaving properly with strings so I tried switching to strcmp(a,b) but that syntax wasn't accepted. I tried double-quotes instead of single quotes without success. I'm not 100% on the syntax being used here so if there is any advice I would greatly appreciate it.