node-red-contrib-knx-ultimate 3.2.0 → 3.2.1

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/nodes/commonFunctions.js +0 -1
  3. package/nodes/hue-config.js +12 -6
  4. package/nodes/knxUltimate-config copy.html +456 -0
  5. package/nodes/knxUltimate-config copy.js +1939 -0
  6. package/nodes/knxUltimate-config.html +4 -9
  7. package/nodes/knxUltimate-config.js +128 -213
  8. package/nodes/knxUltimate.js +41 -32
  9. package/nodes/knxUltimateAlerter.js +11 -15
  10. package/nodes/knxUltimateAutoResponder.js +21 -13
  11. package/nodes/knxUltimateGarageDoorBarrierOpener.js +16 -8
  12. package/nodes/knxUltimateGlobalContext.js +10 -10
  13. package/nodes/knxUltimateHueBattery.js +8 -8
  14. package/nodes/knxUltimateHueButton.js +9 -9
  15. package/nodes/knxUltimateHueContactSensor.js +7 -7
  16. package/nodes/knxUltimateHueLight.js +26 -26
  17. package/nodes/knxUltimateHueLightSensor.js +8 -8
  18. package/nodes/knxUltimateHueMotion.js +7 -7
  19. package/nodes/knxUltimateHueScene.js +17 -9
  20. package/nodes/knxUltimateHueTapDial.js +13 -13
  21. package/nodes/knxUltimateHueTemperatureSensor.js +8 -8
  22. package/nodes/knxUltimateHueZigbeeConnectivity.js +8 -8
  23. package/nodes/knxUltimateHuedevice_software_update.js +8 -8
  24. package/nodes/knxUltimateLoadControl.js +24 -21
  25. package/nodes/knxUltimateLogger.js +8 -8
  26. package/nodes/knxUltimateSceneController.js +20 -13
  27. package/nodes/knxUltimateViewer.js +8 -8
  28. package/nodes/knxUltimateWatchDog.js +14 -14
  29. package/nodes/utils/http.js +0 -1
  30. package/nodes/utils/hueEngine.js +13 -6
  31. package/nodes/utils/payloadManipulation.js +2 -2
  32. package/nodes/utils/sysLogger.js +23 -60
  33. package/package.json +3 -3
@@ -18,8 +18,7 @@
18
18
  loglevel: { value: "error" },
19
19
  name: { value: "KNX Gateway" },
20
20
  localEchoInTunneling: { value: true },
21
- delaybetweentelegrams: { value: 50, required: false },
22
- delaybetweentelegramsfurtherdelayREAD: { value: 1, required: false },
21
+ delaybetweentelegrams: { value: 25, required: false },
23
22
  ignoreTelegramsWithRepeatedFlag: { value: false, required: false },
24
23
  keyringFileXML: { value: "" },
25
24
  knxSecureSelected: { value: false },
@@ -320,8 +319,6 @@
320
319
  <span data-i18n="knxUltimate-config.advanced.delaybetweentelegrams"></span>
321
320
  </label>
322
321
  <input type="number" id="node-config-input-delaybetweentelegrams" style="width:20%">
323
- <span data-i18n="knxUltimate-config.advanced.delaybetweentelegramsfurtherdelayREAD"></span><input type="number"
324
- id="node-config-input-delaybetweentelegramsfurtherdelayREAD" style="width:15%">X
325
322
  </div>
326
323
 
327
324
  <div class="form-row">
@@ -330,15 +327,13 @@
330
327
  <span data-i18n="knxUltimate-config.advanced.log_level"></span>
331
328
  </label>
332
329
  <select id="node-config-input-loglevel" style="width:40%;">
333
- <option value="silent" data-i18n="knxUltimate-config.advanced.select_silent"></option>
334
- <option value="error" data-i18n="knxUltimate-config.advanced.select_error"></option>
330
+ <option value="disable" data-i18n="knxUltimate-config.advanced.select_silent"></option>
331
+ <option value="error" data-i18n="knxUltimate-config.advanced.select_error"></option>
335
332
  <option value="warn" data-i18n="knxUltimate-config.advanced.select_warning"></option>
336
333
  <option value="info" data-i18n="knxUltimate-config.advanced.select_info"></option>
337
334
  <option value="debug" data-i18n="knxUltimate-config.advanced.select_debug"></option>
338
- <option value="trace" data-i18n="knxUltimate-config.advanced.select_trace"></option>
339
335
  </select>
340
- <!-- <div class="form-tips" style="margin-top: 11px;background-color:#FFEEEE;text-align:center">
341
- <b><span data-i18n="knxUltimate-config.properties.restart_hint"></span></b>
336
+ <!-- <// DEBUG LEVELS: success < debug < info < warn < error < disable
342
337
  </div> -->
343
338
  </div>
344
339
  </p>
@@ -13,7 +13,6 @@ const dptlib = require('knxultimate').dptlib;
13
13
 
14
14
  // const { Server } = require('http')
15
15
  const payloadRounder = require("./utils/payloadManipulation");
16
- const loggerEngine = require("./utils/sysLogger.js");
17
16
 
18
17
 
19
18
  // DATAPONT MANIPULATION HELPERS
@@ -54,11 +53,16 @@ const toConcattedSubtypes = (acc, baseType) => {
54
53
  };
55
54
  // ####################
56
55
 
56
+ // 10/09/2024 Setup the color logger
57
+ loggerSetup = (options) => {
58
+ let clog = require("node-color-log").createNamedLogger(options.setPrefix);
59
+ clog.setLevel(options.loglevel);
60
+ clog.setDate(() => (new Date()).toLocaleString());
61
+ return clog;
62
+ }
57
63
 
58
64
 
59
65
  module.exports = (RED) => {
60
-
61
-
62
66
  function knxUltimateConfigNode(config) {
63
67
  RED.nodes.createNode(this, config);
64
68
  const node = this;
@@ -70,10 +74,6 @@ module.exports = (RED) => {
70
74
  node.nodeClients = []; // Stores the registered clients
71
75
  node.KNXEthInterface = typeof config.KNXEthInterface === "undefined" ? "Auto" : config.KNXEthInterface;
72
76
  node.KNXEthInterfaceManuallyInput = typeof config.KNXEthInterfaceManuallyInput === "undefined" ? "" : config.KNXEthInterfaceManuallyInput; // If you manually set the interface name, it will be wrote here
73
- node.telegramsQueue = []; // 02/01/2020 Queue containing telegrams
74
- node.timerSendTelegramFromQueue = null;
75
- node.delaybetweentelegramsfurtherdelayREAD = typeof config.delaybetweentelegramsfurtherdelayREAD === "undefined" || Number(config.delaybetweentelegramsfurtherdelayREAD < 1) ? 1 : Number(config.delaybetweentelegramsfurtherdelayREAD); // 18/05/2020 delay multiplicator only for "read" telegrams.
76
- node.delaybetweentelegramsREADCount = 0; // 18/05/2020 delay multiplicator only for "read" telegrams.
77
77
  node.timerDoInitialRead = null; // 17/02/2020 Timer (timeout) to do initial read of all nodes requesting initial read, after all nodes have been registered to the sercer
78
78
  node.stopETSImportIfNoDatapoint = typeof config.stopETSImportIfNoDatapoint === "undefined" ? "stop" : config.stopETSImportIfNoDatapoint; // 09/01/2020 Stop, Import Fake or Skip the import if a group address has unset datapoint
79
79
  node.csv = readCSV(config.csv); // Array from ETS CSV Group Addresses {ga:group address, dpt: datapoint, devicename: full device name with main and subgroups}
@@ -81,10 +81,12 @@ module.exports = (RED) => {
81
81
  node.userDir = path.join(RED.settings.userDir, "knxultimatestorage"); // 04/04/2021 Supergiovane: Storage for service files
82
82
  node.exposedGAs = [];
83
83
  node.loglevel = config.loglevel !== undefined ? config.loglevel : "error"; // 18/02/2020 Loglevel default error
84
- node.sysLogger = null; // 20/03/2022 Default
84
+ if (node.loglevel === 'trace') node.loglevel = 'debug'; // Backward compatibility
85
+ if (node.loglevel === 'silent') node.loglevel = 'disable'; // Backward compatibility
86
+ node.sysLogger = null; // 20/03/2022 Default
85
87
  try {
86
- node.sysLogger = loggerEngine.get({ loglevel: node.loglevel }); // 08/04/2021 new logger to adhere to the loglevel selected in the config-window
87
- } catch (error) { }
88
+ node.sysLogger = loggerSetup({ loglevel: node.loglevel, setPrefix: "knxUltimate-config.js" });
89
+ } catch (error) { console.log(error.stack) }
88
90
  // 12/11/2021 Connect at start delay
89
91
  node.autoReconnect = true; // 20/03/2022 Default
90
92
  if (config.autoReconnect === "no" || config.autoReconnect === false) {
@@ -98,13 +100,11 @@ module.exports = (RED) => {
98
100
  node.knxSecureSelected = typeof config.knxSecureSelected === "undefined" ? false : config.knxSecureSelected;
99
101
  node.name = config.name === undefined || config.name === "" ? node.host : config.name; // 12/08/2021
100
102
  node.timerKNXUltimateCheckState = null; // 08/10/2021 Check the state. If not connected and autoreconnect is true, retrig the connetion attempt.
101
- node.lockHandleTelegramQueue = false; // 12/11/2021 Lock sending telegrams if node disconnected or if already handling the queue
102
103
  node.knxConnectionProperties = null; // Retains the connection properties
103
104
  node.allowLauch_initKNXConnection = true; // See the node.timerKNXUltimateCheckState function
104
- node.timerClearTelegramQueue = null; // Timer to clear the telegram's queue after long disconnection
105
105
  node.hostProtocol = config.hostProtocol === undefined ? "Auto" : config.hostProtocol; // 20/03/2022 Default
106
106
  node.knxConnection = null; // 20/03/2022 Default
107
- // 15/12/2021
107
+ node.delaybetweentelegrams = config.delaybetweentelegrams === undefined ? 25 : config.delaybetweentelegrams;
108
108
 
109
109
  // 05/12/2021 Set the protocol (this is undefined if coming from ild versions
110
110
  if (node.hostProtocol === "Auto") {
@@ -143,20 +143,6 @@ module.exports = (RED) => {
143
143
  });
144
144
  };
145
145
 
146
- // 21/01/2022 TTL Timer for clearung the node.telegramsQueue if the connection stays down for long time
147
- node.startTimerClearTelegramQueue = () => {
148
- if (node.timerClearTelegramQueue === null) {
149
- node.timerClearTelegramQueue = setTimeout(() => {
150
- const t = setTimeout(() => {
151
- // 21/03/2022 fixed possible memory leak. Previously was setTimeout without "let t = ".
152
- node.setAllClientsStatus("Queue", "grey", "Deleted TX");
153
- }, 200);
154
- node.telegramsQueue = [];
155
- node.timerClearTelegramQueue = null;
156
- }, 30000);
157
- }
158
- };
159
-
160
146
  //
161
147
  // KNX-SECURE
162
148
  // 15/11/2021 Function to load the keyring file exported from ETS
@@ -373,7 +359,7 @@ module.exports = (RED) => {
373
359
  dpt: _oClient.dpt,
374
360
  devicename: _oClient.devicename || "",
375
361
  });
376
- node.writeQueueAdd({
362
+ node.sendKNXTelegramToKNXEngine({
377
363
  grpaddr: _oClient.topic,
378
364
  payload: "",
379
365
  dpt: "",
@@ -407,7 +393,7 @@ module.exports = (RED) => {
407
393
  for (let index = 0; index < node.csv.length; index++) {
408
394
  const element = node.csv[index];
409
395
  if (!readHistory.includes(element.ga)) {
410
- node.writeQueueAdd({
396
+ node.sendKNXTelegramToKNXEngine({
411
397
  grpaddr: element.ga,
412
398
  payload: "",
413
399
  dpt: "",
@@ -420,7 +406,7 @@ module.exports = (RED) => {
420
406
  }
421
407
  } else {
422
408
  if (!readHistory.includes(_oClient.topic)) {
423
- node.writeQueueAdd({
409
+ node.sendKNXTelegramToKNXEngine({
424
410
  grpaddr: _oClient.topic,
425
411
  payload: "",
426
412
  dpt: "",
@@ -543,6 +529,7 @@ module.exports = (RED) => {
543
529
  isSecureKNXEnabled: node.knxSecureSelected,
544
530
  jKNXSecureKeyring: node.jKNXSecureKeyring,
545
531
  localIPAddress: "", // Riempito da KNXEngine
532
+ KNXQueueSendIntervalMilliseconds: Number(node.delaybetweentelegrams)
546
533
  };
547
534
  // 11/07/2022 Test if the IP is a valid one or is a DNS Name
548
535
  switch (net.isIP(node.host)) {
@@ -633,6 +620,7 @@ module.exports = (RED) => {
633
620
  // Unsetting handlers if node.knxConnection was existing
634
621
  try {
635
622
  if (node.knxConnection !== null && node.knxConnection !== undefined) {
623
+ await node.knxConnection.Disconnect();
636
624
  if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.debug("knxUltimate-config: removing old handlers. Node " + node.name);
637
625
  node.knxConnection.removeAllListeners();
638
626
  }
@@ -669,7 +657,6 @@ module.exports = (RED) => {
669
657
  // discoverCB(ip, port);
670
658
  // });
671
659
  node.knxConnection.on(knx.KNXClientEvents.disconnected, (info) => {
672
- node.startTimerClearTelegramQueue(); // 21/01/2022 Clear the telegram queue after a while
673
660
  if (node.linkStatus !== "disconnected") {
674
661
  node.linkStatus = "disconnected";
675
662
  if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.warn("knxUltimate-config: Disconnected event %s", info);
@@ -678,15 +665,10 @@ module.exports = (RED) => {
678
665
  });
679
666
  node.knxConnection.on(knx.KNXClientEvents.close, (info) => {
680
667
  if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.debug("knxUltimate-config: KNXClient socket closed.");
668
+ node.linkStatus = "disconnected";
681
669
  });
682
670
  node.knxConnection.on(knx.KNXClientEvents.connected, (info) => {
683
- if (node.timerClearTelegramQueue !== null) {
684
- clearTimeout(node.timerClearTelegramQueue); // Connected. Stop the timer that clears the telegrams queue.
685
- node.timerClearTelegramQueue = null;
686
- }
687
- // 12/11/2021 Starts the telegram out queue handler
688
- if (node.timerSendTelegramFromQueue !== null) clearInterval(node.timerSendTelegramFromQueue);
689
- node.timerSendTelegramFromQueue = setInterval(handleTelegramQueue, config.delaybetweentelegrams === undefined || Number(config.delaybetweentelegrams) < 20 ? 20 : Number(config.delaybetweentelegrams)); // 02/01/2020 Start the timer that handles the queue of telegrams
671
+
690
672
  node.linkStatus = "connected";
691
673
 
692
674
  // Start the timer to do initial read.
@@ -1103,7 +1085,7 @@ module.exports = (RED) => {
1103
1085
  if (_input.hasOwnProperty("notifyreadrequestalsorespondtobus") && _input.notifyreadrequestalsorespondtobus === true) {
1104
1086
  if (typeof _input.currentPayload === "undefined" || _input.currentPayload === "" || _input.currentPayload === null) {
1105
1087
  // 14/08/2021 Added || input.currentPayload === null
1106
- node.writeQueueAdd({
1088
+ node.sendKNXTelegramToKNXEngine({
1107
1089
  grpaddr: _dest,
1108
1090
  payload: _input.notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized,
1109
1091
  dpt: _input.dpt,
@@ -1120,7 +1102,7 @@ module.exports = (RED) => {
1120
1102
  devicename: "",
1121
1103
  });
1122
1104
  } else {
1123
- node.writeQueueAdd({
1105
+ node.sendKNXTelegramToKNXEngine({
1124
1106
  grpaddr: _dest,
1125
1107
  payload: _input.currentPayload,
1126
1108
  dpt: _input.dpt,
@@ -1161,191 +1143,129 @@ module.exports = (RED) => {
1161
1143
  }
1162
1144
  // END Handle BUS events---------------------------------------------------------------------------------------
1163
1145
 
1164
- // 02/01/2020 All sent messages are queued, to allow at least 50 milliseconds between each telegram sent to the bus
1165
- node.writeQueueAdd = (_oKNXMessage) => {
1166
- const _clonedMessage = RED.util.cloneMessage(_oKNXMessage);
1167
- // if (node.linkStatus !== "connected") {
1168
- // try {
1169
- // if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.info("knxUltimate-config: writeQueueAdd Discarded " + JSON.stringify(_clonedMessage));
1170
- // } catch (error) {
1171
-
1172
- // }
1173
- // return;
1174
- // }
1175
- // _clonedMessage is { grpaddr, payload,dpt,outputtype (write or response),nodecallerid (id of the node sending adding the telegram to the queue)}
1176
- node.telegramsQueue.unshift(_clonedMessage); // Add _clonedMessage as first in the queue pile
1177
- };
1178
-
1179
- function handleTelegramQueue() {
1180
- if (node.knxConnection !== null) {
1181
- if (node.lockHandleTelegramQueue === true) return; // Exits if the funtion is busy
1182
- node.lockHandleTelegramQueue = true; // Lock the function. It cannot be called again until finished.
1183
-
1184
- // 16/08/2021 If not connected, exit
1185
- if (node.linkStatus !== "connected" || node.telegramsQueue.length === 0) {
1186
- node.lockHandleTelegramQueue = false; // Unlock the function
1187
- return;
1188
- }
1189
-
1190
- // 26/12/2021 If the KNXEngine is busy waiting for telegram's ACK, exit
1191
- if (!node.knxConnection.clearToSend) {
1192
- node.lockHandleTelegramQueue = false; // Unlock the function
1193
- if (node.telegramsQueue.length > 0) {
1194
- if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.warn(
1195
- "knxUltimate-config: handleTelegramQueue: the KNXEngine is busy or is waiting for a telegram ACK with seqNumner " +
1196
- node.knxConnection.getSeqNumber() +
1197
- ". Delay handling queue. YOUR COMPUTER COULD BE TOO SLOW OR BUSY TO KEEP UP WITH THE STRICT TIMING, REQUIRED FOR KNX TO FUNCTION PROPERLY.",
1198
- );
1199
- }
1200
- return;
1201
- }
1202
-
1203
- // 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.
1204
- let aTelegramsFiltered = [];
1205
- aTelegramsFiltered = node.telegramsQueue.filter((a) => a.outputtype !== "read");
1146
+ node.sendKNXTelegramToKNXEngine = (_oKNXMessage) => {
1147
+ if (node.knxConnection === null || node.linkStatus !== "connected") return;
1206
1148
 
1207
- if (aTelegramsFiltered.length == 0) {
1208
- // There are no write nor response telegrams, handle the remaining "read", if any
1209
- if (node.delaybetweentelegramsREADCount >= node.delaybetweentelegramsfurtherdelayREAD) {
1210
- // 18/05/2020 delay multiplicator only for "read" telegrams.
1211
- node.delaybetweentelegramsREADCount = 0;
1212
- aTelegramsFiltered = node.telegramsQueue;
1213
- } else {
1214
- node.delaybetweentelegramsREADCount += 1;
1215
- }
1216
- }
1217
- if (aTelegramsFiltered.length == 0) {
1218
- node.lockHandleTelegramQueue = false; // Unlock the function
1219
- return;
1220
- }
1149
+ // 26/12/2021 The KNXEngine is busy waiting for telegram's ACK. Strange.
1150
+ if (!node.knxConnection.clearToSend) {
1151
+ if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.warn(
1152
+ "knxUltimate-config: handleTelegramQueue: the KNXEngine is busy or is waiting for a telegram ACK with seqNumner " +
1153
+ node.knxConnection.getSeqNumber() +
1154
+ ". Delay handling queue. YOUR COMPUTER COULD BE TOO SLOW OR BUSY TO KEEP UP WITH THE STRICT TIMING, REQUIRED FOR KNX TO FUNCTION PROPERLY.",
1155
+ );
1156
+ }
1221
1157
 
1222
- const oKNXMessage = aTelegramsFiltered[aTelegramsFiltered.length - 1]; // Get the last message in the queue
1158
+ // oKNXMessage is { 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.
1223
1159
 
1224
- // 19/01/2023 FORMATTING THE OUTPUT PAYLOAD (ROUND, ETC) BASED ON THE NODE CONFIG
1225
- //* ********************************************************
1226
- oKNXMessage.payload = payloadRounder.Manipulate(RED.nodes.getNode(oKNXMessage.nodecallerid), oKNXMessage.payload);
1227
- //* ********************************************************
1160
+ // 19/01/2023 FORMATTING THE OUTPUT PAYLOAD (ROUND, ETC) BASED ON THE NODE CONFIG
1161
+ //* ********************************************************
1162
+ _oKNXMessage.payload = payloadRounder.Manipulate(RED.nodes.getNode(_oKNXMessage.nodecallerid), _oKNXMessage.payload);
1163
+ //* ********************************************************
1228
1164
 
1229
- if (oKNXMessage.outputtype === "response") {
1230
- try {
1231
- node.knxConnection.respond(oKNXMessage.grpaddr, oKNXMessage.payload, oKNXMessage.dpt);
1232
- } catch (error) {
1233
- try {
1234
- const oNode = RED.nodes.getNode(oKNXMessage.nodecallerid); // 05/04/2022 Get the real node
1235
- oNode.setNodeStatus({
1236
- fill: "red",
1237
- shape: "dot",
1238
- text: "Send response " + error,
1239
- payload: oKNXMessage.payload,
1240
- GA: oKNXMessage.grpaddr,
1241
- dpt: oKNXMessage.dpt,
1242
- devicename: "",
1243
- });
1244
- } catch (error) { }
1245
- }
1246
- } else if (oKNXMessage.outputtype === "read") {
1165
+ if (_oKNXMessage.outputtype === "response") {
1166
+ try {
1167
+ node.knxConnection.respond(_oKNXMessage.grpaddr, _oKNXMessage.payload, _oKNXMessage.dpt);
1168
+ } catch (error) {
1247
1169
  try {
1248
- node.knxConnection.read(oKNXMessage.grpaddr);
1170
+ const oNode = RED.nodes.getNode(_oKNXMessage.nodecallerid); // 05/04/2022 Get the real node
1171
+ oNode.setNodeStatus({
1172
+ fill: "red",
1173
+ shape: "dot",
1174
+ text: "Send response " + error,
1175
+ payload: _oKNXMessage.payload,
1176
+ GA: _oKNXMessage.grpaddr,
1177
+ dpt: _oKNXMessage.dpt,
1178
+ devicename: "",
1179
+ });
1249
1180
  } catch (error) { }
1250
- } else if (oKNXMessage.outputtype === "update") {
1251
- // 05/01/2021 Update don't send anything to the bus, but instead updates the values of all nodes belonging to the group address passed
1252
- // oKNXMessage = {
1253
- // grpaddr: '5/0/1',
1254
- // payload: true,
1255
- // dpt: '1.001',
1256
- // outputtype: 'update',
1257
- // nodecallerid: 'd104af91.31da18'
1258
- // }
1259
- try {
1260
- node.nodeClients.forEach((_input) => {
1261
-
1262
- // 16/08/2021 If not connected, exit
1263
- if (node.linkStatus !== "connected") {
1264
- node.lockHandleTelegramQueue = false; // Unlock the function
1265
- return;
1266
- }
1267
-
1268
- // 19/03/2020 in the middle of coronavirus. Whole italy is red zone, closed down. Scene Controller implementation
1269
- if (_input.hasOwnProperty("isSceneController")) {
1270
- } else if (_input.hasOwnProperty("isLogger")) {
1271
- // 26/03/2020 Coronavirus is slightly decreasing the affected numer of people. Logger Node
1272
- } else if (_input.listenallga === true) {
1273
- } else if (_input.topic == oKNXMessage.grpaddr) {
1274
- if (_input.hasOwnProperty("isWatchDog")) {
1275
- // 04/02/2020 Watchdog implementation
1276
- // Is a watchdog node
1277
- } else {
1278
- const msg = {
1279
- topic: _input.outputtopic,
1280
- payload: oKNXMessage.payload,
1281
- devicename: _input.name ? _input.name : "",
1282
- event: "Update_NoWrite",
1283
- eventdesc: "The value has been updated from another node and hasn't been received from KNX BUS",
1284
- };
1285
- // Check RBE INPUT from KNX Bus, to avoid send the payload to the flow, if it's equal to the current payload
1286
- if (!checkRBEInputFromKNXBusAllowSend(_input, msg.payload)) {
1287
- _input.setNodeStatus({
1288
- fill: "grey",
1289
- shape: "ring",
1290
- text: "rbe block (" + msg.payload + ") from KNX",
1291
- payload: "",
1292
- GA: "",
1293
- dpt: "",
1294
- devicename: "",
1295
- });
1296
- node.lockHandleTelegramQueue = false; // Unlock the function
1297
- return;
1298
- }
1299
- msg.previouspayload = typeof _input.currentPayload !== "undefined" ? _input.currentPayload : ""; // 24/01/2020 Added previous payload
1300
- _input.currentPayload = msg.payload; // Set the current value for the RBE input
1181
+ }
1182
+ } else if (_oKNXMessage.outputtype === "read") {
1183
+ try {
1184
+ node.knxConnection.read(_oKNXMessage.grpaddr);
1185
+ } catch (error) { }
1186
+ } else if (_oKNXMessage.outputtype === "update") {
1187
+ // 05/01/2021 Update don't send anything to the bus, but instead updates the values of all nodes belonging to the group address passed
1188
+ // oKNXMessage = {
1189
+ // grpaddr: '5/0/1',
1190
+ // payload: true,
1191
+ // dpt: '1.001',
1192
+ // outputtype: 'update',
1193
+ // nodecallerid: 'd104af91.31da18'
1194
+ // }
1195
+ try {
1196
+ node.nodeClients.forEach((_input) => {
1197
+
1198
+ // 19/03/2020 in the middle of coronavirus. Whole italy is red zone, closed down. Scene Controller implementation
1199
+ if (_input.hasOwnProperty("isSceneController")) {
1200
+ } else if (_input.hasOwnProperty("isLogger")) {
1201
+ // 26/03/2020 Coronavirus is slightly decreasing the affected numer of people. Logger Node
1202
+ } else if (_input.listenallga === true) {
1203
+ } else if (_input.topic == _oKNXMessage.grpaddr) {
1204
+ if (_input.hasOwnProperty("isWatchDog")) {
1205
+ // 04/02/2020 Watchdog implementation
1206
+ // Is a watchdog node
1207
+ } else {
1208
+ const msg = {
1209
+ topic: _input.outputtopic,
1210
+ payload: _oKNXMessage.payload,
1211
+ devicename: _input.name ? _input.name : "",
1212
+ event: "Update_NoWrite",
1213
+ eventdesc: "The value has been updated from another node and hasn't been received from KNX BUS",
1214
+ };
1215
+ // Check RBE INPUT from KNX Bus, to avoid send the payload to the flow, if it's equal to the current payload
1216
+ if (!checkRBEInputFromKNXBusAllowSend(_input, msg.payload)) {
1301
1217
  _input.setNodeStatus({
1302
- fill: "green",
1303
- shape: "dot",
1304
- text: "",
1305
- payload: msg.payload,
1306
- GA: _input.topic,
1307
- dpt: _input.dpt,
1218
+ fill: "grey",
1219
+ shape: "ring",
1220
+ text: "rbe block (" + msg.payload + ") from KNX",
1221
+ payload: "",
1222
+ GA: "",
1223
+ dpt: "",
1308
1224
  devicename: "",
1309
1225
  });
1310
- _input.handleSend(msg);
1226
+ return;
1311
1227
  }
1228
+ msg.previouspayload = typeof _input.currentPayload !== "undefined" ? _input.currentPayload : ""; // 24/01/2020 Added previous payload
1229
+ _input.currentPayload = msg.payload; // Set the current value for the RBE input
1230
+ _input.setNodeStatus({
1231
+ fill: "green",
1232
+ shape: "dot",
1233
+ text: "",
1234
+ payload: msg.payload,
1235
+ GA: _input.topic,
1236
+ dpt: _input.dpt,
1237
+ devicename: "",
1238
+ });
1239
+ _input.handleSend(msg);
1312
1240
  }
1313
- });
1314
- } catch (error) { }
1315
- } else {
1316
- // Write
1317
- try {
1318
- node.knxConnection.write(oKNXMessage.grpaddr, oKNXMessage.payload, oKNXMessage.dpt);
1319
- } catch (error) {
1320
- try {
1321
- const oNode = RED.nodes.getNode(oKNXMessage.nodecallerid); // 05/04/2022 Get the real node
1322
- if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.error(
1323
- "knxUltimate-config: node.knxConnection.write: Payload: " + oKNXMessage.payload + " GA:" + oKNXMessage.grpaddr + " DPT:" + oKNXMessage.dpt + " " + error.stack
1324
- );
1325
- oNode.setNodeStatus({
1326
- fill: "red",
1327
- shape: "dot",
1328
- text: "Send write " + error,
1329
- payload: oKNXMessage.payload,
1330
- GA: oKNXMessage.grpaddr,
1331
- dpt: oKNXMessage.dpt,
1332
- devicename: "",
1333
- });
1334
- } catch (error) { }
1335
- }
1336
- }
1337
- // Remove current item in the main node.telegramsQueue array
1338
- try {
1339
- node.telegramsQueue = node.telegramsQueue.filter((item) => {
1340
- if (item !== oKNXMessage) {
1341
- return item;
1342
1241
  }
1343
1242
  });
1344
1243
  } catch (error) { }
1345
- node.lockHandleTelegramQueue = false; // Unlock the function
1244
+ } else {
1245
+ // Write
1246
+ try {
1247
+ node.knxConnection.write(_oKNXMessage.grpaddr, _oKNXMessage.payload, _oKNXMessage.dpt);
1248
+ } catch (error) {
1249
+ try {
1250
+ const oNode = RED.nodes.getNode(_oKNXMessage.nodecallerid); // 05/04/2022 Get the real node
1251
+ if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.error(
1252
+ "knxUltimate-config: node.knxConnection.write: Payload: " + _oKNXMessage.payload + " GA:" + _oKNXMessage.grpaddr + " DPT:" + _oKNXMessage.dpt + " " + error.stack
1253
+ );
1254
+ oNode.setNodeStatus({
1255
+ fill: "red",
1256
+ shape: "dot",
1257
+ text: "Send write " + error,
1258
+ payload: _oKNXMessage.payload,
1259
+ GA: _oKNXMessage.grpaddr,
1260
+ dpt: _oKNXMessage.dpt,
1261
+ devicename: "",
1262
+ });
1263
+ } catch (error) { }
1264
+ }
1346
1265
  }
1347
1266
  }
1348
1267
 
1268
+
1349
1269
  // 14/08/2019 If the node has payload same as the received telegram, return false
1350
1270
  function checkRBEInputFromKNXBusAllowSend(_node, _KNXTelegramPayload) {
1351
1271
  if (_node.inputRBE !== "true") return true;
@@ -1899,9 +1819,7 @@ module.exports = (RED) => {
1899
1819
  if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.debug("knxUltimate-config: Disconnect: already not connected:" + node.linkStatus + ", node.autoReconnect:" + node.autoReconnect);
1900
1820
  return;
1901
1821
  }
1902
- if (node.timerSendTelegramFromQueue !== null) clearInterval(node.timerSendTelegramFromQueue); // 02/01/2020 Stop queue timer
1903
1822
  node.linkStatus = "disconnected"; // 29/08/2019 signal disconnection
1904
- node.lockHandleTelegramQueue = false; // Unlock the telegram handling function
1905
1823
  if (node.timerDoInitialRead !== null) clearTimeout(node.timerDoInitialRead); // 17/02/2020 Stop the initial read timer
1906
1824
  try {
1907
1825
  if (node.knxConnection !== null) await node.knxConnection.Disconnect();
@@ -1910,7 +1828,6 @@ module.exports = (RED) => {
1910
1828
  "knxUltimate-config: Disconnected: node.knxConnection.Disconnect() " + (error.message || "") + " , node.autoReconnect:" + node.autoReconnect,
1911
1829
  );
1912
1830
  }
1913
- node.startTimerClearTelegramQueue(); // 21/01/2022 Clear the telegram queue after a while
1914
1831
  node.setAllClientsStatus("Disconnected", _sColor, _sNodeStatus);
1915
1832
  saveExposedGAs(); // 04/04/2021 save the current values of GA payload
1916
1833
  if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.debug("knxUltimate-config: Disconnected, node.autoReconnect:" + node.autoReconnect);
@@ -1920,8 +1837,6 @@ module.exports = (RED) => {
1920
1837
  try {
1921
1838
  await node.Disconnect();
1922
1839
  } catch (error) { /* empty */ }
1923
- if (node.timerClearTelegramQueue !== null) clearTimeout(node.timerClearTelegramQueue);
1924
- node.telegramsQueue = [];
1925
1840
  node.nodeClients = []; // 05/04/2022 Nullify
1926
1841
  try {
1927
1842
  if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger = null;