node-red-contrib-hik-media-buffer 1.1.126 → 1.1.128
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 +16 -5
- package/package.json +1 -1
package/hik-media-buffer.js
CHANGED
|
@@ -32,8 +32,19 @@ module.exports = function(RED) {
|
|
|
32
32
|
|
|
33
33
|
node.status({fill:"grey", shape:"ring", text:"Inizializzazione..."});
|
|
34
34
|
|
|
35
|
+
// --- FORMATTAZIONE DATA LOCALE (Risolve il bug delle 2 ore di differenza dell'NVR) ---
|
|
35
36
|
function toHikSearchDate(d) {
|
|
36
|
-
|
|
37
|
+
const pad = (num) => String(num).padStart(2, '0');
|
|
38
|
+
|
|
39
|
+
const year = d.getFullYear();
|
|
40
|
+
const month = pad(d.getMonth() + 1);
|
|
41
|
+
const day = pad(d.getDate());
|
|
42
|
+
const hours = pad(d.getHours());
|
|
43
|
+
const minutes = pad(d.getMinutes());
|
|
44
|
+
const seconds = pad(d.getSeconds());
|
|
45
|
+
|
|
46
|
+
// Costruisce la stringa mantenendo l'ora locale del PC/Node-RED (es. 09:53:19Z)
|
|
47
|
+
return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}Z`;
|
|
37
48
|
}
|
|
38
49
|
|
|
39
50
|
// --- 1. PRENDE IL NOME REALE DELLA TELECAMERA DAL DIGITAL PROXY ---
|
|
@@ -125,8 +136,8 @@ module.exports = function(RED) {
|
|
|
125
136
|
if (nowTime - lastTriggerTime[channelID] < 5000) return;
|
|
126
137
|
lastTriggerTime[channelID] = nowTime;
|
|
127
138
|
|
|
128
|
-
node.status({fill:"yellow", shape:"dot", text:`Attesa scrittura NVR (
|
|
129
|
-
await new Promise(resolve => setTimeout(resolve,
|
|
139
|
+
node.status({fill:"yellow", shape:"dot", text:`Attesa scrittura NVR (6s)...`});
|
|
140
|
+
await new Promise(resolve => setTimeout(resolve, 6000));
|
|
130
141
|
|
|
131
142
|
const nvrAuth = new AxiosDigestAuth({ username: node.user, password: node.pass });
|
|
132
143
|
const referenceTime = new Date();
|
|
@@ -137,12 +148,12 @@ module.exports = function(RED) {
|
|
|
137
148
|
node.status({fill:"yellow", shape:"dot", text:`Download Cam ${channelID}...`});
|
|
138
149
|
|
|
139
150
|
const inizioFinestra = new Date(referenceTime.getTime() - (2 * 60 * 1000));
|
|
140
|
-
const fineFinestra = new Date(referenceTime.getTime() + (
|
|
151
|
+
const fineFinestra = new Date(referenceTime.getTime() + (2 * 60 * 1000));
|
|
141
152
|
|
|
142
153
|
const startSearchStr = toHikSearchDate(inizioFinestra);
|
|
143
154
|
const endSearchStr = toHikSearchDate(fineFinestra);
|
|
144
155
|
|
|
145
|
-
node.warn(`[DEBUG HIK] Avvio ricerca video. Canale: ${channelID}. Cerco da: ${
|
|
156
|
+
node.warn(`[DEBUG HIK] Avvio ricerca video. Canale: ${channelID}. Cerco da: ${startSearchStr} a: ${endSearchStr}`);
|
|
146
157
|
|
|
147
158
|
let output = {
|
|
148
159
|
tipo_messaggio: "evento",
|