node-red-contrib-knx-ultimate 1.3.19 → 1.3.20

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/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  <br/>
6
6
  <p>
7
+ <b>Version 1.3.20</b> - January 2022<br/>
8
+ - NEW: Telegram out queue TTL: as soon as KNX-Ultimate detects a connection loss, it will retain the telegrams sent to the BUS during the disconnection. After the reconnection, KNX-Ultimate will send the retained queue.<br/>
9
+ </p>
10
+ <p>
7
11
  <b>Version 1.3.19</b> - January 2022<br/>
8
12
  - NEW: Added Datapoint 14.058 Pressure (Pa).<br/>
9
13
  - Added some more description while disconnecting from the BUS.<br/>
@@ -883,7 +883,7 @@ class KNXClient extends EventEmitter {
883
883
  } catch (error) { }
884
884
  //this.emit(KNXClientEvents.error, `Unexpected Tunnel Ack ${knxTunnelingAck.seqCounter}`);
885
885
  }
886
- }
886
+ }
887
887
 
888
888
  } else if (knxHeader.service_type === KNXConstants.KNX_CONSTANTS.ROUTING_INDICATION) {
889
889
 
@@ -154,6 +154,7 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
154
154
  node.lockHandleTelegramQueue = false; // 12/11/2021 Lock sending telegrams if node disconnected or if already handling the queue
155
155
  node.knxConnectionProperties = null; // Retains the connection properties
156
156
  node.allowLauch_initKNXConnection = true; // See the node.timerKNXUltimateCheckState function
157
+ node.timerClearTelegramQueue = null; // Timer to clear the telegram's queue after long disconnection
157
158
 
158
159
  // 15/12/2021
159
160
  node.adaptProtocolBasedOnIP = () => {
@@ -187,6 +188,20 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
187
188
  node.nodeClients.map(nextStatus);
188
189
  }
189
190
 
191
+ // 21/01/2022 TTL Timer for clearung the node.telegramsQueue if the connection stays down for long time
192
+ node.startTimerClearTelegramQueue = () => {
193
+ if (node.timerClearTelegramQueue === null) {
194
+ node.timerClearTelegramQueue = setTimeout(() => {
195
+ setTimeout(() => {
196
+ node.setAllClientsStatus("Queue", "grey", "Deleted TX");
197
+ }, 200);
198
+ node.telegramsQueue = [];
199
+ node.timerClearTelegramQueue = null;
200
+ }, 30000);
201
+ }
202
+ }
203
+
204
+
190
205
  //
191
206
  // KNX-SECURE
192
207
  // 15/11/2021 Function to load the keyring file exported from ETS
@@ -417,7 +432,7 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
417
432
  if (node.knxConnection !== null) node.knxConnection.Disconnect();
418
433
  } catch (error) { }
419
434
 
420
- node.telegramsQueue = []; // 02/01/2020 clear the telegram queue
435
+ node.startTimerClearTelegramQueue(); // 21/01/2022 Clear the telegram queue after a while
421
436
  node.setAllClientsStatus("Disconnected", "grey", "")
422
437
  node.linkStatus = "disconnected"; // 29/08/2019 signal disconnection
423
438
 
@@ -732,7 +747,7 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
732
747
  node.knxConnection.on(knx.KNXClient.KNXClientEvents.indication, handleBusEvents);
733
748
  node.knxConnection.on(knx.KNXClient.KNXClientEvents.error, err => {
734
749
  saveExposedGAs(); // 13/12/2021 save the current values of GA payload
735
- node.telegramsQueue = [];
750
+ node.startTimerClearTelegramQueue(); // 21/01/2022 Clear the telegram queue after a while
736
751
  node.linkStatus = "disconnected";
737
752
  node.setAllClientsStatus("Disconnected by error " + (err.message === undefined ? err : err.message), "red", "");
738
753
  if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.error("knxUltimate-config: Disconnected by: " + (err.message === undefined ? err : err.message));
@@ -744,7 +759,7 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
744
759
  });
745
760
  node.knxConnection.on(knx.KNXClient.KNXClientEvents.disconnected, info => {
746
761
  saveExposedGAs(); // 13/12/2021 save the current values of GA payload
747
- node.telegramsQueue = [];
762
+ node.startTimerClearTelegramQueue(); // 21/01/2022 Clear the telegram queue after a while
748
763
  if (node.linkStatus !== "disconnected") {
749
764
  node.linkStatus = "disconnected";
750
765
  node.setAllClientsStatus("Disconnected by event: " + info || "", "red", "");
@@ -755,7 +770,10 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
755
770
  if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.debug("knxUltimate-config: KNXClient socket closed.");
756
771
  });
757
772
  node.knxConnection.on(knx.KNXClient.KNXClientEvents.connected, info => {
758
- node.telegramsQueue = []; // 01/10/2020 Supergiovane: clear the telegram queue
773
+ if (node.timerClearTelegramQueue !== null) {
774
+ clearTimeout(node.timerClearTelegramQueue); // Connected. Stop the timer that clears the telegrams queue.
775
+ node.timerClearTelegramQueue = null;
776
+ }
759
777
  node.linkStatus = "connected";
760
778
  // Start the timer to do initial read.
761
779
  if (node.timerDoInitialRead !== null) clearTimeout(node.timerDoInitialRead);
@@ -766,7 +784,6 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
766
784
  if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.info("knxUltimate-config: Connected to %o", info);
767
785
  });
768
786
  node.knxConnection.on(knx.KNXClient.KNXClientEvents.connecting, info => {
769
- node.telegramsQueue = []; // 01/10/2020 Supergiovane: clear the telegram queue
770
787
  node.linkStatus = "connecting";
771
788
  // Start the timer to do initial read.
772
789
  if (node.timerDoInitialRead !== null) clearTimeout(node.timerDoInitialRead);
@@ -859,9 +876,6 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
859
876
  }
860
877
  switch (_evt) {
861
878
  case "GroupValue_Write": {
862
- //console.log("BANANA FIGA ARRIVA ROBA", node.linkStatus)
863
- //node.linkStatus = "connected"; // 01/10/2020 The connection must be alive, if womething comes from the bus!
864
- //console.log("BANANA HO ATTIVATO FORZATAMENTE LA CONNESSIONE", node.linkStatus)
865
879
  node.nodeClients
866
880
  .filter(input => input.notifywrite == true)
867
881
  .forEach(input => {
@@ -1072,14 +1086,14 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
1072
1086
  // 02/01/2020 All sent messages are queued, to allow at least 50 milliseconds between each telegram sent to the bus
1073
1087
  node.writeQueueAdd = _oKNXMessage => {
1074
1088
  let _clonedMessage = RED.util.cloneMessage(_oKNXMessage);
1075
- if (node.linkStatus !== "connected") {
1076
- try {
1077
- if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.info("knxUltimate-config: writeQueueAdd Discarded " + JSON.stringify(_clonedMessage));
1078
- } catch (error) {
1079
-
1080
- }
1081
- return;
1082
- }
1089
+ // if (node.linkStatus !== "connected") {
1090
+ // try {
1091
+ // if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.info("knxUltimate-config: writeQueueAdd Discarded " + JSON.stringify(_clonedMessage));
1092
+ // } catch (error) {
1093
+
1094
+ // }
1095
+ // return;
1096
+ // }
1083
1097
  // _clonedMessage is { grpaddr, payload,dpt,outputtype (write or response),nodecallerid (id of the node sending adding the telegram to the queue)}
1084
1098
  node.telegramsQueue.unshift(_clonedMessage); // Add _clonedMessage as first in the queue pile
1085
1099
  }
@@ -1090,12 +1104,11 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
1090
1104
  node.lockHandleTelegramQueue = true; // Lock the function. It cannot be called again until finished.
1091
1105
 
1092
1106
  // 16/08/2021 If not connected, exit
1093
- if (node.linkStatus !== "connected") {
1094
- node.telegramsQueue = [];
1107
+ if (node.linkStatus !== "connected" || node.telegramsQueue.length === 0) {
1095
1108
  node.lockHandleTelegramQueue = false; // Unlock the function
1096
1109
  return;
1097
1110
  }
1098
-
1111
+
1099
1112
  // 26/12/2021 If the KNXEngine is busy waiting for telegram's ACK, exit
1100
1113
  if (!node.knxConnection._getClearToSend()) {
1101
1114
  node.lockHandleTelegramQueue = false; // Unlock the function
@@ -1105,6 +1118,7 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
1105
1118
  return;
1106
1119
  }
1107
1120
 
1121
+
1108
1122
  // Retrieving oKNXMessage { grpaddr, payload,dpt,outputtype (write or response),nodecallerid (node caller)}. 06/03/2020 "Read" request does have the lower priority in the queue, so firstly, i search for "read" telegrams and i move it on the top of the queue pile.
1109
1123
  var aTelegramsFiltered = [];
1110
1124
  aTelegramsFiltered = node.telegramsQueue.filter(a => a.outputtype !== "read");
@@ -1160,7 +1174,6 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
1160
1174
 
1161
1175
  // 16/08/2021 If not connected, exit
1162
1176
  if (node.linkStatus !== "connected") {
1163
- node.telegramsQueue = [];
1164
1177
  node.lockHandleTelegramQueue = false; // Unlock the function
1165
1178
  return;
1166
1179
  }
@@ -1769,7 +1782,7 @@ return msg;`, "helplink": "https://github.com/Supergiovane/node-red-contrib-knx-
1769
1782
  if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.debug("knxUltimate-config: Waiting next cycle to reconect. node.LinkStatus:" + node.linkStatus + ", node.autoReconnect:" + node.autoReconnect);
1770
1783
  //node.initKNXConnection();
1771
1784
  }
1772
- }, 15000);
1785
+ }, 10000);
1773
1786
 
1774
1787
 
1775
1788
 
@@ -315,12 +315,12 @@ module.exports = function (RED) {
315
315
  } else {
316
316
  try {
317
317
  node.currentPayload = msg.payload;// 31/12/2019 Set the current value (because, if the node is a virtual device, then it'll never fire "GroupValue_Write" in the server node, causing the currentPayload to never update)
318
- if (node.server.linkStatus === "connected") {
318
+ //if (node.server.linkStatus === "connected") {
319
319
  node.server.writeQueueAdd({ grpaddr: grpaddr, payload: msg.payload, dpt: dpt, outputtype: outputtype, nodecallerid: node.id })
320
320
  node.setNodeStatus({ fill: "green", shape: "dot", text: "Writing", payload: msg.payload, GA: grpaddr, dpt: dpt, devicename: "" });
321
- } else {
322
- node.setNodeStatus({ fill: "grey", shape: "dot", text: "Disconnected", payload: msg.payload, GA: grpaddr, dpt: dpt, devicename: "" });
323
- }
321
+ //} else {
322
+ // node.setNodeStatus({ fill: "grey", shape: "dot", text: "Disconnected", payload: msg.payload, GA: grpaddr, dpt: dpt, devicename: "" });
323
+ //}
324
324
  } catch (error) { }
325
325
  }
326
326
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-knx-ultimate",
3
- "version": "1.3.19",
3
+ "version": "1.3.20",
4
4
  "description": "Control your KNX intallation via Node-Red! Single Node KNX IN/OUT with optional ETS group address importer. Easy to use and highly configurable.",
5
5
  "dependencies": {
6
6
  "fs": "0.0.1-security",