node-red-contrib-knx-ultimate 2.1.63 → 2.2.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.
@@ -1,95 +1,107 @@
1
1
  module.exports = function (RED) {
2
2
  function knxUltimateHueMotion(config) {
3
- RED.nodes.createNode(this, config)
4
- const node = this
5
- node.server = RED.nodes.getNode(config.server)
6
- node.serverHue = RED.nodes.getNode(config.serverHue)
7
- node.topic = node.name
8
- node.name = config.name === undefined ? 'Hue' : config.name
9
- node.dpt = ''
10
- node.notifyreadrequest = false
11
- node.notifyreadrequestalsorespondtobus = 'false'
12
- node.notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized = ''
13
- node.notifyresponse = false
14
- node.notifywrite = true
15
- node.initialread = true
16
- node.listenallga = true // Don't remove
17
- node.outputtype = 'write'
18
- node.outputRBE = false // Apply or not RBE to the output (Messages coming from flow)
19
- node.inputRBE = false // Apply or not RBE to the input (Messages coming from BUS)
20
- node.currentPayload = '' // Current value for the RBE input and for the .previouspayload msg
21
- node.passthrough = 'no'
22
- node.formatmultiplyvalue = 1
23
- node.formatnegativevalue = 'leave'
24
- node.formatdecimalsvalue = 2
3
+ RED.nodes.createNode(this, config);
4
+ const node = this;
5
+ node.server = RED.nodes.getNode(config.server);
6
+ node.serverHue = RED.nodes.getNode(config.serverHue);
7
+ node.topic = node.name;
8
+ node.name = config.name === undefined ? "Hue" : config.name;
9
+ node.dpt = "";
10
+ node.notifyreadrequest = false;
11
+ node.notifyreadrequestalsorespondtobus = "false";
12
+ node.notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized = "";
13
+ node.notifyresponse = false;
14
+ node.notifywrite = true;
15
+ node.initialread = true;
16
+ node.listenallga = true; // Don't remove
17
+ node.outputtype = "write";
18
+ node.outputRBE = false; // Apply or not RBE to the output (Messages coming from flow)
19
+ node.inputRBE = false; // Apply or not RBE to the input (Messages coming from BUS)
20
+ node.currentPayload = ""; // Current value for the RBE input and for the .previouspayload msg
21
+ node.passthrough = "no";
22
+ node.formatmultiplyvalue = 1;
23
+ node.formatnegativevalue = "leave";
24
+ node.formatdecimalsvalue = 2;
25
25
 
26
26
  // Used to call the status update from the config node.
27
- node.setNodeStatus = ({ fill, shape, text, payload }) => {
28
-
29
- }
27
+ node.setNodeStatus = ({ fill, shape, text, payload }) => {};
30
28
  // Used to call the status update from the HUE config node.
31
29
  node.setNodeStatusHue = ({ fill, shape, text, payload }) => {
32
- if (payload === undefined) return
33
- const dDate = new Date()
34
- payload = typeof payload === 'object' ? JSON.stringify(payload) : payload.toString()
35
- node.status({ fill, shape, text: text + ' ' + payload + ' (' + dDate.getDate() + ', ' + dDate.toLocaleTimeString() + ')' })
36
- }
30
+ if (payload === undefined) return;
31
+ const dDate = new Date();
32
+ payload = typeof payload === "object" ? JSON.stringify(payload) : payload.toString();
33
+ node.status({ fill, shape, text: `${text} ${payload} (${dDate.getDate()}, ${dDate.toLocaleTimeString()})` });
34
+ };
37
35
 
38
36
  // This function is called by the knx-ultimate config node, to output a msg.payload.
39
- node.handleSend = msg => {
40
- }
37
+ node.handleSend = (msg) => {};
41
38
 
42
- node.handleSendHUE = _event => {
39
+ node.handleSendHUE = (_event) => {
43
40
  try {
44
41
  if (_event.id === config.hueDevice) {
45
- const knxMsgPayload = {}
46
- knxMsgPayload.topic = config.GAmotion
47
- knxMsgPayload.dpt = config.dptmotion
42
+ const knxMsgPayload = {};
43
+ knxMsgPayload.topic = config.GAmotion;
44
+ knxMsgPayload.dpt = config.dptmotion;
48
45
 
49
- if (_event.hasOwnProperty('motion') && _event.motion.hasOwnProperty('motion')) {
50
- knxMsgPayload.payload = _event.motion.motion
46
+ if (_event.hasOwnProperty("motion") && _event.motion.hasOwnProperty("motion")) {
47
+ knxMsgPayload.payload = _event.motion.motion_report.motion;
51
48
  // Send to KNX bus
52
- if (knxMsgPayload.topic !== '' && knxMsgPayload.topic !== undefined) node.server.writeQueueAdd({ grpaddr: knxMsgPayload.topic, payload: knxMsgPayload.payload, dpt: knxMsgPayload.dpt, outputtype: 'write', nodecallerid: node.id })
53
- node.status({ fill: 'green', shape: 'dot', text: 'HUE->KNX ' + JSON.stringify(knxMsgPayload.payload) + ' (' + new Date().getDate() + ', ' + new Date().toLocaleTimeString() + ')' })
49
+ if (knxMsgPayload.topic !== "" && knxMsgPayload.topic !== undefined) {
50
+ node.server.writeQueueAdd({
51
+ grpaddr: knxMsgPayload.topic,
52
+ payload: knxMsgPayload.payload,
53
+ dpt: knxMsgPayload.dpt,
54
+ outputtype: "write",
55
+ nodecallerid: node.id,
56
+ });
57
+ }
58
+ node.status({
59
+ fill: "green",
60
+ shape: "dot",
61
+ text: `HUE->KNX ${JSON.stringify(knxMsgPayload.payload)} (${new Date().getDate()}, ${new Date().toLocaleTimeString()})`,
62
+ });
54
63
 
55
64
  // Setup the output msg
56
- knxMsgPayload.name = node.name
57
- knxMsgPayload.event = 'motion'
65
+ knxMsgPayload.name = node.name;
66
+ knxMsgPayload.event = "motion";
58
67
 
59
68
  // Send payload
60
- knxMsgPayload.rawEvent = _event
61
- node.send(knxMsgPayload)
62
- node.setNodeStatusHue({ fill: 'blue', shape: 'ring', text: 'HUE->KNX', payload: knxMsgPayload.payload })
69
+ knxMsgPayload.rawEvent = _event;
70
+ node.send(knxMsgPayload);
71
+ node.setNodeStatusHue({
72
+ fill: "blue",
73
+ shape: "ring",
74
+ text: "HUE->KNX",
75
+ payload: knxMsgPayload.payload,
76
+ });
63
77
  }
64
78
  }
65
79
  } catch (error) {
66
- node.status({ fill: 'red', shape: 'dot', text: 'HUE->KNX error ' + error.message + ' (' + new Date().getDate() + ', ' + new Date().toLocaleTimeString() + ')' })
80
+ node.status({ fill: "red", shape: "dot", text: `HUE->KNX error ${error.message} (${new Date().getDate()}, ${new Date().toLocaleTimeString()})` });
67
81
  }
68
- }
82
+ };
69
83
 
70
84
  // On each deploy, unsubscribe+resubscribe
71
85
  if (node.server) {
72
- node.server.removeClient(node)
73
- node.server.addClient(node)
86
+ node.server.removeClient(node);
87
+ node.server.addClient(node);
74
88
  }
75
89
  if (node.serverHue) {
76
- node.serverHue.removeClient(node)
77
- node.serverHue.addClient(node)
90
+ node.serverHue.removeClient(node);
91
+ node.serverHue.addClient(node);
78
92
  }
79
93
 
80
- node.on('input', function (msg) {
81
-
82
- })
94
+ node.on("input", (msg) => {});
83
95
 
84
- node.on('close', function (done) {
96
+ node.on("close", (done) => {
85
97
  if (node.server) {
86
- node.server.removeClient(node)
98
+ node.server.removeClient(node);
87
99
  }
88
100
  if (node.serverHue) {
89
- node.serverHue.removeClient(node)
101
+ node.serverHue.removeClient(node);
90
102
  }
91
- done()
92
- })
103
+ done();
104
+ });
93
105
  }
94
- RED.nodes.registerType('knxUltimateHueMotion', knxUltimateHueMotion)
95
- }
106
+ RED.nodes.registerType("knxUltimateHueMotion", knxUltimateHueMotion);
107
+ };
@@ -260,7 +260,7 @@
260
260
  <script src="https://kit.fontawesome.com/11f26b4500.js" crossorigin="anonymous"></script>
261
261
 
262
262
  <script type="text/markdown" data-help-name="knxUltimateHueScene">
263
- <p> This node lets you recall a HUE scene, via KNX.<br/>
263
+ This node lets you recall a HUE scene, via KNX.
264
264
 
265
265
  Start typing in the GA field, the name or group address of your KNX device, the avaiable devices start showing up while you're typing.
266
266
 
@@ -82,7 +82,7 @@ module.exports = function (RED) {
82
82
  // knxMsgPayload.dpt = config.dptmotion
83
83
 
84
84
  // if (_event.hasOwnProperty('motion') && _event.motion.hasOwnProperty('motion')) {
85
- // knxMsgPayload.payload = _event.motion.motion
85
+ // knxMsgPayload.payload = _event.motion.motion_report.motion
86
86
  // // Send to KNX bus
87
87
  // if (knxMsgPayload.topic !== '' && knxMsgPayload.topic !== undefined) node.server.writeQueueAdd({ grpaddr: knxMsgPayload.topic, payload: knxMsgPayload.payload, dpt: knxMsgPayload.dpt, outputtype: 'write', nodecallerid: node.id })
88
88
  // node.status({ fill: 'green', shape: 'dot', text: 'HUE->KNX ' + JSON.stringify(knxMsgPayload.payload) + ' (' + new Date().getDate() + ', ' + new Date().toLocaleTimeString() + ')' })
@@ -226,7 +226,7 @@
226
226
  <script src="https://kit.fontawesome.com/11f26b4500.js" crossorigin="anonymous"></script>
227
227
 
228
228
  <script type="text/markdown" data-help-name="knxUltimateHueTapDial">
229
- <p> This node lets you get the events from your HUE rotary device, for example the Tap Dial.<br/>
229
+ This node lets you get the events from your HUE rotary device, for example the Tap Dial.
230
230
 
231
231
  The Tap Dial device has 4 buttons and 1 rotary knob.
232
232
  You can find the 4 buttons in the **Hue Button node**, not here!
@@ -147,7 +147,6 @@ module.exports = function (RED) {
147
147
  if (node.timerDimStop !== undefined) clearTimeout(node.timerDimStop);
148
148
  node.isTimerDimStopRunning = true;
149
149
  node.timerDimStop = setTimeout(() => {
150
- console.log('Stop banana');
151
150
  // KNX Stop DIM
152
151
  knxMsgPayload.payload = { decr_incr: 0, data: 0 }; // Payload for the output msg
153
152
  // Send to KNX bus
@@ -158,7 +157,7 @@ module.exports = function (RED) {
158
157
  }
159
158
  if (knxMsgPayload.topic !== '' && knxMsgPayload.topic !== undefined) node.status({ fill: 'green', shape: 'dot', text: 'HUE->KNX Stop DIM' + ` (${new Date().getDate()}, ${new Date().toLocaleTimeString()})` });
160
159
  node.isTimerDimStopRunning = false;
161
- }, 1500);
160
+ }, 500);
162
161
  };
163
162
 
164
163
  // On each deploy, unsubscribe+resubscribe
@@ -220,8 +220,8 @@
220
220
  </script>
221
221
  <script src="https://kit.fontawesome.com/11f26b4500.js" crossorigin="anonymous"></script>
222
222
 
223
- <script type="text/markdown" data-help-name="knxUltimateHueTemperatureSensor">
224
- <p> This node lets you get the events from your HUE temperature device.<br/>
223
+ <script type="text/markdown" data-help-name="knxUltimateHueTemperatureSensor"
224
+ This node lets you get the events from your HUE temperature device.
225
225
 
226
226
  Here you can get the HUE temperature events, that represents a celsius value, evetytime the ambient temp changes.<br/>
227
227
  Start typing in the GA field, the name or group address of your KNX device, the avaiable devices start showing up while you're typing.
@@ -376,7 +376,7 @@ The node turns off one device (or multiple devices) at a time, based on the orde
376
376
 
377
377
  Here you can add devices to turn off in case of overload. <br/>
378
378
  Choose the device to turn off. Enter the device name or its group address. <br/>
379
- Enter any group address that indicates the consumption of the device chosen in the first line. ** This is an optional parameter **. If the device is consuming more than a certain number of Watts, it means that it is in use. If it consumes less, the device will be considered "not in use" and both this and the next will be turned off at once.<br/>
379
+ Enter any group address that indicates the consumption of the device chosen in the first line. **This is an optional parameter**. If the device is consuming more than a certain number of Watts, it means that it is in use. If it consumes less, the device will be considered "not in use" and both this and the next will be turned off at once.<br/>
380
380
  If *Automatic recovery* is enabled, the device is automatically reactivated when the "reset delay" expires.
381
381
 
382
382
  ### Inputs
@@ -80,4 +80,32 @@
80
80
 
81
81
 
82
82
 
83
+ </script>
84
+
85
+ <script type="text/markdown" data-help-name="knxUltimateViewer">
86
+ View all group addresses and their values in a Dashboard widget.
87
+
88
+ This node works in conjunction with the Node-Red dashboard UI Template node.
89
+ View all group addresses and their values in a Dashboard widget.
90
+
91
+ **General**
92
+ |Property|Description|
93
+ |--|--|
94
+ | KNX Gateway | The Gateway you wish to connect to. |
95
+ | Name | The node name |
96
+ |
97
+ <br/>
98
+
99
+ ### Outputs
100
+
101
+ 1. Standard output
102
+ : payload (json) : formatted payload. Connect it directly with the Template UI node.
103
+ 2. Array of objects
104
+ : payload (array) : An array containing all the GA. You can use the array to do your own format and reordering.
105
+
106
+ <br/>
107
+
108
+ [Find it useful?](https://www.paypal.me/techtoday)
109
+
110
+ <br/>
83
111
  </script>
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable max-len */
2
2
  const { EventEmitter } = require('events');
3
3
  const EventSource = require('eventsource');
4
- const http = require('./http.js');
4
+ const http = require('./http');
5
5
 
6
6
  class classHUE extends EventEmitter {
7
7
  constructor(_hueBridgeIP, _username, _clientkey, _bridgeid, _sysLogger) {
@@ -89,6 +89,7 @@ class classHUE extends EventEmitter {
89
89
  if (this.commandQueue.length > 0) {
90
90
  // const jRet = { ...this.commandQueue.shift() } //Clone the object by value
91
91
  const jRet = this.commandQueue.shift();
92
+ // jRet is ({ _lightID, _state, _operation });;
92
93
  switch (jRet._operation) {
93
94
  case 'setLight':
94
95
  // It can be a light or a grouped light
@@ -105,23 +106,6 @@ class classHUE extends EventEmitter {
105
106
  if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.info(`KNXUltimatehueEngine: classHUE: handleQueue: setLight grouped_light: ${error.message}`);
106
107
  }
107
108
  break;
108
- case 'getLight':
109
- try {
110
- const jReturn = await this.hueApiV2.get(`/resource/light/${jRet._lightID}`);
111
- jRet._callback(jReturn[0]); // Need to call the callback, because the event is absolutely async
112
- } catch (error) {
113
- if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.info(`KNXUltimatehueEngine: classHUE: handleQueue: getLight light: ${error.message}`);
114
- }
115
- break;
116
- case 'getGroupedLight':
117
- try {
118
- const jReturn = await this.hueApiV2.get(`/resource/grouped_light/${jRet._lightID}`);
119
- // Need to call the callback, because the event is absolutely async
120
- jRet._callback(jReturn[0]);
121
- } catch (error) {
122
- if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.info(`KNXUltimatehueEngine: classHUE: handleQueue: getLight grouped_light: ${error.message}`);
123
- }
124
- break;
125
109
  case 'setScene':
126
110
  try {
127
111
  const sceneID = jRet._lightID;
@@ -146,14 +130,13 @@ class classHUE extends EventEmitter {
146
130
  case 'getBattery':
147
131
  try {
148
132
  const jReturn = await this.hueApiV2.get(`/resource/device_power/${jRet._lightID}`);
149
- jRet._callback(jReturn[0]); // Need to call the callback, because the event is absolutely async
150
133
  } catch (error) {
151
134
  if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.error(`KNXUltimatehueEngine: classHUE: handleQueue: getBattery: ${error.message}`);
152
135
  }
136
+ break;
153
137
  case 'getLightLevel':
154
138
  try {
155
139
  const jReturn = await this.hueApiV2.get(`/resource/light_level/${jRet._lightID}`);
156
- jRet._callback(jReturn[0]); // Need to call the callback, because the event is absolutely async
157
140
  } catch (error) {
158
141
  if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.error(`KNXUltimatehueEngine: classHUE: handleQueue: getLightLevel: ${error.message}`);
159
142
  }
@@ -161,7 +144,6 @@ class classHUE extends EventEmitter {
161
144
  case 'getTemperature':
162
145
  try {
163
146
  const jReturn = await this.hueApiV2.get(`/resource/temperature/${jRet._lightID}`);
164
- jRet._callback(jReturn[0]); // Need to call the callback, because the event is absolutely async
165
147
  } catch (error) {
166
148
  if (this.sysLogger !== undefined && this.sysLogger !== null) this.sysLogger.error(`KNXUltimatehueEngine: classHUE: handleQueue: getTemperature: ${error.message}`);
167
149
  }
@@ -174,11 +156,9 @@ class classHUE extends EventEmitter {
174
156
  this.timerwriteQueueAdd = setTimeout(this.handleQueue, 200);
175
157
  };
176
158
 
177
- writeHueQueueAdd = async (_lightID, _state, _operation, _callback) => {
159
+ writeHueQueueAdd = async (_lightID, _state, _operation) => {
178
160
  // Add the new item
179
- this.commandQueue.push({
180
- _lightID, _state, _operation, _callback,
181
- });
161
+ this.commandQueue.push({ _lightID, _state, _operation });
182
162
  };
183
163
  // ######################################
184
164
 
package/package.json CHANGED
@@ -3,12 +3,12 @@
3
3
  "engines": {
4
4
  "node": ">=16.0.0"
5
5
  },
6
- "version": "2.1.63",
7
- "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. With integrated Philips HUE devices handling.",
6
+ "version": "2.2.2",
7
+ "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. With integrated Philips HUE devices control.",
8
8
  "dependencies": {
9
9
  "binary-parser": "2.2.1",
10
10
  "color-convert": "2.0.1",
11
- "crypto-js": "4.1.1",
11
+ "crypto-js": "4.2.0",
12
12
  "dns-sync": "0.2.1",
13
13
  "eventsource": "2.0.2",
14
14
  "lodash": "4.17.21",
@@ -52,8 +52,6 @@
52
52
  "KNX",
53
53
  "ETS",
54
54
  "eib",
55
- "eibd",
56
- "knxd",
57
55
  "konnex",
58
56
  "IOT",
59
57
  "hue"
@@ -69,5 +67,28 @@
69
67
  },
70
68
  "scripts": {
71
69
  "test": "standard"
70
+ },
71
+ "Prettier": {
72
+ "arrowParens": "always",
73
+ "bracketSameLine": true,
74
+ "bracketSpacing": false,
75
+ "semi": true,
76
+ "singleQuote": true,
77
+ "jsxSingleQuote": false,
78
+ "quoteProps": "as-needed",
79
+ "trailingComma": "all",
80
+ "singleAttributePerLine": false,
81
+ "htmlWhitespaceSensitivity": "css",
82
+ "vueIndentScriptAndStyle": false,
83
+ "proseWrap": "preserve",
84
+ "insertPragma": false,
85
+ "printWidth": 80,
86
+ "requirePragma": false,
87
+ "tabWidth": 2,
88
+ "useTabs": true,
89
+ "embeddedLanguageFormatting": "auto",
90
+ "[html]": {
91
+ "editor.defaultFormatter": "vscode.html-language-features"
92
+ }
72
93
  }
73
94
  }