node-red-contrib-hik-media-buffer 1.1.32 → 1.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hik-media-buffer.js +18 -5
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -22,7 +22,7 @@ module.exports = function(RED) {
|
|
|
22
22
|
|
|
23
23
|
let streamRequest = null;
|
|
24
24
|
let isClosing = false;
|
|
25
|
-
let lastTriggerTime =
|
|
25
|
+
let lastTriggerTime = {};
|
|
26
26
|
let nvrOnline = true;
|
|
27
27
|
let statoCamera = {};
|
|
28
28
|
|
|
@@ -111,12 +111,16 @@ module.exports = function(RED) {
|
|
|
111
111
|
// --- DOWNLOAD, SALVATAGGIO, CONVERSIONE E RIMOZIONE DOPO 2 MINUTI ---
|
|
112
112
|
async function downloadMedia(evento, channelID) {
|
|
113
113
|
const camera = node.cameras.find(c => c.channel == channelID);
|
|
114
|
-
const nomeCamera = await getCameraName(camera);
|
|
115
114
|
if (!camera) return;
|
|
116
115
|
|
|
116
|
+
const nomeCamera = await getCameraName(camera);
|
|
117
|
+
|
|
117
118
|
const nowTime = Date.now();
|
|
118
|
-
if
|
|
119
|
-
|
|
119
|
+
if(!lastTriggerTime[camera.ip]){
|
|
120
|
+
lastTriggerTime[camera.ip] = 0;
|
|
121
|
+
}
|
|
122
|
+
if (nowTime - lastTriggerTime[camera.ip] < 5000) return;
|
|
123
|
+
lastTriggerTime[camera.ip] = nowTime;
|
|
120
124
|
|
|
121
125
|
const camAuth = new AxiosDigestAuth({ username: node.user, password: node.camPass });
|
|
122
126
|
const referenceTime = new Date();
|
|
@@ -241,9 +245,18 @@ module.exports = function(RED) {
|
|
|
241
245
|
if (data.includes("active")) {
|
|
242
246
|
const chMatch = data.match(/<channelid>(\d+)<\/channelid>/i);
|
|
243
247
|
if (chMatch) {
|
|
248
|
+
let channelID = chMatch[1];
|
|
249
|
+
|
|
250
|
+
// --- IL TUO CONTROLLO LOGICO ---
|
|
251
|
+
// Se l'host di ascolto coincide con l'IP della telecamera termica (canale 2)
|
|
252
|
+
// e la telecamera restituisce erroneamente canale 1, forziamo il canale a 2
|
|
253
|
+
const camTermica = node.cameras.find(c => c.channel == "2");
|
|
254
|
+
if (camTermica && node.host === camTermica.ip && channelID === "1") {
|
|
255
|
+
channelID = "2";
|
|
256
|
+
}
|
|
244
257
|
let ev = "Unknown";
|
|
245
258
|
for (let e of EventList) { if (data.includes(e.toLowerCase())) { ev = e; break; } }
|
|
246
|
-
downloadMedia(ev,
|
|
259
|
+
downloadMedia(ev, channelID);
|
|
247
260
|
}
|
|
248
261
|
}
|
|
249
262
|
});
|