node-red-contrib-hikvision-ultimate
Advanced tools
Comparing version 1.0.22 to 1.0.23
@@ -7,2 +7,7 @@ <p align="center"><img src='https://raw.githubusercontent.com/Supergiovane/node-red-contrib-hikvision-ultimate/master/img/logo.png' width="40%"></p> | ||
<p> | ||
<b>Version 1.0.23</b> January 2021<br/> | ||
- FIX: all nodes won't emit a topic property. Has been fixed. | ||
- NEW: you can now filter false alarms in the radar node.<br/> | ||
</p> | ||
<p> | ||
<b>Version 1.0.22</b> December 2020<br/> | ||
@@ -9,0 +14,0 @@ - NEW: you can now choose how much times the node server should try to reconnect to the Hik device, before emitting the connection error on PIN 2. This is useful in case of problematic LANs, like VPN or very slow Wireless 3G connections.<br/> |
@@ -268,3 +268,3 @@ | ||
} catch (error) { | ||
if (node.debug) RED.log.error("Hikvision-config: streamPipeline: " + (error.message || " unknown error")); | ||
if (node.debug) RED.log.error("Hikvision-config: streamPipeline: Please be sure to have the latest Node.JS version installed: " + (error.message || " unknown error")); | ||
} | ||
@@ -271,0 +271,0 @@ |
@@ -7,2 +7,3 @@ | ||
var node = this; | ||
node.topic = config.topic || config.name; | ||
node.server = RED.nodes.getNode(config.server) | ||
@@ -19,2 +20,3 @@ node.reactto = (config.reactto === null || config.reactto === undefined) ? "vmd" : config.reactto.toLowerCase();// Rect to alarm coming from... | ||
if (_msg === null || _msg === undefined) return; | ||
_msg.topic = node.topic; | ||
if (_msg.hasOwnProperty("errorDescription")) { node.send([null, _msg]); return; }; // It's a connection error/restore comunication. | ||
@@ -48,2 +50,3 @@ | ||
oRetMsg.payload = bAlarmStatus; | ||
oRetMsg.topic = _msg.topic; | ||
oRetMsg.channelid = (_msg.payload.hasOwnProperty("channelID") ? _msg.payload.channelID : "0"); | ||
@@ -54,5 +57,5 @@ oRetMsg.description = (_msg.payload.hasOwnProperty("eventDescription") ? _msg.payload.eventDescription : ""); | ||
return; // Find first occurrence, exit. | ||
} | ||
} | ||
} | ||
} | ||
@@ -59,0 +62,0 @@ } |
@@ -7,2 +7,3 @@ | ||
var node = this; | ||
node.topic = config.topic || config.name; | ||
node.server = RED.nodes.getNode(config.server) | ||
@@ -18,2 +19,3 @@ | ||
if (_msg === null || _msg === undefined) return; | ||
_msg.topic = node.topic; | ||
if (_msg.hasOwnProperty("errorDescription")) { node.send([null, _msg]); return; }; // It's a connection error/restore comunication. | ||
@@ -20,0 +22,0 @@ |
@@ -7,2 +7,3 @@ | ||
var node = this; | ||
node.topic = config.topic || config.name; | ||
node.server = RED.nodes.getNode(config.server) | ||
@@ -22,3 +23,4 @@ node.avoidsameplatetime = config.avoidsameplatetime || 20; // Doesn't send the same plate in this timeframe, in seconds. | ||
if (_msg === null || _msg === undefined) return; | ||
if (_msg.hasOwnProperty("errorDescription")) { node.send([null,_msg]); return; }; // It's a connection error/restore comunication. | ||
_msg.topic = node.topic; | ||
if (_msg.hasOwnProperty("errorDescription")) { node.send([null, _msg]); return; }; // It's a connection error/restore comunication. | ||
if (_msg.payload === null || _msg.payload === undefined) return; | ||
@@ -43,3 +45,3 @@ | ||
node.currentPlate = _msg.payload; | ||
node.send([_msg,null]); | ||
node.send([_msg, null]); | ||
try { | ||
@@ -57,3 +59,3 @@ node.setNodeStatus({ fill: "green", shape: "dot", text: "Plate " + _msg.payload }); | ||
this.on('input', function (msg) { | ||
}); | ||
@@ -60,0 +62,0 @@ |
@@ -10,2 +10,3 @@ | ||
var node = this; | ||
node.topic = config.topic || config.name; | ||
node.server = RED.nodes.getNode(config.server) | ||
@@ -89,3 +90,3 @@ node.picture; // Stores the cam image | ||
}).catch(error => { | ||
res.json({ picture: "", width: " !Error getting picture! ", height: " !" + error.message + "! "}); | ||
res.json({ picture: "", width: " !Error getting picture! ", height: " !" + error.message + "! " }); | ||
}); | ||
@@ -123,2 +124,3 @@ } | ||
if (_msg === null || _msg === undefined) return; | ||
_msg.topic = node.topic; | ||
if (_msg.hasOwnProperty("errorDescription")) { node.send([null, _msg]); return; }; // It's a connection error/restore comunication. | ||
@@ -125,0 +127,0 @@ if (_msg.hasOwnProperty("payload")) { |
@@ -5,2 +5,3 @@ module.exports = function (RED) { | ||
var node = this; | ||
node.topic = config.topic || node.name; | ||
node.server = RED.nodes.getNode(config.server) | ||
@@ -18,2 +19,3 @@ node.PTZPreset = (config.PTZPreset === null || config.PTZPreset === undefined) ? "1" : config.PTZPreset; | ||
if (_msg === null || _msg === undefined) return; | ||
_msg.topic = node.topic; | ||
if (_msg.hasOwnProperty("errorDescription")) { node.send([null, _msg]); return; }; // It's a connection error/restore comunication. | ||
@@ -20,0 +22,0 @@ if (_msg.hasOwnProperty("payload")) { |
@@ -7,4 +7,11 @@ | ||
var node = this; | ||
node.topic = config.topic || config.name; | ||
node.server = RED.nodes.getNode(config.server) | ||
node.filterzone = config.filterzone || "0";// Rect to alarm coming from... | ||
node.alarmfilterduration = config.alarmfilterduration !== undefined ? config.alarmfilterduration : 0; | ||
node.alarmfilterperiod = config.alarmfilterperiod !== undefined ? config.alarmfilterperiod : 0; | ||
node.currentAlarmMSG = {}; // Stores the current alarm object | ||
node.total_alarmfilterduration = 0; // stores the total time an alarm has been true in the alarmfilterperiod time. | ||
node.isNodeInAlarm = false; // Stores the current state of the filtered alarm. | ||
node.isRunningTimerFilterPeriod = false; // Indicates wether the period timer is running; | ||
@@ -16,6 +23,43 @@ node.setNodeStatus = ({ fill, shape, text }) => { | ||
// 15/01/2021 start the timer that counts the time the alarm has been true | ||
// ################################### | ||
node.timer_alarmfilterduration = setInterval(() => { | ||
if (node.currentAlarmMSG.hasOwnProperty("payload")) { | ||
if (node.currentAlarmMSG.payload === true) { | ||
node.total_alarmfilterduration += 1; | ||
if (node.isRunningTimerFilterPeriod) node.setNodeStatus({ fill: "red", shape: "ring", text: "Zone " + node.currentAlarmMSG.zone + " pre alert count " + node.total_alarmfilterduration }); | ||
if (node.total_alarmfilterduration >= node.alarmfilterduration) { | ||
if (!node.isNodeInAlarm) { | ||
// Emit alarm | ||
if (node.timer_alarmfilterperiod !== null) clearTimeout(node.timer_alarmfilterperiod); | ||
//node.setNodeStatus({ fill: "yellow", shape: "ring", text: "STOP TimerFilterPeriod" }); | ||
node.isRunningTimerFilterPeriod = false; | ||
node.isNodeInAlarm = true; | ||
node.total_alarmfilterduration = 0; | ||
node.setNodeStatus({ fill: "red", shape: "dot", text: "Zone " + node.currentAlarmMSG.zone + " alarm" }); | ||
node.send([node.currentAlarmMSG, null]); | ||
} else { node.total_alarmfilterduration = 0; } | ||
} | ||
} | ||
} | ||
}, 1000); | ||
// This timer resets the node.total_alarmfilterduration | ||
startTimerFilterPeriod = () => { | ||
//node.setNodeStatus({ fill: "yellow", shape: "ring", text: "START TimerFilterPeriod" }); | ||
node.isRunningTimerFilterPeriod = true; | ||
node.total_alarmfilterduration = 0; | ||
node.timer_alarmfilterperiod = setTimeout(() => { | ||
node.total_alarmfilterduration = 0; | ||
//node.setNodeStatus({ fill: "yellow", shape: "ring", text: "ELAPSED TimerFilterPeriod" }); | ||
node.isRunningTimerFilterPeriod = false; | ||
}, node.alarmfilterperiod * 1000); | ||
} | ||
// ################################### | ||
// Called from config node, to send output to the flow | ||
node.sendPayload = (_msg) => { | ||
if (_msg === null || _msg === undefined) return; | ||
if (_msg.hasOwnProperty("errorDescription")) { node.send([null,_msg]); return; }; // It's a connection error/restore comunication. | ||
_msg.topic = node.topic; | ||
if (_msg.hasOwnProperty("errorDescription")) { node.send([null, _msg]); return; }; // It's a connection error/restore comunication. | ||
// Radar alarm JSON | ||
@@ -53,3 +97,3 @@ /* { | ||
//var oRetMsg = RED.util.cloneMessage(_msg); | ||
if (_msg.hasOwnProperty("payload") | ||
@@ -59,3 +103,4 @@ && _msg.payload.hasOwnProperty("CIDEvent") | ||
&& _msg.payload.CIDEvent.hasOwnProperty("zone")) { | ||
var oRetMsg = {}; // Return message | ||
let oRetMsg = {}; // Return message | ||
oRetMsg.topic = _msg.topic; | ||
oRetMsg.connected = _msg.connected; | ||
@@ -70,3 +115,3 @@ oRetMsg.alarm = _msg.payload; // Put the full alarm description here. | ||
oRetMsg.payload = true; | ||
node.setNodeStatus({ fill: "red", shape: "dot", text: "Zone " + oRetMsg.zone + " alert" }); | ||
node.setNodeStatus({ fill: "red", shape: "ring", text: "Zone " + oRetMsg.zone + " pre alert" }); | ||
break; | ||
@@ -84,3 +129,13 @@ case "3103": | ||
} | ||
node.send([oRetMsg,null]); | ||
node.currentAlarmMSG = oRetMsg; | ||
// Sends the false only in case the isNodeInAlarm is true. | ||
if (oRetMsg.payload === false && node.isNodeInAlarm) { | ||
node.send([oRetMsg, null]); | ||
node.currentAlarmMSG = {}; | ||
node.isNodeInAlarm = false; | ||
} else if (oRetMsg.payload === true && !node.isNodeInAlarm) { | ||
if (!node.isRunningTimerFilterPeriod) { | ||
startTimerFilterPeriod(); | ||
} | ||
} | ||
} | ||
@@ -97,6 +152,8 @@ } | ||
this.on('input', function (msg) { | ||
node.sendPayload(msg); | ||
}); | ||
node.on("close", function (done) { | ||
if (node.timer_alarmfilterduration !== null) clearInterval(node.timer_alarmfilterduration); | ||
if (node.timer_alarmfilterperiod !== null) clearTimeout(node.timer_alarmfilterperiod); | ||
if (node.server) { | ||
@@ -103,0 +160,0 @@ node.server.removeClient(node); |
{ | ||
"name": "node-red-contrib-hikvision-ultimate", | ||
"version": "1.0.22", | ||
"version": "1.0.23", | ||
"description": "A native set of nodes for Hikvision Cameras, Alarms, Radars etc.", | ||
@@ -23,3 +23,3 @@ "author": "Supergiovane (https://github.com/Supergiovane)", | ||
"engines": { | ||
"node": ">=10.0.0" | ||
"node": ">=12.3.0" | ||
}, | ||
@@ -26,0 +26,0 @@ "license": "MIT", |
@@ -20,2 +20,3 @@ | ||
All nodes are capable of auto reconnect if the connection is lost and are able to actively monitor the connection.<br/> | ||
Be sure to have installed **Node.js v12.3.0** or newer (issue a node -v command in a console, to check it out). | ||
@@ -219,2 +220,3 @@ | ||
In an **unknown CID event** arrives from the Radar, the node will output a message containing the CID code, the full alarm and a null payload.</br> | ||
The radar node can filter improper/false alams.</br> | ||
@@ -221,0 +223,0 @@ **Output PIN 1** |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1235422
1214
350