node-red-contrib-knx-ultimate 2.2.23 → 2.2.25
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 +8 -1
- package/nodes/hue-config.js +44 -23
- package/nodes/knxUltimate-config.js +2 -2
- package/nodes/knxUltimateHueLight.html +50 -17
- package/nodes/knxUltimateHueLight.js +105 -48
- package/nodes/utils/hueEngine.js +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,14 @@
|
|
|
6
6
|
|
|
7
7
|
# CHANGELOG
|
|
8
8
|
|
|
9
|
-
**Version 2.2.
|
|
9
|
+
**Version 2.2.25** - November 2023<br/>
|
|
10
|
+
- HUE Light: fixed settings of some behaviour options.<br/>
|
|
11
|
+
- You can now query the HUE Light node stati, via a "read" telegram sent to the KNX stati group address. ("Status" is Latin, not English, so the plural is "stati" and not "statuses" nor "status"). Other HUE nodes will follow asap.<br/>
|
|
12
|
+
- Fixed some little bugs.<br/>
|
|
13
|
+
- Fixed an issue where in some circumstances, the HUE Light turn off by itself.<br/>
|
|
14
|
+
- WARNING: the new HUE Light options are to be considered **BETA (= in testing with user feedback)**.<br/>
|
|
15
|
+
|
|
16
|
+
**Version 2.2.24** - November 2023<br/>
|
|
10
17
|
- HUE Light: added DPT 9.002 for direct kelvin selection, with HUE range (2000K-6535K). There is another DPT 7.600 with the KNX scale (0K-6553K) avaiable.<br/>
|
|
11
18
|
- NEW: HUE Light: now you can choose the "switch on" behaviour between color and temperature (in Kelvin) + brightness.<br/>
|
|
12
19
|
- The fontawesome JS is now locally referenced.<br/>
|
package/nodes/hue-config.js
CHANGED
|
@@ -111,29 +111,30 @@ module.exports = (RED) => {
|
|
|
111
111
|
});
|
|
112
112
|
// Connected
|
|
113
113
|
node.hueManager.on("connected", () => {
|
|
114
|
-
node.linkStatus
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
114
|
+
if (node.linkStatus === "disconnected") {
|
|
115
|
+
node.linkStatus = "connected";
|
|
116
|
+
// Start the timer to do initial read.
|
|
117
|
+
if (node.timerDoInitialRead !== null) clearTimeout(node.timerDoInitialRead);
|
|
118
|
+
node.timerDoInitialRead = setTimeout(() => {
|
|
119
|
+
(async () => {
|
|
120
|
+
try {
|
|
121
|
+
await node.loadResourcesFromHUEBridge();
|
|
122
|
+
} catch (error) {
|
|
123
|
+
node.linkStatus = "disconnected";
|
|
124
|
+
node.nodeClients.forEach((_oClient) => {
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
_oClient.setNodeStatusHue({
|
|
127
|
+
fill: "red",
|
|
128
|
+
shape: "ring",
|
|
129
|
+
text: "HUE",
|
|
130
|
+
payload: error.message,
|
|
131
|
+
});
|
|
132
|
+
}, 1000);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
})();
|
|
136
|
+
}, 6000); // 17/02/2020 Do initial read of all nodes requesting initial read
|
|
137
|
+
}
|
|
137
138
|
});
|
|
138
139
|
|
|
139
140
|
node.hueManager.on("disconnected", () => {
|
|
@@ -204,6 +205,25 @@ module.exports = (RED) => {
|
|
|
204
205
|
//})();
|
|
205
206
|
};
|
|
206
207
|
|
|
208
|
+
node.getFirstLightInGroup = function getFirstLightInGroup(_groupID) {
|
|
209
|
+
if (node.hueAllResources === undefined) return;
|
|
210
|
+
// Find the group
|
|
211
|
+
const group = node.hueAllResources.filter((a) => a.id === _groupID)[0];
|
|
212
|
+
if (group === null || group === undefined) return;
|
|
213
|
+
const owner = node.hueAllResources.filter((a) => a.id === group.owner.rid)[0];
|
|
214
|
+
if (owner.children !== undefined && owner.children.length > 0) {
|
|
215
|
+
const firstLightId = owner.children.find((a) => a.rtype === "light").rid;
|
|
216
|
+
if (firstLightId !== undefined && firstLightId !== null) {
|
|
217
|
+
const firstLight = node.hueAllResources.find((a) => a.id === firstLightId);
|
|
218
|
+
if (firstLight !== null && firstLight !== undefined) {
|
|
219
|
+
return firstLight;
|
|
220
|
+
} else {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
207
227
|
// Returns the cached devices (node.hueAllResources) by type.
|
|
208
228
|
node.getResources = function getResources(_rtype) {
|
|
209
229
|
try {
|
|
@@ -425,6 +445,7 @@ module.exports = (RED) => {
|
|
|
425
445
|
if (serverNode === null) {
|
|
426
446
|
RED.log.error(`Warn KNXUltimateGetResourcesHUE serverNode is null`);
|
|
427
447
|
res.json({ devices: `serverNode not set` });
|
|
448
|
+
return;
|
|
428
449
|
}
|
|
429
450
|
const jRet = serverNode.getResources(req.query.rtype);
|
|
430
451
|
if (jRet !== undefined) {
|
|
@@ -1244,7 +1244,7 @@ return msg;`,
|
|
|
1244
1244
|
devicename: msg.devicename,
|
|
1245
1245
|
});
|
|
1246
1246
|
input.handleSend(msg);
|
|
1247
|
-
} else if (input.topic
|
|
1247
|
+
} else if (input.topic === _dest) {
|
|
1248
1248
|
// 04/02/2020 Watchdog implementation
|
|
1249
1249
|
if (input.hasOwnProperty("isWatchDog")) {
|
|
1250
1250
|
// Is a watchdog node
|
|
@@ -1333,7 +1333,7 @@ return msg;`,
|
|
|
1333
1333
|
devicename: msg.devicename,
|
|
1334
1334
|
});
|
|
1335
1335
|
input.handleSend(msg);
|
|
1336
|
-
} else if (input.topic
|
|
1336
|
+
} else if (input.topic === _dest) {
|
|
1337
1337
|
// 04/02/2020 Watchdog implementation
|
|
1338
1338
|
if (input.hasOwnProperty("isWatchDog")) {
|
|
1339
1339
|
// Is a watchdog node
|
|
@@ -73,11 +73,11 @@
|
|
|
73
73
|
GALightKelvinState: { value: "" },
|
|
74
74
|
dptLightKelvinState: { value: "" },
|
|
75
75
|
|
|
76
|
-
specifySwitchOnBrightness: { value: "
|
|
77
|
-
colorAtSwitchOnDayTime: { value: '{"
|
|
76
|
+
specifySwitchOnBrightness: { value: "temperature" },
|
|
77
|
+
colorAtSwitchOnDayTime: { value: '{"kelvin":3000, "brightness":100 }' },
|
|
78
78
|
|
|
79
79
|
enableDayNightLighting: { value: "no" },
|
|
80
|
-
colorAtSwitchOnNightTime: { value: '{"
|
|
80
|
+
colorAtSwitchOnNightTime: { value: '{ "kelvin":2700, "brightness":20 }' },
|
|
81
81
|
|
|
82
82
|
invertDayNight: { value: false },
|
|
83
83
|
|
|
@@ -105,6 +105,27 @@
|
|
|
105
105
|
var oNodeServer = RED.nodes.node($("#node-input-server").val()); // Store the config-node
|
|
106
106
|
var oNodeServerHue = RED.nodes.node($("#node-input-serverHue").val()); // Store the config-node
|
|
107
107
|
|
|
108
|
+
// TIMER BLINK ####################################################
|
|
109
|
+
let blinkStatus = 2;
|
|
110
|
+
let timerBlinkBackground;
|
|
111
|
+
function blinkBackground(_elementIDwithHashAtTheBeginning) {
|
|
112
|
+
if (timerBlinkBackground !== undefined) clearInterval(timerBlinkBackground);
|
|
113
|
+
timerBlinkBackground = setInterval(() => {
|
|
114
|
+
if (isEven(blinkStatus)) $(_elementIDwithHashAtTheBeginning).css("background-color", "lightgreen");
|
|
115
|
+
if (!isEven(blinkStatus)) $(_elementIDwithHashAtTheBeginning).css("background-color", "");
|
|
116
|
+
blinkStatus += 1;
|
|
117
|
+
if (blinkStatus >= 14) {
|
|
118
|
+
clearInterval(timerBlinkBackground);
|
|
119
|
+
blinkStatus = 2;
|
|
120
|
+
$(_elementIDwithHashAtTheBeginning).css("background-color", "");
|
|
121
|
+
}
|
|
122
|
+
}, 100);
|
|
123
|
+
}
|
|
124
|
+
function isEven(n) {
|
|
125
|
+
return (n % 2 == 0);
|
|
126
|
+
}
|
|
127
|
+
// ################################################################
|
|
128
|
+
|
|
108
129
|
$("#tabs").tabs(); // Tabs gestione KNX
|
|
109
130
|
|
|
110
131
|
// 19/02/2020 Used to get the server sooner als deploy.
|
|
@@ -259,6 +280,7 @@
|
|
|
259
280
|
if ($("#node-input-specifySwitchOnBrightness").val() === "yes") {
|
|
260
281
|
$("#divColorsAtSwitchOn").show();
|
|
261
282
|
$("#divTemperatureAtSwitchOn").hide();
|
|
283
|
+
blinkBackground("#colorPickerDay");
|
|
262
284
|
} else if ($("#node-input-specifySwitchOnBrightness").val() === "temperature") {
|
|
263
285
|
$("#divColorsAtSwitchOn").hide();
|
|
264
286
|
$("#divTemperatureAtSwitchOn").show();
|
|
@@ -290,6 +312,8 @@
|
|
|
290
312
|
$("#divCCSBoxAtNightLighting").css({ border: "1px solid dimgrey", "border-radius": "12px", padding: "5px" }); // Add little box to better understand the property page
|
|
291
313
|
$("#divColorsAtSwitchOnNightTime").show();
|
|
292
314
|
$("#divTemperatureAtSwitchOnNightTime").hide();
|
|
315
|
+
blinkBackground("#colorPickerNight")
|
|
316
|
+
$("#getColorAtSwitchOnDayTimeButton").text("Get again");
|
|
293
317
|
} else if ($("#node-input-enableDayNightLighting").val() === "temperature") {
|
|
294
318
|
$("#divEnableDayNightLighting").show();
|
|
295
319
|
$("#divCCSBoxAtNightLighting").css({ border: "1px solid dimgrey", "border-radius": "12px", padding: "5px" }); // Add little box to better understand the property page
|
|
@@ -385,10 +409,7 @@
|
|
|
385
409
|
$.getJSON(sQuery + "?id=" + $("#node-input-hueDevice").val().split("#")[0], (data) => {
|
|
386
410
|
$("#node-input-colorAtSwitchOnDayTime").val(data);
|
|
387
411
|
$("#colorPickerDay").val(data);
|
|
388
|
-
|
|
389
|
-
setTimeout(() => {
|
|
390
|
-
$("#colorPickerDay").css("background-color", "");
|
|
391
|
-
}, 500);
|
|
412
|
+
blinkBackground("#colorPickerDay")
|
|
392
413
|
$("#getColorAtSwitchOnDayTimeButton").text("Get again");
|
|
393
414
|
});
|
|
394
415
|
});
|
|
@@ -402,10 +423,7 @@
|
|
|
402
423
|
$.getJSON(sQuery + "?id=" + $("#node-input-hueDevice").val().split("#")[0], (data) => {
|
|
403
424
|
$("#node-input-colorAtSwitchOnNightTime").val(data);
|
|
404
425
|
$("#colorPickerNight").val(data);
|
|
405
|
-
|
|
406
|
-
setTimeout(() => {
|
|
407
|
-
$("#colorPickerNight").css("background-color", "");
|
|
408
|
-
}, 500);
|
|
426
|
+
blinkBackground("#colorPickerNight")
|
|
409
427
|
$("#getColorAtSwitchOnNightTimeButton").text("Get again");
|
|
410
428
|
});
|
|
411
429
|
});
|
|
@@ -454,6 +472,8 @@
|
|
|
454
472
|
|
|
455
473
|
// Calculate kelvin/color
|
|
456
474
|
let json;
|
|
475
|
+
this.colorAtSwitchOnDayTime = this.colorAtSwitchOnDayTime.replace("geen", "green"); // Old bug in "geen" property
|
|
476
|
+
this.colorAtSwitchOnNightTime = this.colorAtSwitchOnNightTime.replace("geen", "green"); // Old bug in "geen" property
|
|
457
477
|
try {
|
|
458
478
|
json = JSON.parse(this.colorAtSwitchOnDayTime);
|
|
459
479
|
} catch (error) { }
|
|
@@ -461,13 +481,19 @@
|
|
|
461
481
|
// Kelvin
|
|
462
482
|
$("#comboTemperatureAtSwitchOn").val(json.kelvin);
|
|
463
483
|
$("#comboBrightnessAtSwitchOn").val(json.brightness);
|
|
484
|
+
if (this.specifySwitchOnBrightness !== 'no') $("#node-input-specifySwitchOnBrightness").val('temperature'); // Adjust in case of mismatch (from old geen bug)
|
|
464
485
|
} else if (json !== undefined && json.red !== undefined) {
|
|
465
486
|
// Must transform RGB into HTML HEX color
|
|
466
|
-
|
|
487
|
+
try {
|
|
488
|
+
$("#node-input-colorAtSwitchOnDayTime").val("#" + rgbHex(json.red, json.green, json.blue));
|
|
489
|
+
} catch (error) {
|
|
490
|
+
}
|
|
467
491
|
$("#colorPickerDay").val($("#node-input-colorAtSwitchOnDayTime").val());
|
|
492
|
+
if (this.specifySwitchOnBrightness !== 'no') $("#node-input-specifySwitchOnBrightness").val('yes'); // Adjust in case of mismatch (from old geen bug)
|
|
468
493
|
} else {
|
|
469
494
|
// It's already an HEX color
|
|
470
495
|
$("#colorPickerDay").val(this.colorAtSwitchOnDayTime);
|
|
496
|
+
if (this.specifySwitchOnBrightness !== 'no') $("#node-input-specifySwitchOnBrightness").val('yes'); // Adjust in case of mismatch (from old geen bug)
|
|
471
497
|
}
|
|
472
498
|
//Night
|
|
473
499
|
json = undefined;
|
|
@@ -478,15 +504,22 @@
|
|
|
478
504
|
// Kelvin
|
|
479
505
|
$("#comboTemperatureAtSwitchOnNightTime").val(json.kelvin);
|
|
480
506
|
$("#comboBrightnessAtSwitchOnNightTime").val(json.brightness);
|
|
507
|
+
if (this.enableDayNightLighting !== 'no') $("#node-input-enableDayNightLighting").val('temperature'); // Adjust in case of mismatch (from old geen bug)
|
|
481
508
|
} else if (json !== undefined && json.red !== undefined) {
|
|
482
509
|
// Must transform RGB into HTML HEX color
|
|
483
|
-
|
|
510
|
+
try {
|
|
511
|
+
$("#node-input-colorAtSwitchOnNightTime").val("#" + rgbHex(json.red, json.green, json.blue));
|
|
512
|
+
} catch (error) {
|
|
513
|
+
}
|
|
484
514
|
$("#colorPickerNight").val($("#node-input-colorAtSwitchOnNightTime").val());
|
|
515
|
+
if (this.enableDayNightLighting !== 'no') $("#node-input-enableDayNightLighting").val('yes'); // Adjust in case of mismatch (from old geen bug)
|
|
485
516
|
} else {
|
|
486
517
|
// It's already an HEX color
|
|
487
518
|
$("#colorPickerNight").val(this.colorAtSwitchOnNightTime);
|
|
519
|
+
if (this.enableDayNightLighting !== 'no') $("#node-input-enableDayNightLighting").val('yes'); // Adjust in case of mismatch (from old geen bug)
|
|
488
520
|
}
|
|
489
521
|
|
|
522
|
+
|
|
490
523
|
$("#comboTemperatureAtSwitchOn, #comboBrightnessAtSwitchOn").on("change", function () {
|
|
491
524
|
$("#node-input-colorAtSwitchOnDayTime").val('{ "kelvin":' + $("#comboTemperatureAtSwitchOn").val() + ', "brightness":' + $("#comboBrightnessAtSwitchOn").val() + ' }');
|
|
492
525
|
});
|
|
@@ -909,7 +942,7 @@
|
|
|
909
942
|
<i class="fa fa-tag"></i> KNX Brightness Status
|
|
910
943
|
</label>
|
|
911
944
|
<select id="node-input-updateKNXBrightnessStatusOnHUEOnOff">
|
|
912
|
-
<option value="onhueoff">When HUE light is Off
|
|
945
|
+
<option value="onhueoff">When HUE light is Off send 0%. When HUE On, restore previous value (Default KNX behaviour)</option>
|
|
913
946
|
<option value="no">Leave as is (default HUE behaviour)</option>
|
|
914
947
|
</select>
|
|
915
948
|
</div>
|
|
@@ -1088,9 +1121,9 @@ Start typing in the GA field, the name or group address of your KNX device, the
|
|
|
1088
1121
|
|
|
1089
1122
|
| Property | Description |
|
|
1090
1123
|
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1091
|
-
| KNX Brightness Status | Updates the KNX brightness group address status, whenever the HUE lamp is switched ON/OFF. The options are **When HUE light is Off
|
|
1092
|
-
| Switch on behaviour | It sets the behaviour of your lights when switched on. You can choose from differents behaviours.<br/>**Select color:** the light will be switched on with the color of your choice.<br/>**Select temperature and brightness:** the light will be switched on with the temperature (Kelvin) and brightness (0-100) of your choice.<br>**Last status:** the light will be switched on in the last status. |
|
|
1093
|
-
| Night Lighting | It allows to set a particular light color/brightness at nighttime.
|
|
1124
|
+
| KNX Brightness Status | Updates the KNX brightness group address status, whenever the HUE lamp is switched ON/OFF. The options are **When HUE light is Off send 0%. When HUE On, restore previous value (Default KNX behaviour)** and **Leave as is (default HUE behaviour)**. If you have KNX dimmer with brightness status, like MDT, the suggested option is ***When HUE light is Off send 0%. When HUE On, restore previous value (Default KNX behaviour)*** |
|
|
1125
|
+
| Switch on behaviour | It sets the behaviour of your lights when switched on. You can choose from differents behaviours.<br/>**Select color:** the light will be switched on with the color of your choice. To change color, just CLICK on the color selector (under the *Select color* control).<br/>**Select temperature and brightness:** the light will be switched on with the temperature (Kelvin) and brightness (0-100) of your choice.<br>**Last status:** the light will be switched on in the last status. |
|
|
1126
|
+
| Night Lighting | It allows to set a particular light color/brightness at nighttime. The options are the same as the daytime. You could select either a temperature/brightness or color. A cozy temperature of 2700 Kelvin, with a brightness of 10% or 20%, is a good choice for bathroom's night light.|
|
|
1094
1127
|
| Day/Night | Select the group address used to set the day/night behaviour. The group address value is _true_ if daytime, _false_ if nighttime. |
|
|
1095
1128
|
| Invert day/night values | Invert the values of _Day/Night_ group address. Default value is **unchecked**. |
|
|
1096
1129
|
| Dim Speed (ms) | The dimming speed, in Milliseconds. This applies to the **light** and also to the **tunable white** dimming datapoints. It' calculated from 0% to 100%. |
|
|
@@ -15,7 +15,7 @@ module.exports = function (RED) {
|
|
|
15
15
|
node.name = config.name === undefined ? "Hue" : config.name;
|
|
16
16
|
node.outputtopic = node.name;
|
|
17
17
|
node.dpt = "";
|
|
18
|
-
node.notifyreadrequest =
|
|
18
|
+
node.notifyreadrequest = true;
|
|
19
19
|
node.notifyreadrequestalsorespondtobus = "false";
|
|
20
20
|
node.notifyreadrequestalsorespondtobusdefaultvalueifnotinitialized = "";
|
|
21
21
|
node.notifyresponse = false;
|
|
@@ -39,7 +39,8 @@ module.exports = function (RED) {
|
|
|
39
39
|
config.specifySwitchOnBrightnessNightTime = (config.specifySwitchOnBrightnessNightTime === undefined || config.specifySwitchOnBrightnessNightTime === '') ? "no" : config.specifySwitchOnBrightnessNightTime;
|
|
40
40
|
config.colorAtSwitchOnDayTime = (config.colorAtSwitchOnDayTime === '' || config.colorAtSwitchOnDayTime === undefined) ? '{ "kelvin":3000, "brightness":100 }' : config.colorAtSwitchOnDayTime;
|
|
41
41
|
config.colorAtSwitchOnNightTime = (config.colorAtSwitchOnNightTime === '' || config.colorAtSwitchOnNightTime === undefined) ? '{ "kelvin":2700, "brightness":20 }' : config.colorAtSwitchOnNightTime;
|
|
42
|
-
|
|
42
|
+
config.colorAtSwitchOnDayTime = config.colorAtSwitchOnDayTime.replace("geen", "green");
|
|
43
|
+
config.colorAtSwitchOnNightTime = config.colorAtSwitchOnNightTime.replace("geen", "green");
|
|
43
44
|
// Transform HEX in RGB and stringified json in json oblects.
|
|
44
45
|
if (config.colorAtSwitchOnDayTime.indexOf("#") !== -1) {
|
|
45
46
|
// Transform to rgb.
|
|
@@ -334,6 +335,36 @@ module.exports = function (RED) {
|
|
|
334
335
|
default:
|
|
335
336
|
break;
|
|
336
337
|
}
|
|
338
|
+
|
|
339
|
+
// I must respond to query requests (read request) sent from the KNX BUS
|
|
340
|
+
|
|
341
|
+
if (msg.knx.event === "GroupValue_Read" && node.currentHUEDevice !== undefined) {
|
|
342
|
+
let ret;
|
|
343
|
+
switch (msg.knx.destination) {
|
|
344
|
+
case config.GALightState:
|
|
345
|
+
ret = node.currentHUEDevice.on.on;
|
|
346
|
+
if (ret !== undefined) node.updateKNXLightState(ret, "response");
|
|
347
|
+
break;
|
|
348
|
+
case config.GALightColorState:
|
|
349
|
+
ret = node.currentHUEDevice.color.xy;
|
|
350
|
+
if (ret !== undefined) node.updateKNXLightColorState(node.currentHUEDevice.color, "response");
|
|
351
|
+
break;
|
|
352
|
+
case config.GALightHSVState:
|
|
353
|
+
ret = node.currentHUEDevice.color_temperature.mirek;
|
|
354
|
+
if (ret !== undefined) node.updateKNXLightHSVState(ret, "response");
|
|
355
|
+
break;
|
|
356
|
+
case config.GALightBrightnessState:
|
|
357
|
+
ret = node.currentHUEDevice.dimming.brightness;
|
|
358
|
+
if (ret !== undefined) node.updateKNXBrightnessState(ret, "response");
|
|
359
|
+
break;
|
|
360
|
+
case config.GALightKelvinState:
|
|
361
|
+
ret = node.currentHUEDevice.color_temperature.mirek;
|
|
362
|
+
if (ret !== undefined) node.updateKNXLightKelvinState(ret, "response");
|
|
363
|
+
break;
|
|
364
|
+
default:
|
|
365
|
+
break;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
337
368
|
} catch (error) {
|
|
338
369
|
node.status({
|
|
339
370
|
fill: "red",
|
|
@@ -463,6 +494,22 @@ module.exports = function (RED) {
|
|
|
463
494
|
// Output the msg to the flow
|
|
464
495
|
node.send(_event);
|
|
465
496
|
|
|
497
|
+
// As grouped_light doesn't contain all requested properties, i find the first light in the group, and use this below in the code
|
|
498
|
+
// If the event type is grouped light, and there are missing properties, i infer these missing properties from the first light in the group!
|
|
499
|
+
if ((_event.hasOwnProperty("color") || _event.hasOwnProperty("dimming")) && _event.type === 'grouped_light') {
|
|
500
|
+
try {
|
|
501
|
+
const firstLightInGroup = node.serverHue.getFirstLightInGroup(_event.id);
|
|
502
|
+
if (firstLightInGroup !== null && firstLightInGroup !== undefined) {
|
|
503
|
+
if (_event.color === undefined || Object.keys(_event.color).length === 0) {
|
|
504
|
+
_event.color = firstLightInGroup.color;
|
|
505
|
+
}
|
|
506
|
+
if (_event.color_temperature === undefined || Object.keys(_event.color_temperature).length === 0) {
|
|
507
|
+
_event.color_temperature = firstLightInGroup.color_temperature;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
} catch (error) { }
|
|
511
|
+
}
|
|
512
|
+
|
|
466
513
|
if (_event.hasOwnProperty("on")) {
|
|
467
514
|
node.updateKNXLightState(_event.on.on);
|
|
468
515
|
// In case of switch off, set the dim to zero
|
|
@@ -471,17 +518,16 @@ module.exports = function (RED) {
|
|
|
471
518
|
&& (config.updateKNXBrightnessStatusOnHUEOnOff === undefined || config.updateKNXBrightnessStatusOnHUEOnOff === "onhueoff")
|
|
472
519
|
) {
|
|
473
520
|
node.updateKNXBrightnessState(0);
|
|
474
|
-
node.currentHUEDevice.dimming.brightness = 0;
|
|
521
|
+
//node.currentHUEDevice.dimming.brightness = 0;
|
|
475
522
|
}
|
|
476
523
|
node.currentHUEDevice.on.on = _event.on.on;
|
|
477
524
|
}
|
|
525
|
+
|
|
478
526
|
if (_event.hasOwnProperty("color")) {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
node.updateKNXLightColorState(_event.color);
|
|
482
|
-
node.currentHUEDevice.color = _event.color;
|
|
483
|
-
}
|
|
527
|
+
node.updateKNXLightColorState(_event.color);
|
|
528
|
+
node.currentHUEDevice.color = _event.color;
|
|
484
529
|
}
|
|
530
|
+
|
|
485
531
|
if (_event.hasOwnProperty("dimming") && _event.dimming.brightness !== undefined) {
|
|
486
532
|
// Every once on a time, the light transmit the brightness value of 0.39.
|
|
487
533
|
// To avoid wrongly turn light state on, exit
|
|
@@ -520,7 +566,7 @@ module.exports = function (RED) {
|
|
|
520
566
|
};
|
|
521
567
|
|
|
522
568
|
// Leave the name after "function", to avoid <anonymous function> in the stack trace, in caso of errors.
|
|
523
|
-
node.updateKNXBrightnessState = function updateKNXBrightnessState(_value) {
|
|
569
|
+
node.updateKNXBrightnessState = function updateKNXBrightnessState(_value, _outputtype = "write") {
|
|
524
570
|
if (config.GALightBrightnessState !== undefined && config.GALightBrightnessState !== "") {
|
|
525
571
|
const knxMsgPayload = {};
|
|
526
572
|
knxMsgPayload.topic = config.GALightBrightnessState;
|
|
@@ -528,13 +574,15 @@ module.exports = function (RED) {
|
|
|
528
574
|
knxMsgPayload.payload = _value;
|
|
529
575
|
// Send to KNX bus
|
|
530
576
|
if (knxMsgPayload.topic !== "" && knxMsgPayload.topic !== undefined) {
|
|
531
|
-
node.server.
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
577
|
+
if (node.server !== null && node.server !== undefined) {
|
|
578
|
+
node.server.writeQueueAdd({
|
|
579
|
+
grpaddr: knxMsgPayload.topic,
|
|
580
|
+
payload: knxMsgPayload.payload,
|
|
581
|
+
dpt: knxMsgPayload.dpt,
|
|
582
|
+
outputtype: _outputtype,
|
|
583
|
+
nodecallerid: node.id,
|
|
584
|
+
});
|
|
585
|
+
}
|
|
538
586
|
}
|
|
539
587
|
node.setNodeStatusHue({
|
|
540
588
|
fill: "blue",
|
|
@@ -545,7 +593,7 @@ module.exports = function (RED) {
|
|
|
545
593
|
}
|
|
546
594
|
};
|
|
547
595
|
|
|
548
|
-
node.updateKNXLightState = function
|
|
596
|
+
node.updateKNXLightState = function updateKNXLightState(_value, _outputtype = "write") {
|
|
549
597
|
try {
|
|
550
598
|
const knxMsgPayload = {};
|
|
551
599
|
knxMsgPayload.topic = config.GALightState;
|
|
@@ -556,13 +604,15 @@ module.exports = function (RED) {
|
|
|
556
604
|
// Check not to have already sent the value
|
|
557
605
|
// Send to KNX bus
|
|
558
606
|
if (knxMsgPayload.topic !== "" && knxMsgPayload.topic !== undefined) {
|
|
559
|
-
node.server.
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
607
|
+
if (node.server !== null && node.server !== undefined) {
|
|
608
|
+
node.server.writeQueueAdd({
|
|
609
|
+
grpaddr: knxMsgPayload.topic,
|
|
610
|
+
payload: knxMsgPayload.payload,
|
|
611
|
+
dpt: knxMsgPayload.dpt,
|
|
612
|
+
outputtype: _outputtype,
|
|
613
|
+
nodecallerid: node.id,
|
|
614
|
+
});
|
|
615
|
+
}
|
|
566
616
|
}
|
|
567
617
|
node.setNodeStatusHue({
|
|
568
618
|
fill: "blue",
|
|
@@ -576,7 +626,7 @@ module.exports = function (RED) {
|
|
|
576
626
|
}
|
|
577
627
|
};
|
|
578
628
|
|
|
579
|
-
node.updateKNXLightHSVState = function
|
|
629
|
+
node.updateKNXLightHSVState = function updateKNXLightHSVState(_value, _outputtype = "write") {
|
|
580
630
|
if (config.GALightHSVState !== undefined && config.GALightHSVState !== "") {
|
|
581
631
|
const knxMsgPayload = {};
|
|
582
632
|
knxMsgPayload.topic = config.GALightHSVState;
|
|
@@ -587,13 +637,15 @@ module.exports = function (RED) {
|
|
|
587
637
|
}
|
|
588
638
|
// Send to KNX bus
|
|
589
639
|
if (knxMsgPayload.topic !== "" && knxMsgPayload.topic !== undefined) {
|
|
590
|
-
node.server.
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
640
|
+
if (node.server !== null && node.server !== undefined) {
|
|
641
|
+
node.server.writeQueueAdd({
|
|
642
|
+
grpaddr: knxMsgPayload.topic,
|
|
643
|
+
payload: knxMsgPayload.payload,
|
|
644
|
+
dpt: knxMsgPayload.dpt,
|
|
645
|
+
outputtype: _outputtype,
|
|
646
|
+
nodecallerid: node.id,
|
|
647
|
+
});
|
|
648
|
+
}
|
|
597
649
|
}
|
|
598
650
|
node.setNodeStatusHue({
|
|
599
651
|
fill: "blue",
|
|
@@ -604,7 +656,7 @@ module.exports = function (RED) {
|
|
|
604
656
|
}
|
|
605
657
|
};
|
|
606
658
|
|
|
607
|
-
node.updateKNXLightColorState = function updateKNXLightColorState(_value) {
|
|
659
|
+
node.updateKNXLightColorState = function updateKNXLightColorState(_value, _outputtype = "write") {
|
|
608
660
|
if (config.GALightColorState !== undefined && config.GALightColorState !== "") {
|
|
609
661
|
const knxMsgPayload = {};
|
|
610
662
|
knxMsgPayload.topic = config.GALightColorState;
|
|
@@ -614,15 +666,18 @@ module.exports = function (RED) {
|
|
|
614
666
|
_value.xy.y,
|
|
615
667
|
node.currentHUEDevice !== undefined ? node.currentHUEDevice.dimming.brightness : 100,
|
|
616
668
|
);
|
|
669
|
+
knxMsgPayload.payload = { red: knxMsgPayload.payload.r, green: knxMsgPayload.payload.g, blue: knxMsgPayload.payload.b };
|
|
617
670
|
// Send to KNX bus
|
|
618
671
|
if (knxMsgPayload.topic !== "" && knxMsgPayload.topic !== undefined) {
|
|
619
|
-
node.server.
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
672
|
+
if (node.server !== null && node.server !== undefined) {
|
|
673
|
+
node.server.writeQueueAdd({
|
|
674
|
+
grpaddr: knxMsgPayload.topic,
|
|
675
|
+
payload: knxMsgPayload.payload,
|
|
676
|
+
dpt: knxMsgPayload.dpt,
|
|
677
|
+
outputtype: _outputtype,
|
|
678
|
+
nodecallerid: node.id,
|
|
679
|
+
});
|
|
680
|
+
}
|
|
626
681
|
}
|
|
627
682
|
node.setNodeStatusHue({
|
|
628
683
|
fill: "blue",
|
|
@@ -633,7 +688,7 @@ module.exports = function (RED) {
|
|
|
633
688
|
}
|
|
634
689
|
};
|
|
635
690
|
|
|
636
|
-
node.updateKNXLightKelvinState = function updateKNXLightKelvinState(_value) {
|
|
691
|
+
node.updateKNXLightKelvinState = function updateKNXLightKelvinState(_value, _outputtype = "write") {
|
|
637
692
|
if (config.GALightKelvinState !== undefined && config.GALightKelvinState !== "") {
|
|
638
693
|
const knxMsgPayload = {};
|
|
639
694
|
knxMsgPayload.topic = config.GALightKelvinState;
|
|
@@ -645,13 +700,15 @@ module.exports = function (RED) {
|
|
|
645
700
|
}
|
|
646
701
|
// Send to KNX bus
|
|
647
702
|
if (knxMsgPayload.topic !== "" && knxMsgPayload.topic !== undefined) {
|
|
648
|
-
node.server.
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
703
|
+
if (node.server !== null && node.server !== undefined) {
|
|
704
|
+
node.server.writeQueueAdd({
|
|
705
|
+
grpaddr: knxMsgPayload.topic,
|
|
706
|
+
payload: knxMsgPayload.payload,
|
|
707
|
+
dpt: knxMsgPayload.dpt,
|
|
708
|
+
outputtype: _outputtype,
|
|
709
|
+
nodecallerid: node.id,
|
|
710
|
+
});
|
|
711
|
+
}
|
|
655
712
|
|
|
656
713
|
node.setNodeStatusHue({
|
|
657
714
|
fill: "blue",
|
package/nodes/utils/hueEngine.js
CHANGED
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"engines": {
|
|
4
4
|
"node": ">=16.0.0"
|
|
5
5
|
},
|
|
6
|
-
"version": "2.2.
|
|
6
|
+
"version": "2.2.25",
|
|
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",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"simple-get": "4.0.1",
|
|
20
20
|
"xml2js": "0.6.0"
|
|
21
21
|
},
|
|
22
|
+
|
|
22
23
|
"node-red": {
|
|
23
24
|
"version": ">=2.0.0",
|
|
24
25
|
"nodes": {
|