node-red-contrib-knx-ultimate 2.2.35 → 2.2.37

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,12 @@
6
6
 
7
7
  # CHANGELOG
8
8
 
9
+ **Version 2.2.37** - December 2023<br/>
10
+ - HUE Light Node: you can now set the DIM direction for tunable white lights. Fixed some issues as well.<br/>
11
+
12
+ **Version 2.2.36** - December 2023<br/>
13
+ - HUE Light Node: Ensure at least one liht belonging to a group was on before switching to nighttime. Otherwise turn all lights on at daytime.<br/>
14
+
9
15
  **Version 2.2.35** - December 2023<br/>
10
16
  - NEW: HUE Light Node: now it resumes the old status of all lights belonging to the selected group.<br/>
11
17
 
@@ -633,6 +633,7 @@
633
633
  colorAtSwitchOnNightTime: { value: '{ "kelvin":2700, "brightness":20 }' },
634
634
 
635
635
  invertDayNight: { value: false },
636
+ invertDimTunableWhiteDirection: { value: false },
636
637
 
637
638
  updateKNXBrightnessStatusOnHUEOnOff: { value: "no" },
638
639
  dimSpeed: { value: 5000, required: false },
@@ -1028,6 +1029,13 @@
1028
1029
  <label for="node-input-nameLightKelvinState" style="width:50px; margin-left: 0px; text-align: right;">Name</label>
1029
1030
  <input type="text" id="node-input-nameLightKelvinState" style="width:190px;margin-left: 5px; text-align: left;">
1030
1031
  </div>
1032
+ <div class="form-row">
1033
+ <label style="width:170px" for="node-input-invertDimTunableWhiteDirection">
1034
+ <i class="fa fa-shuffle"></i> Invert DIM direction
1035
+ </label>
1036
+ <input type="checkbox" id="node-input-invertDimTunableWhiteDirection"
1037
+ style="display:inline-block; width:auto; vertical-align:top;" />
1038
+ </div>
1031
1039
  </p>
1032
1040
  </div>
1033
1041
  <div id="tabs-4">
@@ -1283,7 +1291,7 @@ Start typing in the GA field, the name or group address of your KNX device, the
1283
1291
  | Control kelvin | **DPT 7.600:** set the HUE light's temperature in Kelvin degrees, using the KNX range from 0 to 65536. This range will be then transformed in mirek.<br/>**DPT 9.002:** set the temperature using Philips HUE range: 2000K - 6535K (Ambiance range starts at 2200K). Please be aware, conversion may produce slightly changes in Kelvin degrees value, due to KNX RGB or Kelvin degrees to HUE mirek degrees conversion.|
1284
1292
  | Status %| Link this to the light temperature status group address. Datapoint is 5.001 absolute value. 0 is full warm, 100 is full cold.|
1285
1293
  | Status kelvin | **DPT 7.600:** get the HUE light's temperature in Kelvin degrees, using the KNX range from 0 to 65536. This range will be then transformed in kelvin degrees.<br/>**DPT 9.002:** get the temperature using Philips HUE range: 2000K - 6535K (Ambiance range starts at 2200K). Please be aware, conversion may produce slightly changes in Kelvin degrees value, due to KNX RGB or Kelvin degrees to HUE mirek degrees conversion. |
1286
-
1294
+ | Invert DIM direction | Inverts the DIM direction. |
1287
1295
  <br/>
1288
1296
 
1289
1297
  **Colors**
@@ -45,6 +45,9 @@ module.exports = function (RED) {
45
45
  config.colorAtSwitchOnNightTime = (config.colorAtSwitchOnNightTime === '' || config.colorAtSwitchOnNightTime === undefined) ? '{ "kelvin":2700, "brightness":20 }' : config.colorAtSwitchOnNightTime;
46
46
  config.colorAtSwitchOnDayTime = config.colorAtSwitchOnDayTime.replace("geen", "green");
47
47
  config.colorAtSwitchOnNightTime = config.colorAtSwitchOnNightTime.replace("geen", "green");
48
+ config.dimSpeed = config.dimSpeed === undefined ? 5000 : Number(config.dimSpeed);
49
+ config.invertDimTunableWhiteDirection = config.invertDimTunableWhiteDirection === undefined ? false : true;
50
+
48
51
  // Transform HEX in RGB and stringified json in json oblects.
49
52
  if (config.colorAtSwitchOnDayTime.indexOf("#") !== -1) {
50
53
  // Transform to rgb.
@@ -108,12 +111,11 @@ module.exports = function (RED) {
108
111
  // If you try and control multiple conflicting parameters at once e.g. {"color": {"xy": {"x":0.5,"y":0.5}}, "color_temperature": {"mirek": 250}}
109
112
  // the lights can only physically do one, for this we apply the rule that xy beats ct. Simple.
110
113
  // color_temperature.mirek: color temperature in mirek is null when the light color is not in the ct spectrum
111
- if (node.DayTime === true && config.specifySwitchOnBrightness === "no") {
114
+ if ((node.DayTime === true && config.specifySwitchOnBrightness === "no") && ((node.isGrouped_light === false && node.HUEDeviceWhileDaytime !== null) || (node.isGrouped_light === true && node.HUELightsBelongingToGroupWhileDaytime !== null))) {
112
115
  if (node.isGrouped_light === false && node.HUEDeviceWhileDaytime !== null) {
113
116
  // The DayNight has switched into day, so restore the previous light status
114
117
  state = { on: { on: true }, dimming: node.HUEDeviceWhileDaytime.dimming, color: node.HUEDeviceWhileDaytime.color, color_temperature: node.HUEDeviceWhileDaytime.color_temperature };
115
118
  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
119
  node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, state, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
118
120
  node.setNodeStatusHue({
119
121
  fill: "green",
@@ -121,21 +123,35 @@ module.exports = function (RED) {
121
123
  text: "KNX->HUE",
122
124
  payload: "Restore light status",
123
125
  });
126
+ node.HUEDeviceWhileDaytime = null; // Nullize the object.
124
127
  } else if (node.isGrouped_light === true && node.HUELightsBelongingToGroupWhileDaytime !== null) {
125
128
  // The DayNight has switched into day, so restore the previous light state, belonging to the group
129
+ let bAtLeastOneIsOn = false;
130
+ for (let index = 0; index < node.HUELightsBelongingToGroupWhileDaytime.length; index++) { // Ensure, at least 1 lamp was on, otherwise turn all lamps on
131
+ const element = node.HUELightsBelongingToGroupWhileDaytime[index].light[0];
132
+ if (element.on.on === true) {
133
+ bAtLeastOneIsOn = true;
134
+ break;
135
+ }
136
+ }
126
137
  for (let index = 0; index < node.HUELightsBelongingToGroupWhileDaytime.length; index++) {
127
138
  const element = node.HUELightsBelongingToGroupWhileDaytime[index].light[0];
128
- state = { on: { on: true }, dimming: element.dimming, color: element.color, color_temperature: element.color_temperature };
139
+ if (bAtLeastOneIsOn === true) {
140
+ state = { on: element.on, dimming: element.dimming, color: element.color, color_temperature: element.color_temperature };
141
+ } else {
142
+ // Failsafe all on
143
+ state = { on: { on: true }, dimming: element.dimming, color: element.color, color_temperature: element.color_temperature };
144
+ }
129
145
  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
146
  node.serverHue.hueManager.writeHueQueueAdd(element.id, state, "setLight");
131
147
  }
132
- node.HUELightsBelongingToGroupWhileDaytime = null; // Nullize the object.
133
148
  node.setNodeStatusHue({
134
149
  fill: "green",
135
150
  shape: "dot",
136
151
  text: "KNX->HUE",
137
152
  payload: "Resuming all group's light",
138
153
  });
154
+ node.HUELightsBelongingToGroupWhileDaytime = null; // Nullize the object.
139
155
  return;
140
156
  }
141
157
  } else {
@@ -273,7 +289,7 @@ module.exports = function (RED) {
273
289
  // { decr_incr: 1, data: 1 } : Start increasing until { decr_incr: 0, data: 0 } is received.
274
290
  // { decr_incr: 0, data: 1 } : Start decreasing until { decr_incr: 0, data: 0 } is received.
275
291
  msg.payload = dptlib.fromBuffer(msg.knx.rawValue, dptlib.resolve(config.dptLightHSV));
276
- node.hueDimmingTunableWhite(msg.payload.decr_incr, msg.payload.data, config.dimSpeed);
292
+ node.hueDimmingTunableWhite(msg.payload.decr_incr, msg.payload.data, 5000);
277
293
  node.setNodeStatusHue({
278
294
  fill: "green", shape: "dot", text: "KNX->HUE", payload: JSON.stringify(msg.payload),
279
295
  });
@@ -468,106 +484,137 @@ module.exports = function (RED) {
468
484
 
469
485
  // Start dimming
470
486
  // ***********************************************************
471
- node.hueDimming = function hueDimming(_KNXaction, _KNXbrightness_delta, _dimSpeedInMillisecs = undefined) {
472
- // 31/10/2023 after many attempts to use dimming_delta function of the HueApeV2, loosing days of my life, without a decent success
487
+ node.hueDimming = function hueDimming(_KNXaction, _KNXbrightness_Direction, _dimSpeedInMillisecs = undefined) {
488
+ // 31/10/2023 after many attempts to use dimming_delta function of the HueApeV2, loosing days of my life, without a decent success, will use the standard dimming calculations
473
489
  // i decide to go to the "step brightness" way.
474
- let hueTelegram = {};
475
- const numStep = 10; // Steps from 0 to 100 by 10
476
- if (_dimSpeedInMillisecs === undefined || _dimSpeedInMillisecs === '') _dimSpeedInMillisecs = 5000;
477
-
478
- if (_KNXbrightness_delta === 0 && _KNXaction === 0) {
479
- // STOP DIM
480
- if (node.timerStepDim !== undefined) clearInterval(node.timerStepDim);
481
- node.brightnessStep = null;
482
- return;
483
- }
490
+ try {
491
+ let hueTelegram = {};
492
+ let numStep = 10; // Steps from 0 to 100 by 10
493
+
494
+ if (_KNXbrightness_Direction === 0 && _KNXaction === 0) {
495
+ // STOP DIM
496
+ if (node.timerStepDim !== undefined) clearInterval(node.timerStepDim);
497
+ node.brightnessStep = null;
498
+ return;
499
+ }
484
500
 
485
- // Set the actual brightness to start with
486
- if (node.brightnessStep === null || node.brightnessStep === undefined) node.brightnessStep = node.currentHUEDevice.dimming.brightness || 50;
487
- node.brightnessStep = Math.ceil(Number(node.brightnessStep));
488
-
489
- // Set the speed
490
- _dimSpeedInMillisecs /= numStep;
491
-
492
- // We have also minDimLevelLight and maxDimLevelLight to take care of.
493
- let minDimLevelLight = config.minDimLevelLight === undefined ? 10 : Number(config.minDimLevelLight);
494
- if (config.minDimLevelLight === "useHueLightLevel" && node.currentHUEDevice.dimming.min_dim_level === undefined) minDimLevelLight = 10;
495
- const maxDimLevelLight = config.maxDimLevelLight === undefined ? 100 : Number(config.maxDimLevelLight);
496
-
497
- if (_KNXbrightness_delta > 0 && _KNXaction === 1) {
498
- // DIM UP
499
- if (node.timerStepDim !== undefined) clearInterval(node.timerStepDim);
500
- node.timerStepDim = setInterval(() => {
501
- node.updateKNXBrightnessState(node.brightnessStep); // Unnecessary, but necessary to set the KNX Status in real time.
502
- node.brightnessStep += numStep;
503
- if (node.brightnessStep > maxDimLevelLight) node.brightnessStep = maxDimLevelLight;
504
- hueTelegram = { dimming: { brightness: node.brightnessStep }, dynamics: { duration: _dimSpeedInMillisecs } };
505
- // Switch on the light if off
506
- if (node.currentHUEDevice.on !== undefined && node.currentHUEDevice.on.on === false) {
507
- hueTelegram.on = { on: true };
508
- }
509
- node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, hueTelegram, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
510
- if (node.brightnessStep >= maxDimLevelLight) clearInterval(node.timerStepDim);
511
- }, _dimSpeedInMillisecs);
512
- }
513
- if (_KNXbrightness_delta > 0 && _KNXaction === 0) {
514
- if (node.currentHUEDevice.on.on === false) return; // Don't dim down, if the light is already off.
515
- // DIM DOWN
516
- if (node.timerStepDim !== undefined) clearInterval(node.timerStepDim);
517
- node.timerStepDim = setInterval(() => {
518
- node.updateKNXBrightnessState(node.brightnessStep); // Unnecessary, but necessary to set the KNX Status in real time.
519
- node.brightnessStep -= numStep;
520
- if (node.brightnessStep < minDimLevelLight) node.brightnessStep = minDimLevelLight;
521
- hueTelegram = { dimming: { brightness: node.brightnessStep }, dynamics: { duration: _dimSpeedInMillisecs } };
522
- // Switch off the light if on
523
- if (node.currentHUEDevice.on !== undefined && node.currentHUEDevice.on.on === true && node.brightnessStep === 0) {
524
- hueTelegram.on = { on: false };
525
- }
526
- node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, hueTelegram, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
527
- if (node.brightnessStep <= minDimLevelLight) clearInterval(node.timerStepDim);
528
- }, _dimSpeedInMillisecs);
529
- }
501
+ // Set the actual brightness to start with
502
+ if (node.brightnessStep === null || node.brightnessStep === undefined) node.brightnessStep = node.currentHUEDevice.dimming.brightness || 50;
503
+ node.brightnessStep = Math.ceil(Number(node.brightnessStep));
504
+
505
+ // Set the speed
506
+ _dimSpeedInMillisecs /= numStep;
507
+ numStep = Math.round((config.maxDimLevelLight - config.minDimLevelLight) / numStep, 0);
508
+
509
+ // We have also minDimLevelLight and maxDimLevelLight to take care of.
510
+ let minDimLevelLight = config.minDimLevelLight === undefined ? 10 : Number(config.minDimLevelLight);
511
+ if (config.minDimLevelLight === "useHueLightLevel" && node.currentHUEDevice.dimming.min_dim_level === undefined) minDimLevelLight = 10;
512
+ const maxDimLevelLight = config.maxDimLevelLight === undefined ? 100 : Number(config.maxDimLevelLight);
513
+
514
+ if (_KNXbrightness_Direction > 0 && _KNXaction === 1) {
515
+ // DIM UP
516
+ if (node.timerStepDim !== undefined) clearInterval(node.timerStepDim);
517
+ node.timerStepDim = setInterval(() => {
518
+ node.updateKNXBrightnessState(node.brightnessStep); // Unnecessary, but necessary to set the KNX Status in real time.
519
+ node.brightnessStep += numStep;
520
+ if (node.brightnessStep > maxDimLevelLight) node.brightnessStep = maxDimLevelLight;
521
+ hueTelegram = { dimming: { brightness: node.brightnessStep }, dynamics: { duration: _dimSpeedInMillisecs + 100 } }; // + 100 is to avoid ladder effect
522
+ // Switch on the light if off
523
+ if (node.currentHUEDevice.on !== undefined && node.currentHUEDevice.on.on === false) {
524
+ hueTelegram.on = { on: true };
525
+ }
526
+ node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, hueTelegram, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
527
+ if (node.brightnessStep >= maxDimLevelLight) clearInterval(node.timerStepDim);
528
+ }, _dimSpeedInMillisecs);
529
+ }
530
+ if (_KNXbrightness_Direction > 0 && _KNXaction === 0) {
531
+ if (node.currentHUEDevice.on.on === false) return; // Don't dim down, if the light is already off.
532
+ // DIM DOWN
533
+ if (node.timerStepDim !== undefined) clearInterval(node.timerStepDim);
534
+ node.timerStepDim = setInterval(() => {
535
+ node.updateKNXBrightnessState(node.brightnessStep); // Unnecessary, but necessary to set the KNX Status in real time.
536
+ node.brightnessStep -= numStep;
537
+ if (node.brightnessStep < minDimLevelLight) node.brightnessStep = minDimLevelLight;
538
+ hueTelegram = { dimming: { brightness: node.brightnessStep }, dynamics: { duration: _dimSpeedInMillisecs + 100 } };// + 100 is to avoid ladder effect
539
+ // Switch off the light if on
540
+ if (node.currentHUEDevice.on !== undefined && node.currentHUEDevice.on.on === true && node.brightnessStep === 0) {
541
+ hueTelegram.on = { on: false };
542
+ }
543
+ node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, hueTelegram, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
544
+ if (node.brightnessStep <= minDimLevelLight) clearInterval(node.timerStepDim);
545
+ }, _dimSpeedInMillisecs);
546
+ }
547
+ } catch (error) { }
530
548
  };
531
549
  // ***********************************************************
532
550
 
533
551
  // Start dimming tunable white
534
552
  // mirek: required(integer minimum: 153, maximum: 500)
535
553
  // ***********************************************************
536
- node.hueDimmingTunableWhite = function hueDimming(_KNXaction, _KNXbrightness_delta, _dimSpeedInMillisecs = undefined) {
537
- let dimDirection = "stop";
538
- let hueTelegram = {};
539
- _dimSpeedInMillisecs = _dimSpeedInMillisecs === undefined || _dimSpeedInMillisecs === "" ? 5000 : _dimSpeedInMillisecs;
540
- let delta = 0;
541
- if (node.currentHUEDevice.color_temperature.mirek === undefined) delta = 347 - Math.round(173, 0); // Unable to read the mirek, set medium as default
542
- // We have also minDimLevelLight and maxDimLevelLight to take care of.
543
- // Mirek limits are not taken in consideration.
544
- // Maximum mirek is 347
545
- if (_KNXbrightness_delta === 0 && _KNXaction === 0) {
546
- dimDirection = "stop";
547
- hueTelegram = { color_temperature_delta: { action: dimDirection } };
548
- node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, hueTelegram, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
549
- return;
550
- }
551
- if (_KNXbrightness_delta > 0 && _KNXaction === 1) {
552
- if (node.currentHUEDevice.color_temperature.mirek !== undefined) delta = 347 - Math.round(node.currentHUEDevice.color_temperature.mirek, 0);
553
- dimDirection = "up";
554
- }
555
- if (_KNXbrightness_delta > 0 && _KNXaction === 0) {
556
- // Set the minumum delta, taking care of the minimum brightness specified either in the HUE lamp itself, or specified by the user (parameter node.minDimLevelLight)
557
- if (node.currentHUEDevice.color_temperature.mirek !== undefined) delta = Math.round(node.currentHUEDevice.color_temperature.mirek, 0);
558
- dimDirection = "down";
559
- }
560
- // Calculate the dimming time based on delta
561
- // 10000:x=347:delta
562
- // x = (10000 * delta) / 347
563
- _dimSpeedInMillisecs = Math.round((_dimSpeedInMillisecs * delta) / 347, 0);
564
-
565
- hueTelegram = { color_temperature_delta: { action: dimDirection, mirek_delta: delta }, dynamics: { duration: _dimSpeedInMillisecs } };
566
- // Switch on the light if off
567
- if (node.currentHUEDevice.on !== undefined && node.currentHUEDevice.on.on === false && dimDirection === "up") {
568
- hueTelegram.on = { on: true };
569
- }
570
- node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, hueTelegram, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
554
+ node.hueDimmingTunableWhite = function hueDimming(_KNXaction, _KNXbrightness_DirectionTunableWhite, _dimSpeedInMillisecsTunableWhite = undefined) {
555
+ // 23/23/2023 after many attempts to use dimming_delta function of the HueApeV2, loosing days of my life, without a decent success, will use the standard dimming calculations
556
+ // i decide to go to the "step brightness" way.
557
+ try {
558
+
559
+ if (_KNXbrightness_DirectionTunableWhite === 0 && _KNXaction === 0) {
560
+ // STOP DIM
561
+ if (node.timerStepDimTunableWhite !== undefined) clearInterval(node.timerStepDimTunableWhite);
562
+ node.brightnessStepTunableWhite = null;
563
+ return;
564
+ }
565
+
566
+ let numStepTunableWhite = 10; // Steps from 153 to 500
567
+ if (config.invertDimTunableWhiteDirection === true) {
568
+ if (_KNXaction === 1) { _KNXaction = 0; } else { _KNXaction = 1; }
569
+ }
570
+
571
+ // Set the actual brightness to start with
572
+ if (node.brightnessStepTunableWhite === null || node.brightnessStepTunableWhite === undefined) node.brightnessStepTunableWhite = node.currentHUEDevice.color_temperature.mirek || 372;
573
+ node.brightnessStepTunableWhite = Math.ceil(Number(node.brightnessStepTunableWhite));
574
+
575
+ // Set the speed
576
+ _dimSpeedInMillisecsTunableWhite = Math.ceil(_dimSpeedInMillisecsTunableWhite / numStepTunableWhite);
577
+
578
+ const minDimLevelLightTunableWhite = 153;
579
+ const maxDimLevelLightTunableWhite = 500;
580
+ //numStepTunableWhite = hueColorConverter.ColorConverter.scale(numStepTunableWhite, [0, 100], [minDimLevelLightTunableWhite, maxDimLevelLightTunableWhite]);
581
+ //numStepTunableWhite = hueColorConverter.ColorConverter.scale(numStepTunableWhite, [node.brightnessStepTunableWhite, maxDimLevelLightTunableWhite], [node.brightnessStepTunableWhite, maxDimLevelLightTunableWhite]);
582
+ numStepTunableWhite = Math.round((maxDimLevelLightTunableWhite - minDimLevelLightTunableWhite) / numStepTunableWhite, 0);
583
+
584
+ if (_KNXbrightness_DirectionTunableWhite > 0 && _KNXaction === 1) {
585
+ // DIM UP
586
+ if (node.timerStepDimTunableWhite !== undefined) clearInterval(node.timerStepDimTunableWhite);
587
+ node.timerStepDimTunableWhite = setInterval(() => {
588
+ node.updateKNXLightHSVState(node.brightnessStepTunableWhite); // Unnecessary, but necessary to set the KNX Status in real time.
589
+ node.brightnessStepTunableWhite += numStepTunableWhite; // *2 to speed up the things
590
+ if (node.brightnessStepTunableWhite > maxDimLevelLightTunableWhite) node.brightnessStepTunableWhite = maxDimLevelLightTunableWhite;
591
+ const hueTelegram = { color_temperature: { mirek: node.brightnessStepTunableWhite }, dynamics: { duration: _dimSpeedInMillisecsTunableWhite } };
592
+ // Switch on the light if off
593
+ if (node.currentHUEDevice.on !== undefined && node.currentHUEDevice.on.on === false) {
594
+ hueTelegram.on = { on: true };
595
+ }
596
+ node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, hueTelegram, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
597
+ if (node.brightnessStepTunableWhite >= maxDimLevelLightTunableWhite) clearInterval(node.timerStepDimTunableWhite);
598
+ }, _dimSpeedInMillisecsTunableWhite);
599
+ }
600
+ if (_KNXbrightness_DirectionTunableWhite > 0 && _KNXaction === 0) {
601
+ if (node.currentHUEDevice.on.on === false) return; // Don't dim down, if the light is already off.
602
+ // DIM DOWN
603
+ if (node.timerStepDimTunableWhite !== undefined) clearInterval(node.timerStepDimTunableWhite);
604
+ node.timerStepDimTunableWhite = setInterval(() => {
605
+ node.updateKNXLightHSVState(node.brightnessStepTunableWhite); // Unnecessary, but necessary to set the KNX Status in real time.
606
+ node.brightnessStepTunableWhite -= numStepTunableWhite; // *2 to speed up the things
607
+ if (node.brightnessStepTunableWhite < minDimLevelLightTunableWhite) node.brightnessStepTunableWhite = minDimLevelLightTunableWhite;
608
+ const hueTelegram = { color_temperature: { mirek: node.brightnessStepTunableWhite }, dynamics: { duration: _dimSpeedInMillisecsTunableWhite } };
609
+ // Switch off the light if on
610
+ if (node.currentHUEDevice.on !== undefined && node.currentHUEDevice.on.on === true && node.brightnessStepTunableWhite === 0) {
611
+ hueTelegram.on = { on: false };
612
+ }
613
+ node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, hueTelegram, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
614
+ if (node.brightnessStepTunableWhite <= minDimLevelLightTunableWhite) clearInterval(node.timerStepDimTunableWhite);
615
+ }, _dimSpeedInMillisecsTunableWhite);
616
+ }
617
+ } catch (error) { }
571
618
  };
572
619
  // ***********************************************************
573
620
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "engines": {
4
4
  "node": ">=16.0.0"
5
5
  },
6
- "version": "2.2.35",
6
+ "version": "2.2.37",
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",