node-red-contrib-hik-media-buffer 1.1.68 → 1.1.70

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.
@@ -120,13 +120,13 @@ module.exports = function(RED) {
120
120
  const referenceTime = new Date();
121
121
  const timestamp = Math.floor(referenceTime.getTime() / 1000);
122
122
 
123
- // FUNZIONE 1: FORMATTO IN ORA LOCALE (Es. 2026-06-09T14:30:00)
123
+ // FUNZIONE 1: FORMATTO IN ORA LOCALE (Es. YYYY-MM-DDTHH:mm:ss)
124
124
  const formatLocaleDate = (d) => {
125
125
  const pad = (num) => String(num).padStart(2, '0');
126
126
  return `${d.getFullYear()}-${pad(d.getMonth()+1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
127
127
  };
128
128
 
129
- // FUNZIONE 2: FORMATTO IN ORA UTC (Es. 2026-06-09T12:30:00Z)
129
+ // FUNZIONE 2: FORMATTO IN ORA UTC (Es. YYYY-MM-DDTHH:mm:ssZ)
130
130
  const formatUtcDate = (d) => {
131
131
  const pad = (num) => String(num).padStart(2, '0');
132
132
  return `${d.getUTCFullYear()}-${pad(d.getUTCMonth()+1)}-${pad(d.getUTCDate())}T${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}:${pad(d.getUTCSeconds())}Z`;
@@ -135,13 +135,22 @@ module.exports = function(RED) {
135
135
  node.status({fill:"yellow", shape:"dot", text:`Download Cam ${channelID}...`});
136
136
  const nomeCamera = await getCameraName(channelID);
137
137
 
138
- // Aspettiamo 8 secondi per dare tempo all'Hard Disk di scrivere l'indice
138
+ // Aspettiamo 8 secondi per dare tempo all'Hard Disk di stabilizzare il file temporaneo
139
139
  node.warn(`[warn] [hik-media-buffer:test] Attesa scrittura indice Hard Disk (8s)...`);
140
140
  await new Promise(resolve => setTimeout(resolve, 8000));
141
141
 
142
142
  const baseUrl = `${node.protocol}://${node.host}:${node.port}/ISAPI/ContentMgmt`;
143
143
  const evMinuscolo = evento.toLowerCase();
144
144
 
145
+ // CREIAMO LE FINESTRE TEMPORALI: Dal passato fino a ORA (Senza sforare nel futuro!)
146
+ const oraLocaleRichiesta = new Date(); // Questo è il momento esatto del termine degli 8s
147
+ const startLocale = formatLocaleDate(new Date(oraLocaleRichiesta.getTime() - (90 * 1000))); // 90 secondi fa
148
+ const endLocale = formatLocaleDate(oraLocaleRichiesta); // Esattamente ADESSO
149
+
150
+ const oraUtcRichiesta = new Date();
151
+ const startUtc = formatUtcDate(new Date(oraUtcRichiesta.getTime() - (90 * 1000))); // 90 secondi fa
152
+ const endUtc = formatUtcDate(oraUtcRichiesta); // Esattamente ADESSO
153
+
145
154
  let output = {
146
155
  tipo_messaggio: "evento",
147
156
  nome_cliente: node.name,
@@ -165,6 +174,8 @@ module.exports = function(RED) {
165
174
 
166
175
  node.warn(`[warn] [hik-media-buffer:test] [TENTATIVO 1] Ricerca video in Ora Locale: ${startLocale} -> ${endLocale}`);
167
176
 
177
+ const trackVideoId = (parsedChannel * 100) + 1;
178
+
168
179
  let payloadLocale = {
169
180
  "EventSearchDescription": {
170
181
  "searchID": "BA80CAF2-A1E5-42E3-8624-529C3D6665D7",
@@ -172,7 +183,7 @@ module.exports = function(RED) {
172
183
  "maxResults": 10,
173
184
  "timeSpanList": [{"startTime": startLocale, "endTime": endLocale}],
174
185
  "type": "all",
175
- "channels": [parsedChannel],
186
+ "channels": [trackVideoId],
176
187
  "eventType": "behavior",
177
188
  "behavior": {"behaviorEventType": evMinuscolo}
178
189
  }
@@ -206,7 +217,7 @@ module.exports = function(RED) {
206
217
  "maxResults": 10,
207
218
  "timeSpanList": [{"startTime": startUtc, "endTime": endUtc}],
208
219
  "type": "all",
209
- "channels": [parsedChannel],
220
+ "channels": [trackVideoId],
210
221
  "eventType": "behavior",
211
222
  "behavior": {"behaviorEventType": evMinuscolo}
212
223
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-hik-media-buffer",
3
- "version": "1.1.68",
3
+ "version": "1.1.70",
4
4
  "description": "Ottiene buffer video e immagine da camere Hikvision via ISAPI",
5
5
  "keywords": [
6
6
  "node-red",