node-red-contrib-knx-ultimate 2.1.4 → 2.1.5

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
@@ -7,7 +7,7 @@
7
7
  # CHANGELOG
8
8
 
9
9
  <p>
10
- <b>Version 2.1.4</b> - June 2023<br/>
10
+ <b>Version 2.1.5</b> - June 2023<br/>
11
11
  - NEW: Hue light node: added random color cycle effect group address.<br/>
12
12
  - Fixed destroying KNX nodes.<br/>
13
13
  - Fixed destroying HUE nodes.<br/>
@@ -28,14 +28,6 @@ const convertSubtype = (baseType) => (kv) => {
28
28
  }
29
29
  }
30
30
 
31
- // 06/02/2020 To be tested
32
- // convertSubtype = (baseType) => (kv) => {
33
- // let value = `${baseType.base}.${kv[0]}`
34
- // return {
35
- // value: value
36
- // , text: value + ` (${kv[1].name}${kv[1].unit !== undefined?" - " + kv[1].unit:""})`
37
- // }
38
- // }
39
31
 
40
32
  const toConcattedSubtypes = (acc, baseType) => {
41
33
  const subtypes =
@@ -96,23 +96,37 @@ module.exports = function (RED) {
96
96
  case config.GALightColorCycle:
97
97
  const gaValColorCycle = dptlib.fromBuffer(msg.knx.rawValue, dptlib.resolve(config.dptLightSwitch))
98
98
  if (gaValColorCycle) {
99
+
99
100
  node.serverHue.hueManager.writeHueQueueAdd(config.hueDevice, { on: { on: true } })
100
101
  node.timerColorCycle = setInterval(() => {
101
- function getRandomIntInclusive(min, max) {
102
- min = Math.ceil(min);
103
- max = Math.floor(max);
104
- return Math.floor(Math.random() * (max - min + 1) + min); // The maximum is inclusive and the minimum is inclusive
102
+ try {
103
+ function getRandomIntInclusive(min, max) {
104
+ min = Math.ceil(min);
105
+ max = Math.floor(max);
106
+ return Math.floor(Math.random() * (max - min + 1) + min); // The maximum is inclusive and the minimum is inclusive
107
+ }
108
+ const red = getRandomIntInclusive(0, 255)
109
+ const green = getRandomIntInclusive(0, 255)
110
+ const blue = getRandomIntInclusive(0, 255)
111
+ const gamut = node.currentHUEDevice.color.gamut_type || null
112
+ const retXY = hueColorConverter.ColorConverter.rgbToXy(red, green, blue, gamut)
113
+ const bright = hueColorConverter.ColorConverter.getBrightnessFromRGB(red, green, blue)
114
+ state = bright > 0 ? { on: { on: true }, dimming: { brightness: bright }, color: { xy: retXY } } : { on: { on: false } }
115
+ node.serverHue.hueManager.writeHueQueueAdd(config.hueDevice, state)
116
+ } catch (error) {
117
+ (async () => {
118
+ try {
119
+ const retLight = await node.serverHue.hueManager.getLight(config.hueDevice)
120
+ node.currentHUEDevice = retLight[0]
121
+ RED.log.error('Errore knxUltimateHueLight node.currentHUEDevice Samba ' + error.message)
122
+ } catch (err) {
123
+ RED.log.error('Errore knxUltimateHueLight node.currentHUEDevice Banana ' + err.message)
124
+ }
125
+ })()
105
126
  }
106
- const red = getRandomIntInclusive(0, 255)
107
- const green = getRandomIntInclusive(0, 255)
108
- const blue = getRandomIntInclusive(0, 255)
109
- const gamut = node.currentHUEDevice.color.gamut_type || null
110
- const retXY = hueColorConverter.ColorConverter.rgbToXy(red, green, blue, gamut)
111
- const bright = hueColorConverter.ColorConverter.getBrightnessFromRGB(red, green, blue)
112
- state = bright > 0 ? { on: { on: true }, dimming: { brightness: bright }, color: { xy: retXY } } : { on: { on: false } }
113
- node.serverHue.hueManager.writeHueQueueAdd(config.hueDevice, state)
114
127
  }, 10000);
115
- } else {
128
+
129
+ } else {
116
130
  if (node.timerColorCycle !== undefined) clearInterval(node.timerColorCycle)
117
131
  node.serverHue.hueManager.writeHueQueueAdd(config.hueDevice, { on: { on: false } })
118
132
  }
@@ -203,23 +217,17 @@ module.exports = function (RED) {
203
217
  }
204
218
  if (node.serverHue) {
205
219
  node.serverHue.removeClient(node)
206
- node.serverHue.addClient(node)
207
- setTimeout(() => {
208
- try {
209
- if (node !== null && node.serverHue !== null && node.serverHue.hueManager !== null) {
210
- node.serverHue.hueManager.getLight(config.hueDevice).then(ret => {
211
- try {
212
- if (ret !== undefined && ret.length > 0) node.currentHUEDevice = ret[0]
213
- } catch (error) {
214
- }
215
- //console.log("retrieving node.currentHUEDevice" + node.currentHUEDevice.metadata.name)
216
- })
220
+ if (node !== null && node.serverHue !== null && node.serverHue.hueManager !== null) {
221
+ (async () => {
222
+ try {
223
+ const retLight = await node.serverHue.hueManager.getLight(config.hueDevice)
224
+ node.currentHUEDevice = retLight[0]
225
+ node.serverHue.addClient(node)
226
+ } catch (err) {
227
+ RED.log.error('Errore knxUltimateHueLight node.currentHUEDevice ' + err.message)
217
228
  }
218
- } catch (error) {
219
- console.log('Error: knxUltimateHueLight: node.serverHue.hueManager.getLight: ' + error.message)
220
- }
221
- }, 5000);
222
-
229
+ })()
230
+ }
223
231
  }
224
232
 
225
233
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "engines": {
4
4
  "node": ">=14.0.0"
5
5
  },
6
- "version": "2.1.4",
6
+ "version": "2.1.5",
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 handling.",
8
8
  "dependencies": {
9
9
  "mkdirp": "1.0.4",