node-red-contrib-hik-media-buffer 1.1.97 → 1.1.99

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.
@@ -118,9 +118,17 @@ module.exports = function(RED) {
118
118
  const referenceTime = new Date();
119
119
  const timestamp = Math.floor(referenceTime.getTime() / 1000);
120
120
 
121
- // Nuova finestra temporale larga: cerca da 10 minuti fa a 2 minuti nel futuro per compensare i disallineamenti di orario
122
- const startTime = toJsonDate(new Date(referenceTime.getTime() - (10 * 1000)));
123
- const endTime = toJsonDate(new Date(referenceTime.getTime() + (10 * 1000)));
121
+ // Forziamo l'azzeramento totale dei secondi (:00 e :59) come vuole il database Hikvision
122
+ const dStart = new Date(referenceTime.getTime() - (5 * 60 * 1000)); // 5 minuti fa
123
+ dStart.setSeconds(0, 0); // Forza :00 secondi e 0 millisecondi
124
+
125
+ const dEnd = new Date(referenceTime.getTime() + (2 * 60 * 1000)); // 2 minuti nel futuro
126
+ dEnd.setSeconds(59, 999); // Forza :59 secondi
127
+
128
+ const startTime = toJsonDate(dStart);
129
+ const endTime = toJsonDate(dEnd);
130
+
131
+ node.warn(`[DEBUG TEMPO SANIFICATO] Cerco da: ${startTime} a: ${endTime}`);
124
132
 
125
133
  node.status({fill:"yellow", shape:"dot", text:`Ricerca Evento Cam ${channelID}...`});
126
134
 
@@ -136,21 +144,25 @@ module.exports = function(RED) {
136
144
  let fileDaCancellare = [];
137
145
 
138
146
  try {
139
- // Generiamo il SearchID dinamico per evitare il crash di prima
147
+ // Ripristiniamo il SearchID dinamico
140
148
  const dynamicSearchId = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
141
149
  var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
142
150
  return v.toString(16).toUpperCase();
143
151
  });
144
152
 
145
- // Usiamo l'ID della traccia video reale (es. 201 per il canale 2)
153
+ // Ricostruiamo il JSON IDENTICO a quello intercettato su Chrome che funzionava
146
154
  const searchPayload = {
147
155
  "EventSearchDescription": {
148
156
  "searchID": dynamicSearchId,
149
157
  "searchResultPosition": 0,
150
- "maxResults": 10,
158
+ "maxResults": 30,
151
159
  "timeSpanList": [{ "startTime": startTime, "endTime": endTime }],
152
160
  "type": "all",
153
- "channels": [ parseInt(channelID * 100 + 1) ]
161
+ "channels": [ parseInt(channelID) ], // Ritorniamo al canale puro (es. 2)
162
+ "eventType": "behavior",
163
+ "behavior": {
164
+ "behaviorEventType": evento.toLowerCase() // Spara "linedetection" o "fielddetection"
165
+ }
154
166
  }
155
167
  };
156
168
  const tempJsonPath = path.join(baseStorage, `search_${channelID}_${timestamp}.json`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-hik-media-buffer",
3
- "version": "1.1.97",
3
+ "version": "1.1.99",
4
4
  "description": "Ottiene buffer video e immagine da camere Hikvision via ISAPI",
5
5
  "keywords": [
6
6
  "node-red",