node-red-contrib-knx-ultimate 1.3.10 → 1.3.11

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.11</b> - December 2021<br/>
8
+ - KNX-Ultimate DEVICE node: added the validation of Group Address while deploy, with support for modern addressing up to 31/7/255.<br/>
9
+ </p>
10
+ <p>
7
11
  <b>Version 1.3.10</b> - December 2021<br/>
8
12
  - FIX: fixed a stupid "Disconnected by Message length mismatch 8/16" error due to a dumb find/replace error in the code.<br/>
9
13
  - Added some more log to help resolving issues.<br/>
@@ -13,17 +13,28 @@ const splitIP = (ip, name = 'ip') => {
13
13
  };
14
14
  exports.splitIP = splitIP;
15
15
  const validateKNXAddress = (address, isGroup = false) => {
16
+ // 22/12/2021 Supergiovane: https://support.knx.org/hc/en-us/articles/115003188109-Group-Addresses
16
17
  if (typeof (address) === 'string') {
17
18
  const digits = address.split(/[./]/);
18
- if (digits.length < 2 || digits.length > 3) {
19
- throw new Error(`Invalid address format: ${address}`);
19
+ if (digits.length !== 3) {
20
+ throw new Error(`Invalid address format: ${address} Only 3 level addresses are allowed`);
20
21
  }
21
22
  let count = 0;
22
23
  let newAddress = 0;
23
24
  for (let i = digits.length - 1; i >= 0; i--, count++) {
24
25
  const digit = Number(digits[i]);
25
- if (isNaN(digit) || (count > 1 && digit > 15) || (count === 0 && digit > 255)) {
26
- throw new Error(`Invalid digit at pos ${i} inside address: ${address}`);
26
+ if (isGroup) {
27
+ // Validating Group Address
28
+ if (isNaN(digit) || (count === 2 && digit > 31) || (count === 1 && digit > 7) || (count === 0 && digit > 255)) {
29
+ // 22/12/2021 Supergiovane disabled digits validation
30
+ throw new Error(`Invalid GA digit ${digit} inside address: ${address}`);
31
+ }
32
+ } else {
33
+ // Validating KNX Device Address
34
+ if (isNaN(digit) || (count > 1 && digit > 15) || (count === 0 && digit > 255)) {
35
+ // 22/12/2021 Supergiovane disabled digits validation
36
+ throw new Error(`Invalid Individual Address digit ${digit} inside address: ${address}`);
37
+ }
27
38
  }
28
39
  if (count === 0) {
29
40
  newAddress = digit;
@@ -1,5 +1,6 @@
1
1
  module.exports = function (RED) {
2
2
  const _ = require("lodash");
3
+ const KNXUtils = require("./../KNXEngine/protocol/KNXUtils");
3
4
 
4
5
  function knxUltimate(config) {
5
6
  RED.nodes.createNode(this, config)
@@ -57,15 +58,16 @@ module.exports = function (RED) {
57
58
  }
58
59
 
59
60
  // Check if the node has a valid topic and dpt
60
- if (node.listenallga == false) {
61
- if (typeof node.topic == "undefined" || typeof node.dpt == "undefined") {
61
+ if (node.listenallga === false) {
62
+ if (node.topic === undefined || node.dpt === undefined) {
62
63
  node.setNodeStatus({ fill: "red", shape: "dot", text: "Empty Group Addr. or datapoint.", payload: "", GA: "", dpt: "", devicename: "" })
63
64
  return;
64
65
  } else {
65
-
66
- // topic must be in formar x/x/x
67
- if (node.topic.split("\/").length < 3) {
68
- node.setNodeStatus({ fill: "red", shape: "dot", text: "Wrong group address format.", payload: "", GA: node.topic, dpt: "", devicename: "" })
66
+ // Validate the Address
67
+ try {
68
+ KNXUtils.validateKNXAddress(node.topic, true)
69
+ } catch (error) {
70
+ node.setNodeStatus({ fill: "red", shape: "dot", text: "Wrong group address format." + error.message, payload: "", GA: node.topic, dpt: "", devicename: "" })
69
71
  return;
70
72
  }
71
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-knx-ultimate",
3
- "version": "1.3.10",
3
+ "version": "1.3.11",
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",