node-red-contrib-knx-ultimate 2.2.18 → 2.2.19

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
@@ -6,6 +6,10 @@
6
6
 
7
7
  # CHANGELOG
8
8
 
9
+ <b>Version 2.2.19</b> - November 2023<br/>
10
+ <p>
11
+ - HUE Bugfix.<br/>
12
+ </p>
9
13
  <b>Version 2.2.18</b> - November 2023<br/>
10
14
  <p>
11
15
  - HUE Bugfix.<br/>
@@ -81,7 +81,7 @@ module.exports = (RED) => {
81
81
  // }
82
82
 
83
83
  // Connect to Bridge and get the resources
84
- node.initHUEConnection = () => {
84
+ node.initHUEConnection = async () => {
85
85
  try {
86
86
  if (node.hueManager !== undefined) node.hueManager.close();
87
87
  } catch (error) { }
@@ -115,7 +115,24 @@ module.exports = (RED) => {
115
115
  // Start the timer to do initial read.
116
116
  if (node.timerDoInitialRead !== null) clearTimeout(node.timerDoInitialRead);
117
117
  node.timerDoInitialRead = setTimeout(() => {
118
- node.loadResourcesFromHUEBridge();
118
+ (async () => {
119
+ try {
120
+ await node.loadResourcesFromHUEBridge();
121
+ } catch (error) {
122
+ node.linkStatus = "disconnected";
123
+ node.nodeClients.forEach((_oClient) => {
124
+ setTimeout(() => {
125
+ _oClient.setNodeStatusHue({
126
+ fill: "red",
127
+ shape: "ring",
128
+ text: "HUE",
129
+ payload: error.message,
130
+ });
131
+ }, 1000);
132
+ });
133
+ }
134
+ node.startWatchdogTimer();
135
+ })();
119
136
  }, 6000); // 17/02/2020 Do initial read of all nodes requesting initial read
120
137
  });
121
138
 
@@ -133,11 +150,12 @@ module.exports = (RED) => {
133
150
  };
134
151
 
135
152
  node.startWatchdogTimer = () => {
153
+ if (node.timerHUEConfigCheckState !== undefined) clearTimeout(node.timerHUEConfigCheckState);
136
154
  node.timerHUEConfigCheckState = setTimeout(() => {
137
155
  (async () => {
138
156
  if (node.linkStatus === "disconnected") {
139
157
  try {
140
- node.initHUEConnection();
158
+ await node.initHUEConnection();
141
159
  } catch (error) {
142
160
  node.linkStatus = "disconnected";
143
161
  }
@@ -149,41 +167,41 @@ module.exports = (RED) => {
149
167
  node.startWatchdogTimer();
150
168
 
151
169
  // Query the HUE Bridge to return the resources
152
- node.loadResourcesFromHUEBridge = () => {
170
+ node.loadResourcesFromHUEBridge = async () => {
153
171
  if (node.linkStatus === "disconnected") return;
154
- (async () => {
155
- // °°°°°° Load ALL resources
156
- try {
157
- node.hueAllResources = await node.hueManager.hueApiV2.get("/resource");
158
- if (node.hueAllResources !== undefined) {
159
- node.hueAllRooms = node.hueAllResources.filter((a) => a.type === "room");
160
- // Update all KNX State of the nodes with the new hue device values
161
- node.nodeClients.forEach((_node) => {
162
- if (_node.hueDevice !== undefined && node.hueAllResources !== undefined) {
163
- const oHUEDevice = node.hueAllResources.filter((a) => a.id === _node.hueDevice)[0];
164
- if (oHUEDevice !== undefined) {
165
- // Add _Node to the clients array
166
- _node.setNodeStatusHue({
167
- fill: "green",
168
- shape: "ring",
169
- text: "Ready :-)",
170
- });
171
- _node.currentHUEDevice = oHUEDevice;
172
- if (_node.initializingAtStart === true) _node.handleSendHUE(oHUEDevice);
173
- }
172
+ //(async () => {
173
+ // °°°°°° Load ALL resources
174
+ try {
175
+ node.hueAllResources = await node.hueManager.hueApiV2.get("/resource");
176
+ if (node.hueAllResources !== undefined) {
177
+ node.hueAllRooms = node.hueAllResources.filter((a) => a.type === "room");
178
+ // Update all KNX State of the nodes with the new hue device values
179
+ node.nodeClients.forEach((_node) => {
180
+ if (_node.hueDevice !== undefined && node.hueAllResources !== undefined) {
181
+ const oHUEDevice = node.hueAllResources.filter((a) => a.id === _node.hueDevice)[0];
182
+ if (oHUEDevice !== undefined) {
183
+ // Add _Node to the clients array
184
+ _node.setNodeStatusHue({
185
+ fill: "green",
186
+ shape: "ring",
187
+ text: "Ready :-)",
188
+ });
189
+ _node.currentHUEDevice = oHUEDevice;
190
+ if (_node.initializingAtStart === true) _node.handleSendHUE(oHUEDevice);
174
191
  }
175
- });
176
- } else {
177
- // The config node cannot read the resources. Signalling disconnected
178
- }
179
- } catch (error) {
180
- if (this.sysLogger !== undefined && this.sysLogger !== null) {
181
- this.sysLogger.error(`KNXUltimatehueEngine: loadResourcesFromHUEBridge: ${error.message}`);
182
- return (error.message);
183
- }
192
+ }
193
+ });
194
+ } else {
195
+ // The config node cannot read the resources. Signalling disconnected
196
+ }
197
+ } catch (error) {
198
+ if (this.sysLogger !== undefined && this.sysLogger !== null) {
199
+ this.sysLogger.error(`KNXUltimatehueEngine: loadResourcesFromHUEBridge: ${error.message}`);
200
+ throw (error);
184
201
  }
185
- return true;
186
- })();
202
+ }
203
+
204
+ //})();
187
205
  };
188
206
 
189
207
  // Returns the cached devices (node.hueAllResources) by type.
@@ -304,7 +322,6 @@ module.exports = (RED) => {
304
322
  // Query HUE Bridge and get the updated color.
305
323
  node.getColorFromHueLight = (_lightId) => {
306
324
  try {
307
- // await node.loadResourcesFromHUEBridge();
308
325
  const oLight = node.hueAllResources.filter((a) => a.id === _lightId)[0];
309
326
  const ret = hueColorConverter.ColorConverter.xyBriToRgb(oLight.color.xy.x, oLight.color.xy.y, oLight.dimming.brightness);
310
327
  return JSON.stringify(ret);
@@ -56,7 +56,7 @@ module.exports = function (RED) {
56
56
 
57
57
  // This function is called by the hue-config.js
58
58
  node.handleSend = (msg) => {
59
- if (node.currentHUEDevice === undefined) {
59
+ if (node.currentHUEDevice === undefined && node.serverHue.linkStatus === "connected") {
60
60
  node.setNodeStatusHue({
61
61
  fill: "yellow",
62
62
  shape: "ring",
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "engines": {
4
4
  "node": ">=16.0.0"
5
5
  },
6
- "version": "2.2.18",
6
+ "version": "2.2.19",
7
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",