node-red-contrib-knx-ultimate 2.2.34 → 2.2.35
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 +3 -0
- package/nodes/hue-config.js +26 -0
- package/nodes/knxUltimateHueLight.js +41 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
# CHANGELOG
|
|
8
8
|
|
|
9
|
+
**Version 2.2.35** - December 2023<br/>
|
|
10
|
+
- NEW: HUE Light Node: now it resumes the old status of all lights belonging to the selected group.<br/>
|
|
11
|
+
|
|
9
12
|
**Version 2.2.34** - December 2023<br/>
|
|
10
13
|
- NEW: HUE Light Node: there is a new tab that auto-generates the light entity for Home Assistant.<br/>
|
|
11
14
|
- HUE Light: resuming the last daytime status after nighttime, if the switch on behaviour at daytime is set to None.<br/>
|
package/nodes/hue-config.js
CHANGED
|
@@ -242,6 +242,32 @@ module.exports = (RED) => {
|
|
|
242
242
|
} catch (error) { }
|
|
243
243
|
};
|
|
244
244
|
|
|
245
|
+
// Return an array of light belonging to the groupID
|
|
246
|
+
node.getAllLightsBelongingToTheGroup = async function getAllLightsBelongingToTheGroup(_groupID) {
|
|
247
|
+
if (node.hueAllResources === undefined || node.hueAllResources === null) return;
|
|
248
|
+
const retArr = [];
|
|
249
|
+
try {
|
|
250
|
+
await node.loadResourcesFromHUEBridge();
|
|
251
|
+
node.hueAllResources.forEach((res) => {
|
|
252
|
+
if (res.services !== undefined && res.services.length > 0) {
|
|
253
|
+
res.services.forEach((serv) => {
|
|
254
|
+
if (serv.rid === _groupID) {
|
|
255
|
+
if (res.children !== undefined) {
|
|
256
|
+
const children = res.children.filter((a) => a.rtype === "light");
|
|
257
|
+
for (let index = 0; index < children.length; index++) {
|
|
258
|
+
const element = children[index];
|
|
259
|
+
const oLight = node.hueAllResources.filter((a) => a.id === element.rid);
|
|
260
|
+
if (oLight !== null && oLight !== undefined) retArr.push({ groupID: _groupID, light: oLight });
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
return retArr;
|
|
268
|
+
} catch (error) { /* empty */ }
|
|
269
|
+
};
|
|
270
|
+
|
|
245
271
|
// Returns the cached devices (node.hueAllResources) by type.
|
|
246
272
|
node.getResources = function getResources(_rtype) {
|
|
247
273
|
try {
|
|
@@ -34,6 +34,7 @@ module.exports = function (RED) {
|
|
|
34
34
|
node.formatdecimalsvalue = 2;
|
|
35
35
|
node.currentHUEDevice = undefined; // At start, this value is filled by a call to HUE api. It stores a value representing the current light status.
|
|
36
36
|
node.HUEDeviceWhileDaytime = null;// This retains the HUE device status while daytime, to be restored after nighttime elapsed.
|
|
37
|
+
node.HUELightsBelongingToGroupWhileDaytime = null; // Array contains all light belonging to the grouped_light (if grouped_light is selected)
|
|
37
38
|
node.DayTime = true;
|
|
38
39
|
node.isGrouped_light = config.hueDevice.split("#")[1] === "grouped_light";
|
|
39
40
|
node.hueDevice = config.hueDevice.split("#")[0];
|
|
@@ -107,11 +108,36 @@ module.exports = function (RED) {
|
|
|
107
108
|
// If you try and control multiple conflicting parameters at once e.g. {"color": {"xy": {"x":0.5,"y":0.5}}, "color_temperature": {"mirek": 250}}
|
|
108
109
|
// the lights can only physically do one, for this we apply the rule that xy beats ct. Simple.
|
|
109
110
|
// color_temperature.mirek: color temperature in mirek is null when the light color is not in the ct spectrum
|
|
110
|
-
if (node.DayTime === true && config.specifySwitchOnBrightness === "no"
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
if (node.DayTime === true && config.specifySwitchOnBrightness === "no") {
|
|
112
|
+
if (node.isGrouped_light === false && node.HUEDeviceWhileDaytime !== null) {
|
|
113
|
+
// The DayNight has switched into day, so restore the previous light status
|
|
114
|
+
state = { on: { on: true }, dimming: node.HUEDeviceWhileDaytime.dimming, color: node.HUEDeviceWhileDaytime.color, color_temperature: node.HUEDeviceWhileDaytime.color_temperature };
|
|
115
|
+
if (node.HUEDeviceWhileDaytime.color_temperature.mirek === null) delete state.color_temperature; // Otherwise the lamp will not turn on due to an error. color_temperature.mirek: color temperature in mirek is null when the light color is not in the ct spectrum
|
|
116
|
+
node.HUEDeviceWhileDaytime = null; // Nullize the object.
|
|
117
|
+
node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, state, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
|
|
118
|
+
node.setNodeStatusHue({
|
|
119
|
+
fill: "green",
|
|
120
|
+
shape: "dot",
|
|
121
|
+
text: "KNX->HUE",
|
|
122
|
+
payload: "Restore light status",
|
|
123
|
+
});
|
|
124
|
+
} else if (node.isGrouped_light === true && node.HUELightsBelongingToGroupWhileDaytime !== null) {
|
|
125
|
+
// The DayNight has switched into day, so restore the previous light state, belonging to the group
|
|
126
|
+
for (let index = 0; index < node.HUELightsBelongingToGroupWhileDaytime.length; index++) {
|
|
127
|
+
const element = node.HUELightsBelongingToGroupWhileDaytime[index].light[0];
|
|
128
|
+
state = { on: { on: true }, dimming: element.dimming, color: element.color, color_temperature: element.color_temperature };
|
|
129
|
+
if (element.color_temperature.mirek === null) delete state.color_temperature; // Otherwise the lamp will not turn on due to an error. color_temperature.mirek: color temperature in mirek is null when the light color is not in the ct spectrum
|
|
130
|
+
node.serverHue.hueManager.writeHueQueueAdd(element.id, state, "setLight");
|
|
131
|
+
}
|
|
132
|
+
node.HUELightsBelongingToGroupWhileDaytime = null; // Nullize the object.
|
|
133
|
+
node.setNodeStatusHue({
|
|
134
|
+
fill: "green",
|
|
135
|
+
shape: "dot",
|
|
136
|
+
text: "KNX->HUE",
|
|
137
|
+
payload: "Resuming all group's light",
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
115
141
|
} else {
|
|
116
142
|
let colorChoosen;
|
|
117
143
|
let temperatureChoosen;
|
|
@@ -219,11 +245,19 @@ module.exports = function (RED) {
|
|
|
219
245
|
if (config.specifySwitchOnBrightness === "no") {
|
|
220
246
|
// This retains the HUE device status while daytime, to be restored after nighttime elapsed. https://github.com/Supergiovane/node-red-contrib-knx-ultimate/issues/298
|
|
221
247
|
if (node.DayTime === false) {
|
|
222
|
-
// DayTime has switched to false: save the currentHUEDevice into the HUEDeviceWhileDaytime
|
|
223
|
-
node.
|
|
248
|
+
if (node.isGrouped_light === false) node.HUEDeviceWhileDaytime = cloneDeep(node.currentHUEDevice); // DayTime has switched to false: save the currentHUEDevice into the HUEDeviceWhileDaytime
|
|
249
|
+
if (node.isGrouped_light === true) {
|
|
250
|
+
(async () => {
|
|
251
|
+
try {
|
|
252
|
+
const retLights = await node.serverHue.getAllLightsBelongingToTheGroup(node.hueDevice);
|
|
253
|
+
node.HUELightsBelongingToGroupWhileDaytime = cloneDeep(retLights); // DayTime has switched to false: save the lights belonging to the group into the HUELightsBelongingToGroupWhileDaytime array
|
|
254
|
+
} catch (error) { }
|
|
255
|
+
})();
|
|
256
|
+
}
|
|
224
257
|
}
|
|
225
258
|
} else {
|
|
226
259
|
node.HUEDeviceWhileDaytime = null;
|
|
260
|
+
node.HUELightsBelongingToGroupWhileDaytime = null;
|
|
227
261
|
}
|
|
228
262
|
node.setNodeStatusHue({
|
|
229
263
|
fill: "green",
|
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.35",
|
|
7
7
|
"description": "Control your KNX intallation via Node-Red! A bunch of KNX nodes, with integrated Philips HUE control and ETS group address importer. Easy to use and highly configurable.",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"binary-parser": "2.2.1",
|