node-red-contrib-hikvision-ultimate
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -5,2 +5,6 @@ # node-red-contrib-hikvision-ultimate | ||
<p> | ||
<b>Version 0.0.12 BETA</b> November 2020<br/> | ||
- Added support for devices sending XML as well as for devices sending JSON.<br/> | ||
</p> | ||
<p> | ||
<b>Version 0.0.11 BETA</b> November 2020<br/> | ||
@@ -7,0 +11,0 @@ - Added an option to the ANPR node, to filter repeating plates in a timeframe.<br/> |
@@ -7,3 +7,3 @@ | ||
const AbortController = require('abort-controller'); | ||
const xml2js = require('xml2js').Parser({explicitArray: false}).parseString; | ||
const xml2js = require('xml2js').Parser({ explicitArray: false }).parseString; | ||
@@ -18,2 +18,3 @@ function ANPRconfig(config) { | ||
node.lastPicName = ""; | ||
var controller = null; // Abortcontroller | ||
@@ -33,3 +34,3 @@ node.setAllClientsStatus = ({ fill, shape, text }) => { | ||
var client = new DigestFetch(node.credentials.user, node.credentials.password); // Instantiate the fetch client. | ||
var controller = new AbortController(); // For aborting the stream request | ||
controller = new AbortController(); // For aborting the stream request | ||
var options = { | ||
@@ -85,3 +86,3 @@ // These properties are part of the Fetch Standard | ||
// Invalid body | ||
RED.log.error("ANPR-config: DecodingBody:" + error); | ||
RED.log.info("ANPR-config: DecodingBody: Invalid Json " + sRet); | ||
node.lastPicName = ""; // This raises an error, below. | ||
@@ -171,3 +172,3 @@ oPlates = null; // Set null | ||
} | ||
var controller = new AbortController(); // For aborting the stream request | ||
controller = new AbortController(); // For aborting the stream request | ||
var client = new DigestFetch(node.credentials.user, node.credentials.password); // Instantiate the fetch client. | ||
@@ -214,3 +215,2 @@ var options = { | ||
oRet = result; | ||
}); | ||
@@ -222,2 +222,6 @@ } else { | ||
oRet = JSON.parse(sRet); | ||
}else { | ||
// Invalid body | ||
RED.log.info("ANPR-config: DecodingBodyPlateReader: Invalid Json " + sRet); | ||
oRet = null; | ||
} | ||
@@ -260,2 +264,6 @@ } | ||
node.on('close', function (removed, done) { | ||
try { | ||
controller.abort(); | ||
} catch (error) { } | ||
if (node.initPlateReader !== null) clearTimeout(node.initPlateReader); | ||
done(); | ||
@@ -262,0 +270,0 @@ }); |
@@ -7,3 +7,3 @@ | ||
const AbortController = require('abort-controller'); | ||
const xml2js = require('xml2js').Parser({explicitArray: false}).parseString; | ||
const xml2js = require('xml2js').Parser({ explicitArray: false }).parseString; | ||
@@ -48,3 +48,3 @@ function Hikvisionconfig(config) { | ||
node.startAlarmStream = () => { | ||
var controller = new AbortController(); // For aborting the stream request | ||
controller = new AbortController(); // For aborting the stream request | ||
var client = new DigestFetch(node.credentials.user, node.credentials.password); // Instantiate the fetch client. | ||
@@ -82,2 +82,3 @@ var options = { | ||
body.on('readable', () => { | ||
node.isConnected = true; | ||
@@ -90,2 +91,3 @@ try { | ||
} | ||
//console.log("BANANA " + sRet) | ||
sRet = sRet.replace(/--boundary/g, ''); | ||
@@ -95,6 +97,7 @@ var i = sRet.indexOf("<"); // Get only the XML, starting with "<" | ||
sRet = sRet.substring(i); | ||
// console.log("BANANA SBANANATO " + sRet); | ||
// By xml2js | ||
xml2js(sRet, function (err, result) { | ||
node.nodeClients.forEach(oClient => { | ||
if (result !== undefined) oClient.sendPayload({ topic: oClient.topic || "", payload: result, connected: true }); | ||
if (result !== undefined) oClient.sendPayload({ topic: oClient.topic || "", payload: result.EventNotificationAlert, connected: true }); | ||
}) | ||
@@ -111,2 +114,5 @@ }); | ||
}) | ||
} else { | ||
// Invalid body | ||
RED.log.info("Hikvision-config: DecodingBody: Invalid Json " + sRet); | ||
} | ||
@@ -147,2 +153,3 @@ } | ||
if (node.timerCheckHeartBeat !== null) clearTimeout(node.timerCheckHeartBeat); | ||
if (node.startAlarmStream !== null) clearTimeout(node.startAlarmStream) | ||
done(); | ||
@@ -149,0 +156,0 @@ }); |
@@ -17,5 +17,5 @@ | ||
if (_msg.payload === null) { node.send(_msg); return; }; // If null, then it's disconnected. Avoid processing the event | ||
if (_msg.payload.hasOwnProperty("EventNotificationAlert") | ||
&& _msg.payload.EventNotificationAlert.eventType.toString().toLowerCase() === "videoloss" | ||
&& _msg.payload.EventNotificationAlert.eventState.toString().toLowerCase() === "inactive") { | ||
if (_msg.payload.hasOwnProperty("eventType") | ||
&& _msg.payload.eventType.toString().toLowerCase() === "videoloss" | ||
&& _msg.payload.eventState.toString().toLowerCase() === "inactive") { | ||
// It's a HertBeat, exit. | ||
@@ -22,0 +22,0 @@ node.setNodeStatus({ fill: "green", shape: "ring", text: "Waiting for alert..." }); |
{ | ||
"name": "node-red-contrib-hikvision-ultimate", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "A native set of node for Hikvision Cameras, Alarms, Radars etc.", | ||
@@ -5,0 +5,0 @@ "author": "Supergiovane (https://github.com/Supergiovane)", |
@@ -15,7 +15,7 @@ # node-red-contrib-hikvision-ultimate | ||
## DESCRIPTION | ||
This is a set of nodes to handle ISAPI Hikvision messages. It works with digest authorization as well.<br/> | ||
This is a set of nodes to handle ISAPI Hikvision messages.<br/> | ||
Works with cameras, NVR and also with specialized devices, like Radar (for example DS-PR1-60 and 120).<br/> | ||
Digest authehtication is the default, so it should work with all gears!<br/> | ||
Digest authentication is the default, so it should work with all gears!<br/> | ||
All nodes are capable of auto reconnect if the connection is lost and are able to actively monitor the connection.<br/> | ||
There are currently **only two node**, one that traps the alarms, in RAW mode, and outputs a JSON and the other that outputs the ANPR License Plate numbers.<br/> | ||
There are currently **only two nodes**, one that traps the alarms, in RAW mode, and outputs a JSON and the other that outputs the ANPR License Plate numbers.<br/> | ||
@@ -31,3 +31,2 @@ ***THIS NODESET IS IN BETA. E' ancora brutto, ma funziona.***<br/> | ||
<br/> | ||
<br/> | ||
@@ -40,4 +39,2 @@ ## - RAW Alarm Node | ||
<br/> | ||
<br/> | ||
<br/> | ||
@@ -50,4 +47,5 @@ ## - ANPR (License Plate) Node | ||
**Output message** | ||
The node outputs this msg.</br> | ||
The payload is the license plate number, plus there is another property "plate" where you can find other useful informations.</br> | ||
The payload contains the license plate number and the property "plate" contains other useful informations.</br> | ||
@@ -54,0 +52,0 @@ ```javascript |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
304655
518
71