node-red-contrib-knx-ultimate 3.1.0 → 3.1.2

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 (117) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/nodes/knxUltimate.html +43 -71
  3. package/nodes/knxUltimate.js +14 -14
  4. package/package.json +1 -1
  5. package/resources/KNXFunctionCodeSnippets.js +43 -0
  6. package/_JS_KNXEngine/CHANGELOG.md +0 -164
  7. package/_JS_KNXEngine/LICENSE +0 -21
  8. package/_JS_KNXEngine/README.md +0 -592
  9. package/_JS_KNXEngine/img/dpt 2.png +0 -0
  10. package/_JS_KNXEngine/img/dpt.png +0 -0
  11. package/_JS_KNXEngine/img/logo 2.png +0 -0
  12. package/_JS_KNXEngine/img/logo-big 2.png +0 -0
  13. package/_JS_KNXEngine/img/logo-big.png +0 -0
  14. package/_JS_KNXEngine/img/logo.png +0 -0
  15. package/_JS_KNXEngine/img/nodered 2.png +0 -0
  16. package/_JS_KNXEngine/img/nodered.png +0 -0
  17. package/_JS_KNXEngine/index.js +0 -16
  18. package/_JS_KNXEngine/package.json +0 -50
  19. package/_JS_KNXEngine/sample.js +0 -202
  20. package/_JS_KNXEngine/sampleSecure.js +0 -153
  21. package/_JS_KNXEngine/simpleSample.js +0 -76
  22. package/_JS_KNXEngine/src/Curve25519.js +0 -1750
  23. package/_JS_KNXEngine/src/KNXClient.js +0 -1054
  24. package/_JS_KNXEngine/src/KNXSocketOptions.js +0 -3
  25. package/_JS_KNXEngine/src/KNXsecureKeyring.js +0 -543
  26. package/_JS_KNXEngine/src/KnxLog.js +0 -66
  27. package/_JS_KNXEngine/src/cur.js +0 -217
  28. package/_JS_KNXEngine/src/dptlib/dpt1.js +0 -232
  29. package/_JS_KNXEngine/src/dptlib/dpt10.js +0 -106
  30. package/_JS_KNXEngine/src/dptlib/dpt11.js +0 -83
  31. package/_JS_KNXEngine/src/dptlib/dpt12.js +0 -60
  32. package/_JS_KNXEngine/src/dptlib/dpt13.js +0 -107
  33. package/_JS_KNXEngine/src/dptlib/dpt14.js +0 -202
  34. package/_JS_KNXEngine/src/dptlib/dpt15.js +0 -24
  35. package/_JS_KNXEngine/src/dptlib/dpt16.js +0 -68
  36. package/_JS_KNXEngine/src/dptlib/dpt17.js +0 -27
  37. package/_JS_KNXEngine/src/dptlib/dpt18.js +0 -93
  38. package/_JS_KNXEngine/src/dptlib/dpt19.js +0 -58
  39. package/_JS_KNXEngine/src/dptlib/dpt2.js +0 -147
  40. package/_JS_KNXEngine/src/dptlib/dpt20.js +0 -51
  41. package/_JS_KNXEngine/src/dptlib/dpt21.js +0 -66
  42. package/_JS_KNXEngine/src/dptlib/dpt213.js +0 -152
  43. package/_JS_KNXEngine/src/dptlib/dpt22.js +0 -143
  44. package/_JS_KNXEngine/src/dptlib/dpt222.js +0 -151
  45. package/_JS_KNXEngine/src/dptlib/dpt232.js +0 -59
  46. package/_JS_KNXEngine/src/dptlib/dpt235.js +0 -137
  47. package/_JS_KNXEngine/src/dptlib/dpt237.js +0 -92
  48. package/_JS_KNXEngine/src/dptlib/dpt238.js +0 -90
  49. package/_JS_KNXEngine/src/dptlib/dpt242.js +0 -85
  50. package/_JS_KNXEngine/src/dptlib/dpt249.js +0 -88
  51. package/_JS_KNXEngine/src/dptlib/dpt251.js +0 -77
  52. package/_JS_KNXEngine/src/dptlib/dpt275.js +0 -58
  53. package/_JS_KNXEngine/src/dptlib/dpt28.js +0 -63
  54. package/_JS_KNXEngine/src/dptlib/dpt29.js +0 -63
  55. package/_JS_KNXEngine/src/dptlib/dpt3.js +0 -90
  56. package/_JS_KNXEngine/src/dptlib/dpt4.js +0 -57
  57. package/_JS_KNXEngine/src/dptlib/dpt5.js +0 -75
  58. package/_JS_KNXEngine/src/dptlib/dpt6.js +0 -45
  59. package/_JS_KNXEngine/src/dptlib/dpt60001.js +0 -276
  60. package/_JS_KNXEngine/src/dptlib/dpt60002.js +0 -101
  61. package/_JS_KNXEngine/src/dptlib/dpt7.js +0 -147
  62. package/_JS_KNXEngine/src/dptlib/dpt8.js +0 -94
  63. package/_JS_KNXEngine/src/dptlib/dpt9.js +0 -273
  64. package/_JS_KNXEngine/src/dptlib/dpt999.js +0 -62
  65. package/_JS_KNXEngine/src/dptlib/index.js +0 -177
  66. package/_JS_KNXEngine/src/errors/BufferLengthError.js +0 -4
  67. package/_JS_KNXEngine/src/errors/DateFormatError.js +0 -5
  68. package/_JS_KNXEngine/src/errors/DuplicateRequestError.js +0 -5
  69. package/_JS_KNXEngine/src/errors/InvalidValueError.js +0 -5
  70. package/_JS_KNXEngine/src/errors/NotImplementedError.js +0 -5
  71. package/_JS_KNXEngine/src/errors/RequestTimeoutError.js +0 -3
  72. package/_JS_KNXEngine/src/errors/index.js +0 -7
  73. package/_JS_KNXEngine/src/index.js +0 -13
  74. package/_JS_KNXEngine/src/protocol/CRD.js +0 -65
  75. package/_JS_KNXEngine/src/protocol/CRI.js +0 -35
  76. package/_JS_KNXEngine/src/protocol/CRIFactory.js +0 -21
  77. package/_JS_KNXEngine/src/protocol/DIB.js +0 -3
  78. package/_JS_KNXEngine/src/protocol/DeviceInfo.js +0 -233
  79. package/_JS_KNXEngine/src/protocol/HPAI.js +0 -103
  80. package/_JS_KNXEngine/src/protocol/IPConfig.js +0 -99
  81. package/_JS_KNXEngine/src/protocol/IPCurrentConfig.js +0 -114
  82. package/_JS_KNXEngine/src/protocol/KNXAddress.js +0 -119
  83. package/_JS_KNXEngine/src/protocol/KNXAddresses.js +0 -58
  84. package/_JS_KNXEngine/src/protocol/KNXConnectRequest.js +0 -41
  85. package/_JS_KNXEngine/src/protocol/KNXConnectResponse.js +0 -66
  86. package/_JS_KNXEngine/src/protocol/KNXConnectionStateRequest.js +0 -38
  87. package/_JS_KNXEngine/src/protocol/KNXConnectionStateResponse.js +0 -53
  88. package/_JS_KNXEngine/src/protocol/KNXConstants.js +0 -84
  89. package/_JS_KNXEngine/src/protocol/KNXDataBuffer.js +0 -28
  90. package/_JS_KNXEngine/src/protocol/KNXDescriptionRequest.js +0 -26
  91. package/_JS_KNXEngine/src/protocol/KNXDescriptionResponse.js +0 -34
  92. package/_JS_KNXEngine/src/protocol/KNXDisconnectRequest.js +0 -36
  93. package/_JS_KNXEngine/src/protocol/KNXDisconnectResponse.js +0 -30
  94. package/_JS_KNXEngine/src/protocol/KNXHeader.js +0 -66
  95. package/_JS_KNXEngine/src/protocol/KNXPacket.js +0 -23
  96. package/_JS_KNXEngine/src/protocol/KNXProtocol.js +0 -116
  97. package/_JS_KNXEngine/src/protocol/KNXRoutingIndication.js +0 -34
  98. package/_JS_KNXEngine/src/protocol/KNXSearchRequest.js +0 -26
  99. package/_JS_KNXEngine/src/protocol/KNXSearchResponse.js +0 -36
  100. package/_JS_KNXEngine/src/protocol/KNXSecureSessionRequest.js +0 -62
  101. package/_JS_KNXEngine/src/protocol/KNXTunnelingAck.js +0 -39
  102. package/_JS_KNXEngine/src/protocol/KNXTunnelingRequest.js +0 -49
  103. package/_JS_KNXEngine/src/protocol/KNXUtils.js +0 -69
  104. package/_JS_KNXEngine/src/protocol/ServiceFamilies.js +0 -73
  105. package/_JS_KNXEngine/src/protocol/TunnelCRI.js +0 -40
  106. package/_JS_KNXEngine/src/protocol/cEMI/AdditionalInfo.js +0 -37
  107. package/_JS_KNXEngine/src/protocol/cEMI/CEMIConstants.js +0 -28
  108. package/_JS_KNXEngine/src/protocol/cEMI/CEMIFactory.js +0 -56
  109. package/_JS_KNXEngine/src/protocol/cEMI/CEMIMessage.js +0 -33
  110. package/_JS_KNXEngine/src/protocol/cEMI/ControlField.js +0 -132
  111. package/_JS_KNXEngine/src/protocol/cEMI/LDataCon.js +0 -54
  112. package/_JS_KNXEngine/src/protocol/cEMI/LDataInd.js +0 -54
  113. package/_JS_KNXEngine/src/protocol/cEMI/LDataReq.js +0 -54
  114. package/_JS_KNXEngine/src/protocol/cEMI/NPDU.js +0 -173
  115. package/_JS_KNXEngine/src/protocol/cEMI/TLVInfo.js +0 -29
  116. package/_JS_KNXEngine/src/protocol/index.js +0 -7
  117. package/_JS_KNXEngine/src/util/ipAddressHelper.js +0 -52
package/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@
6
6
 
7
7
  # CHANGELOG
8
8
 
9
+ **Version 3.1.2** - August 2024<br/>
10
+ - NEW: KNX Function code editor: minor fixes. CAUTION, KNX FUNCTION IS STILL IN BETA AND SUBJECT TO CHANGES.<br/>
11
+
12
+ **Version 3.1.1** - August 2024<br/>
13
+ - NEW: KNX Function code editor in the device node: you can now write you own script to handle inbound and outboud KNX messages. Added "node" and "RED" object to the function's context. CAUTION, KNX FUNCTION IS STILL IN BETA AND SUBJECT TO CHANGES.<br/>
14
+
9
15
  **Version 3.1.0** - August 2024<br/>
10
16
  - NEW: KNX Function code editor in the device node: you can now write you own script to handle inbound and outboud KNX messages.<br/>
11
17
 
@@ -2,6 +2,7 @@
2
2
 
3
3
 
4
4
  <script type="text/javascript" src="resources/node-red-contrib-knx-ultimate/htmlUtils.js"></script>
5
+ <script type="text/javascript" src="resources/node-red-contrib-knx-ultimate/KNXFunctionCodeSnippets.js"></script>
5
6
 
6
7
  <script type="text/javascript">
7
8
  RED.nodes.registerType('knxUltimate', {
@@ -29,14 +30,16 @@
29
30
  formatnegativevalue: { value: "leave" },
30
31
  formatdecimalsvalue: { value: 999 },
31
32
  passthrough: { value: "no" },
32
- outputFunctionCode: { value: "" },
33
- inputFunctionCode: { value: "" }
33
+ sendMsgToKNXCode: { value: "" },
34
+ receiveMsgFromKNXCode: { value: "" }
34
35
  },
35
36
  inputs: 1,
36
37
  outputs: 1,
37
38
  icon: "node-knx-icon.svg",
38
39
  label: function () {
39
- return ((this.outputRBE === "true" || this.outputRBE === true) ? "|rbe| " : "") + (this.name || this.topic || "KNX Device") + (this.setTopicType === 'str' || this.setTopicType === undefined ? '' : ' [' + this.setTopicType + ']') + ((this.inputRBE === "true" || this.inputRBE === true) ? " |rbe|" : "")
40
+ const functionSendMsgToKNXCode = (this.sendMsgToKNXCode !== undefined && this.sendMsgToKNXCode !== '') ? "f(x) " : "";
41
+ const functionreceiveMsgFromKNXCode = (this.receiveMsgFromKNXCode !== undefined && this.receiveMsgFromKNXCode !== '') ? " f(x)" : "";
42
+ return ((this.outputRBE === "true" || this.outputRBE === true) ? "|rbe| " : "") + functionSendMsgToKNXCode + (this.name || this.topic || "KNX Device") + (this.setTopicType === 'str' || this.setTopicType === undefined ? '' : ' [' + this.setTopicType + ']') + functionreceiveMsgFromKNXCode + ((this.inputRBE === "true" || this.inputRBE === true) ? " |rbe|" : "")
40
43
  },
41
44
  paletteLabel: "KNX DEVICE",
42
45
  // button: {
@@ -93,61 +96,25 @@
93
96
  }
94
97
  }
95
98
 
96
- node.outputFunctionCodeEditor = RED.editor.createEditor({
97
- id: 'outputFunctionCode-editor',
99
+ node.sendMsgToKNXCodeEditor = RED.editor.createEditor({
100
+ id: 'sendMsgToKNXCode-editor',
98
101
  mode: 'ace/mode/nrjavascript',
99
- value: node.outputFunctionCode
102
+ value: node.sendMsgToKNXCode
100
103
  });
101
- node.inputFunctionCodeEditor = RED.editor.createEditor({
102
- id: 'inputFunctionCode-editor',
104
+ node.receiveMsgFromKNXCodeEditor = RED.editor.createEditor({
105
+ id: 'receiveMsgFromKNXCode-editor',
103
106
  mode: 'ace/mode/nrjavascript',
104
- value: node.inputFunctionCode
107
+ value: node.receiveMsgFromKNXCode
105
108
  });
106
109
  // Snippets
107
110
  $("#snippetOne").on("click", function (event) {
108
- node.outputFunctionCodeEditor.session.setValue(`// @ts-nocheck
109
- // Replace 'x/x/x' with the real status group address.
110
- const statusGA = getGAValue('x/x/x','1.001');
111
- if (msg.payload !== statusGA){ // " !==" means " not equal"
112
- return msg;
113
- }else{
114
- // Both values are identical, so i don't send the msg.
115
- return;
116
- }`);
111
+ node.sendMsgToKNXCodeEditor.session.setValue(KNXFunctionSnippetOne);
117
112
  });
118
113
  $("#snippetTwo").on("click", function (event) {
119
- node.inputFunctionCodeEditor.session.setValue(`// This is a sample of the msg received from the KNX BUS
120
- const inputMSG = {
121
- topic: '0/0/10',
122
- devicename: 'Plafoniera soggiorno [switch]',
123
- payload: false,
124
- payloadmeasureunit: 'unknown',
125
- payloadsubtypevalue: 'Off',
126
- gainfo: {
127
- maingroupname: 'Attuatori luci',
128
- middlegroupname: 'Luci primo piano',
129
- ganame: 'Plafoniera soggiorno [switch]',
130
- maingroupnumber: '0',
131
- middlegroupnumber: '0',
132
- ganumber: '10'
133
- },
134
- knx: {
135
- event: 'GroupValue_Write',
136
- dpt: '1.001',
137
- dptdesc: 'Switch',
138
- source: '15.15.22',
139
- destination: '0/0/10',
140
- rawValue: 'bufferValue'
141
- },
142
- previouspayload: false
143
- }
144
- return msg`);
114
+ node.receiveMsgFromKNXCodeEditor.session.setValue(KNXFunctionSnippetTwo);
145
115
  });
146
116
  $("#snippetThree").on("click", function (event) {
147
- node.inputFunctionCodeEditor.session.setValue(`// @ts-nocheck
148
- // The current msg contains the internal temperature in the "msg.payload" property, but we want to emit the external temperature as well.
149
- msg.externalTemperature = getGAValue('0/0/10'); // In case the ETS file is missing, you must specify the dpt as well: getGAValue('0/0/10','9.001')
150
- return msg;`);
117
+ node.receiveMsgFromKNXCodeEditor.session.setValue(KNXFunctionSnippetThree);
151
118
  });
152
119
 
153
120
  function checkUI() {
@@ -409,8 +376,8 @@ return msg;`);
409
376
  },
410
377
  oneditsave: function () {
411
378
  var node = this;
412
- this.outputFunctionCode = this.outputFunctionCodeEditor.getValue();
413
- this.inputFunctionCode = this.inputFunctionCodeEditor.getValue();
379
+ this.sendMsgToKNXCode = this.sendMsgToKNXCodeEditor.getValue();
380
+ this.receiveMsgFromKNXCode = this.receiveMsgFromKNXCodeEditor.getValue();
414
381
  //this.propertyType = $("#node-input-property").typedInput('type');
415
382
 
416
383
  // 19/02/2020 Warn user that the node will node encode/decode datagram, if Listen All GA's if the config node doesn't contain the csv
@@ -443,10 +410,10 @@ return msg;`);
443
410
  try {
444
411
  node.sampleEditor.destroy();
445
412
  delete node.sampleEditor;
446
- node.outputFunctionCodeEditor.destroy();
447
- delete node.outputFunctionCodeEditor;
448
- node.inputFunctionCodeEditor.destroy();
449
- delete node.inputFunctionCodeEditor;
413
+ node.sendMsgToKNXCodeEditor.destroy();
414
+ delete node.sendMsgToKNXCodeEditor;
415
+ node.receiveMsgFromKNXCodeEditor.destroy();
416
+ delete node.receiveMsgFromKNXCodeEditor;
450
417
  //RED.editor.destroy(); // 23/01/2024 added
451
418
  } catch (error) { }
452
419
 
@@ -456,10 +423,10 @@ return msg;`);
456
423
  try {
457
424
  node.sampleEditor.destroy();
458
425
  delete node.sampleEditor;
459
- node.outputFunctionCodeEditor.destroy();
460
- delete node.outputFunctionCodeEditor;
461
- node.inputFunctionCodeEditor.destroy();
462
- delete node.inputFunctionCodeEditor;
426
+ node.sendMsgToKNXCodeEditor.destroy();
427
+ delete node.sendMsgToKNXCodeEditor;
428
+ node.receiveMsgFromKNXCodeEditor.destroy();
429
+ delete node.receiveMsgFromKNXCodeEditor;
463
430
  RED.editor.destroy(); // 23/01/2024 added
464
431
  } catch (error) { }
465
432
  }
@@ -562,7 +529,7 @@ return msg;`);
562
529
  <div class="form-row" style="padding:10px">
563
530
  <div class="form-row">
564
531
  <dt>
565
- <i class="fa fa-arrow-right"></i>| SEND msg to KNX BUS
532
+ <i class="fa fa-arrow-right"></i>| From node's INPUT PIN to KNX BUS
566
533
  </dt>
567
534
  </div>
568
535
  <div class="form-row">
@@ -588,7 +555,7 @@ return msg;`);
588
555
  <hr>
589
556
  <div class="form-row">
590
557
  <dt>
591
- |<i class="fa fa-arrow-right"></i> RECEIVE msg from KNX BUS
558
+ |<i class="fa fa-arrow-right"></i> From KNX BUS to node's ouput PIN
592
559
  </dt>
593
560
  </div>
594
561
  <div class="form-row" id="divNode-input-initialread">
@@ -706,24 +673,24 @@ return msg;`);
706
673
  <div class="form-row" style="padding:10px">
707
674
  <div class="form-row">
708
675
  <dt>
709
- <i class="fa fa-arrow-right"></i>| SEND msg to KNX BUS
676
+ <i class="fa fa-arrow-right"></i>| From node's INPUT PIN to KNX BUS
710
677
  </dt>
711
678
  </div>
712
679
  <div style="height:200px;min-height:150px;padding:0px;">
713
680
  <div style="height:100%;width:100%;padding:0px;" class="node-text-editor"
714
- id="outputFunctionCode-editor"></div>
681
+ id="sendMsgToKNXCode-editor"></div>
715
682
  </div>
716
683
  <i class="fa fa-code"></i> Select a snippet to be inserted<br />
717
684
  <button type="button" id="snippetOne" class="red-ui-button">Status GA check</button>
718
685
  <hr>
719
686
  <div class="form-row">
720
687
  <dt>
721
- |<i class="fa fa-arrow-right"></i> RECEIVE msg from KNX BUS
688
+ |<i class="fa fa-arrow-right"></i> From KNX BUS to node's OUTPUT PIN
722
689
  </dt>
723
690
  </div>
724
691
  <div style="height:200px;min-height:150px;padding:0px;">
725
692
  <div style="height:100%;width:100%;padding:0px;" class="node-text-editor"
726
- id="inputFunctionCode-editor"></div>
693
+ id="receiveMsgFromKNXCode-editor"></div>
727
694
  </div>
728
695
  <i class="fa fa-code"></i> Select a snippet to be inserted<br />
729
696
  <button type="button" id="snippetTwo" class="red-ui-button">Show msg constructor</button>
@@ -770,12 +737,12 @@ return msg;`);
770
737
  **Advanced options**
771
738
  |Property|Description|
772
739
  |--|--|
773
- ||**SEND msg to KNX BUS**|
740
+ ||**From node's INPUT PIN to KNX BUS**|
774
741
  | Telegram type | *write* to send write telegram (usually, you want that), otherwise you can choose the telegram's type to react to. |
775
- | RBE filter (in the CONTROL section) | *Report by change* filter. If set, only the msg input (from the Flow) having different values each time, will be sent to the KNX bus. If you intend to send everytime the same value, turn it off. |
776
- ||**RECEIVE msg from KNX BUS**|
742
+ | RBE filter | *Report by change* filter. If set, only the msg input (from the Flow) having different values each time, will be sent to the KNX bus. If you intend to send everytime the same value, turn it off. If enabled, "rbe" indication will be added to node's name.|
743
+ ||**From KNX BUS to node's ouput PIN**|
777
744
  | Read status on start | Read group address status, every time Node-Red starts and at every reconnection to the KNX Gateway. The node stores all group address values to a file, so you can choose wether to read from file or from the KNX bus. |
778
- | RBE filter (in the STATUS section)| *Report by change* filter. If set, only the msg output (to KNX bus) having different values each time, will be sent to the msg output's flow. If you intend to send everytime the same value, leave it off. |
745
+ | RBE filter | *Report by change* filter. If set, only the msg output (to KNX bus) having different values each time, will be sent to the msg output's flow. If you intend to send everytime the same value, leave it off. If enabled, "rbe" indication will be added to node's name. |
779
746
  | React to write telegrams | The node will react (will send a msg to the flow) each time it receives a *write* telegram from the KNX bus. Usually, you want that. |
780
747
  | React to response telegrams | The node will react (will send a msg to the flow) each time it receives a *response* telegram from the KNX bus. Usually, you want that for particular scenarios. |
781
748
  | React to read telegrams | The node will react (will send a msg to the flow) each time it receives a *read* telegram from the KNX bus. Usually, you want that if you're want to send a custom value to the KNX BUS. |
@@ -790,14 +757,17 @@ return msg;`);
790
757
 
791
758
  You can use Javascript to modify the behaviour of the input msg coming from the flow and the output telegram sent to the KNX bus.
792
759
  The embedded code editor provides useful objects and functions to retrieve the value of all group addresses, both with the imported ETS file and without (specifying the datapoint).
793
- The script is called everytime the node receives a msg from the flow or a telegram from the KNX BUS.
760
+ The script is called everytime the node receives a msg from the flow or a telegram from the KNX BUS.
761
+ If enabled, "f(x)" indication will be added to node's name.
794
762
 
795
- ### SEND msg to KNX BUS
763
+ ### From KNX BUS to node's OUTPUT PIN
796
764
 
797
765
  List of object and functions you can use in the code
798
766
 
799
767
  : msg (object) : The current msg object received by the node from the flow.
800
768
  : getGAValue (GA as string, DPT as string) : Function. Get the specified GA's value, for example '1/0/1'. **DPT** is optional if you've imported the ETS file, otherwise you must specify it, for example '1.001'.
769
+ : node (object) : The node object.
770
+ : RED (Node-Red object) : The Node-Red's RED object.
801
771
  : return (msg) : Mandatory `return msg;`, if you want to emit the msg to the KNX BUS. Otherwise, using `return;` will not emit any message.
802
772
 
803
773
  In this sample, we'll send the input msg to the KNX BUS only if another GA has opposite value.
@@ -812,12 +782,14 @@ if (msg.payload !== statusGA){ // "!==" means "not equal"
812
782
  }
813
783
  ```
814
784
 
815
- ### RECEIVE msg from KNX BUS
785
+ ### From KNX BUS to node's ouput PIN
816
786
 
817
787
  List of object and functions you can use in the code
818
788
 
819
789
  : msg (object) : The current msg object received by the node from the KNX BUS.
820
790
  : getGAValue (GA as string, DPT as string) : Function. Get the specified GA's value, for example '1/0/1'. **DPT** is optional if you've imported the ETS file, otherwise you must specify it, for example '1.001'.
791
+ : node (object) : The node object.
792
+ : RED (Node-Red object) : The Node-Red's RED object.
821
793
  : return (msg) : Mandatory `return msg;`, if you want to emit the msg to the flow. Otherwise, using `return;` will not emit any message.
822
794
 
823
795
  In this sample, we'll emit the msg object to the flow, by appending the value of another GA to the output msg.
@@ -120,10 +120,10 @@ module.exports = function (RED) {
120
120
  node.inputmessage = {}; // Stores the input message to be passed through
121
121
  node.timerTTLInputMessage = null; // The stored node.inputmessage has a ttl.
122
122
  node.sysLogger = require('./utils/sysLogger.js').get({ loglevel: node.server.loglevel || 'error' }); // 08/04/2021 new logger to adhere to the loglevel selected in the config-window
123
- node.outputFunctionCode = config.outputFunctionCode || undefined;
124
- node.inputFunctionCode = config.inputFunctionCode || undefined;
125
- if (node.outputFunctionCode === '') node.outputFunctionCode = undefined
126
- if (node.inputFunctionCode === '') node.inputFunctionCode = undefined
123
+ node.sendMsgToKNXCode = config.sendMsgToKNXCode || undefined;
124
+ node.receiveMsgFromKNXCode = config.receiveMsgFromKNXCode || undefined;
125
+ if (node.sendMsgToKNXCode === '') node.sendMsgToKNXCode = undefined
126
+ if (node.receiveMsgFromKNXCode === '') node.receiveMsgFromKNXCode = undefined
127
127
 
128
128
  // Check if the node has a valid dpt
129
129
  if (node.listenallga === false) {
@@ -171,13 +171,13 @@ module.exports = function (RED) {
171
171
 
172
172
  // #region "Inject the msg to the JS code, then output msg to the flow"
173
173
  // -+++++++++++++++++++++++++++++++++++++++++++
174
- if (node.outputFunctionCode !== undefined) {
174
+ if (node.receiveMsgFromKNXCode !== undefined) {
175
175
  try {
176
- let outputFunction = new Function('msg', 'getGAValue', node.outputFunctionCode)
177
- msg = outputFunction(msg, getGAValue);
176
+ let receiveMsgFromKNXCode = new Function('msg', 'getGAValue', 'node', 'RED', node.receiveMsgFromKNXCode)
177
+ msg = receiveMsgFromKNXCode(msg, getGAValue, node, RED);
178
178
  } catch (error) {
179
- RED.log.error('knxUltimate: outputFunction: node ID:' + node.id + ' ' + error.message);
180
- if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.error(`knxUltimate: outputFunction: node id ${node.id} ` || ' ' + error.stack);
179
+ RED.log.error('knxUltimate: receiveMsgFromKNXCode: node ID:' + node.id + ' ' + error.message);
180
+ if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.error(`knxUltimate: receiveMsgFromKNXCode: node id ${node.id} ` || ' ' + error.stack);
181
181
  return;
182
182
  }
183
183
  }
@@ -234,14 +234,14 @@ module.exports = function (RED) {
234
234
 
235
235
  // #region "Inject the msg to the JS code, then output msg to the flow"
236
236
  // -+++++++++++++++++++++++++++++++++++++++++++
237
- if (node.inputFunctionCode !== undefined) {
237
+ if (node.sendMsgToKNXCode !== undefined) {
238
238
  try {
239
- let inputFunction = new Function('msg', 'getGAValue', node.inputFunctionCode)
240
- msg = inputFunction(msg, getGAValue);
239
+ let sendMsgToKNXCode = new Function('msg', 'getGAValue', 'node', 'RED', node.sendMsgToKNXCode)
240
+ msg = sendMsgToKNXCode(msg, getGAValue, node, RED);
241
241
  if (msg === undefined) return;
242
242
  } catch (error) {
243
- RED.log.error('knxUltimate: inputFunction: node ID:' + node.id + ' ' + error.message);
244
- if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.error(`knxUltimate: inputFunction: node id ${node.id} ` || ' ' + error.stack);
243
+ RED.log.error('knxUltimate: sendMsgToKNXCode: node ID:' + node.id + ' ' + error.message);
244
+ if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.error(`knxUltimate: sendMsgToKNXCode: node id ${node.id} ` || ' ' + error.stack);
245
245
  return;
246
246
  }
247
247
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "engines": {
4
4
  "node": ">=16.0.0"
5
5
  },
6
- "version": "3.1.0",
6
+ "version": "3.1.2",
7
7
  "description": "Control your KNX intallation via Node-Red! A bunch of KNX nodes, with integrated Philips HUE control and ETS group address importer. Easy to use and highly configurable.",
8
8
  "dependencies": {
9
9
  "binary-parser": "2.2.1",
@@ -0,0 +1,43 @@
1
+ // 31/03/2020 Search Helper
2
+
3
+ const KNXFunctionSnippetOne = `// @ts-nocheck
4
+ // Replace 'x/x/x' with the real status group address.
5
+ const statusGA = getGAValue('x/x/x','1.001');
6
+ if (msg.payload !== statusGA){ // " !==" means " not equal"
7
+ return msg;
8
+ }else{
9
+ // Both values are identical, so i don't send the msg.
10
+ return;
11
+ }`;
12
+
13
+ const KNXFunctionSnippetTwo = `// This is a sample of the msg received from the KNX BUS
14
+ const inputMSG = {
15
+ topic: '0/0/10',
16
+ devicename: 'Plafoniera soggiorno [switch]',
17
+ payload: false,
18
+ payloadmeasureunit: 'unknown',
19
+ payloadsubtypevalue: 'Off',
20
+ gainfo: {
21
+ maingroupname: 'Attuatori luci',
22
+ middlegroupname: 'Luci primo piano',
23
+ ganame: 'Plafoniera soggiorno [switch]',
24
+ maingroupnumber: '0',
25
+ middlegroupnumber: '0',
26
+ ganumber: '10'
27
+ },
28
+ knx: {
29
+ event: 'GroupValue_Write',
30
+ dpt: '1.001',
31
+ dptdesc: 'Switch',
32
+ source: '15.15.22',
33
+ destination: '0/0/10',
34
+ rawValue: 'bufferValue'
35
+ },
36
+ previouspayload: false
37
+ }
38
+ return msg`;
39
+
40
+ const KNXFunctionSnippetThree = `// @ts-nocheck
41
+ // The current msg contains the internal temperature in the "msg.payload" property, but we want to emit the external temperature as well.
42
+ msg.externalTemperature = getGAValue('0/0/10'); // In case the ETS file is missing, you must specify the dpt as well: getGAValue('0/0/10','9.001')
43
+ return msg;`;
@@ -1,164 +0,0 @@
1
- ![Sample Node](img/logo.png)
2
-
3
- [![Donate via PayPal](https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square)](https://www.paypal.me/techtoday)
4
-
5
- <br/>
6
-
7
- # CHANGELOG
8
-
9
-
10
- <p>
11
- <b>Version 1.0.49</b> - April 2024<br/>
12
- - DPT9: auto transform a string value, to a numeric value.<br/>
13
- </p>
14
- <p>
15
- <b>Version 1.0.48</b> - February 2024<br/>
16
- - Maintenance release.<br/>
17
- </p>
18
- <p>
19
- <b>Version 1.0.47</b> - January 2024<br/>
20
- - NEW: added DPT 275.100.<br/>
21
- </p>
22
- <p>
23
- <b>Version 1.0.44</b> - December 2023<br/>
24
- - Fixed DPT 9.001 issue when sending numberso having > 2 decimals.<br/>
25
- </p>
26
- <p>
27
- <b>Version 1.0.43</b> - October 2023<br/>
28
- - Added help description for DPT 3.001 DIMMING stop telegram.<br/>
29
- </p>
30
- <p>
31
- <b>Version 1.0.42</b> - July 2023<br/>
32
- - Quick fix for MDT and Wienzler interfaces.<br/>
33
- </p>
34
- <p>
35
- <b>Version 1.0.41</b> - July 2023<br/>
36
- - Enabled compatibility with KNX Virtual software (BETA).<br/>
37
- </p>
38
- <p>
39
- <b>Version 1.0.39</b> - June 2023<br/>
40
- - Bump dependencies versions.<br/>
41
- - Increased TTL of dgram socket, from 128 to 250.<br/>
42
- - Set max hop count in tunneling/broadcast, from 6 to 7.<br/>
43
- </p>
44
- <p>
45
- <b>Version 1.0.37</b> - June 2023<br/>
46
- - Dependencies versions bump.<br/>
47
- </p>
48
- <p>
49
- <b>Version 1.0.36</b> - June 2023<br/>
50
- - Some internal changes due to integration with NOde-Red node.<br/>
51
- </p>
52
- <p>
53
- <b>Version 1.0.34</b> - March 2023<br/>
54
- - NEW: Added Datapoint 235.001 Tariff.<br/>
55
- </p>
56
- <p>
57
- <b>Version 1.0.33</b> - March 2023<br/>
58
- - NEW: Added Datapoint 29.xxx.<br/>
59
- </p>
60
- <p>
61
- <b>Version 1.0.32</b> - January 2023<br/>
62
- - FIX: Fixed Datapoint 9. There was too many decimals.<br/>
63
- </p>
64
- <p>
65
- <b>Version 1.0.31</b> - January 2023<br/>
66
- - NEW: added Datapoint 28.001: ASCII string (variable length) UTF-8<br/>
67
- </p>
68
- <p>
69
- <b>Version 1.0.30</b> - November 2022<br/>
70
- - NEW: added Datapoints 13.016, 13.1200, 13.1201.<br/>
71
- </p>
72
- <p>
73
- <b>Version 1.0.29</b> - November 2022<br/>
74
- - NEW: added Griesser Datpoint Custom 6001.001.<br/>
75
- </p>
76
- <p>
77
- <b>Version 1.0.28</b> - November 2022<br/>
78
- - NEW: added datapoint 9.009 Airflow.<br/>
79
- </p>
80
- <p>
81
- <b>Version 1.0.27</b> - October 2022<br/>
82
- - FIX: fixed an issue accurring when you put a wrong IP/hostname in the configuration of the gateway. Leaving node running with such wrong configuration, after a month or so, all UDP channels remain occupied until reboot. Thanks to @tarag for reporting that.<br/>
83
- </p>
84
- <p>
85
- <b>Version 1.0.25</b> - September 2022<br/>
86
- - Standardized code.<br/>
87
- </p>
88
- <p>
89
- <b>Version 1.0.24</b> - August 2022<br/>
90
- - Fixed old "new Buffer" syntax, due to future unsupported call.<br/>
91
- </p>
92
- <p>
93
- <b>Version 1.0.23</b> - Juli 2022<br/>
94
- -NEW: Added datapoint 1.024 for Day/Night<br/>
95
- </p>
96
- <p>
97
- <b>Version 1.0.22</b> - June 2022<br/>
98
- - KNX-Secure: completed the Secure_Session_Request and working on Secure_Session_Response.<br/>
99
- </p>
100
- <p>
101
- <b>Version 1.0.21</b> - Mai 2022<br/>
102
- - Fixed an issue in retrieving the local IP, in case of ETH interface not having the "family" property set.<br/>
103
- </p>
104
- <p>
105
- <b>Version 1.0.20</b> - Mai 2022<br/>
106
- - Fixed a compatibility issue introducted in Node 18.<br/>
107
- </p>
108
- <p>
109
- <b>Version 1.0.19</b> - April 2022<br/>
110
- - Protected some functions to avoid issues in case of misuse.<br/>
111
- - The ACK of received telegrams is now called befor the "indication" event is emitted to the client.<br/>
112
- - Fixed some issues in the disconnection mechanism.<br/>
113
- </p>
114
- <p>
115
- <b>Version 1.0.18</b> - April 2022<br/>
116
- - NEW: new event has been added. The ackReceived event is triggered every time a telegram is sent over TunnelUDP or TunnelTCP, after it has been acknowledged or not acknowledged. Please see the full featured sample.js file.<br/>
117
- </p>
118
- <p>
119
- <b>Version 1.0.16</b> - April 2022<br/>
120
- - Changed: the KNX Gateway don't care anymore for ROUTING_LOST_MESSAGE and ROUTING_BUSY. Previously, it was disconnecting. Now it only advises in LOG.<br/>
121
- - Added sample on how to decode incoming datagram's values<br/>
122
- - Updated README and samples.<br/>
123
- </p>
124
- <p>
125
- <b>Version 1.0.15</b> - March 2022<br/>
126
- - Further optimization for the garbage collector.<br/>
127
- </p>
128
- <p>
129
- <b>Version 1.0.14</b> - March 2022<br/>
130
- - Optimized memory allocation to allow the garbage collector to get rid of unref variables.<br/>
131
- </p>
132
- <p>
133
- <b>Version 1.0.13</b> - March 2022<br/>
134
- - Updated samples and fixed disconnection issues is some circumstaces, where the KNX IP Interface doesn't send the DISCONNECT_RESPONSE datagram to confirm the disconnection.<br/>
135
- </p>
136
- <p>
137
- <b>Version 1.0.12</b> - February 2022<br/>
138
- - FIX Datapoint 16.001: fixed an issue with the ISO8859-1 encoding.<br/>
139
- </p>
140
- <p>
141
- <b>Version 1.0.11</b> - February 2022<br/>
142
- - Added the property containing the decoded Keyring file, accessible by all modules referencing the "index.js".<br/>
143
- - Updated the secure sample code.<br/>
144
- </p>
145
- <p>
146
- <b>Version 1.0.10</b> - February 2022<br/>
147
- - Added secure connection sample code.<br/>
148
- </p>
149
- <p>
150
- <b>Version 1.0.9</b> - February 2022<br/>
151
- - Fixed a file not found issue.<br/>
152
- </p>
153
- <p>
154
- <b>Version 1.0.6</b> - February 2022<br/>
155
- - More samples and property specification in the README.<br/>
156
- </p>
157
- <p>
158
- <b>Version 1.0.3</b> - February 2022<br/>
159
- - Added sample in the readme.<br/>
160
- </p>
161
- <p>
162
- <b>Version 1.0.2</b> - February 2022<br/>
163
- - First version.<br/>
164
- </p>
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Massimo
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.