node-red-contrib-knx-ultimate 2.2.36 → 2.2.38

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.38** - December 2023<br/>
10
+ - NEW: HUE Light Node: added support for the HUE SMART PLUG.<br/>
11
+
12
+ **Version 2.2.37** - December 2023<br/>
13
+ - HUE Light Node: you can now set the DIM direction for tunable white lights. Fixed some issues as well.<br/>
14
+
9
15
  **Version 2.2.36** - December 2023<br/>
10
16
  - 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/>
11
17
 
@@ -1,6 +1,3 @@
1
- <!-- <script type="application/javascript;charset=utf-8" src="https://kit.fontawesome.com/11f26b4500.js" crossorigin="anonymous"></script>
2
- <script type="application/javascript;charset=utf-8" src="https://cdn.jsdelivr.net/npm/@jaames/iro@5"></script> -->
3
-
4
1
  'use strict'
5
2
  <script type="text/javascript" src="resources/node-red-contrib-knx-ultimate/11f26b4500.js"></script>
6
3
 
@@ -33,10 +30,8 @@
33
30
  }
34
31
  // ################################################################
35
32
 
36
-
37
33
  $("#tabs").tabs(); // Tabs gestione KNX
38
34
 
39
-
40
35
  // 19/02/2020 Used to get the server sooner als deploy.
41
36
  $("#node-input-server").change(function () {
42
37
  try {
@@ -230,6 +225,7 @@
230
225
  .text("No")
231
226
  );
232
227
  }
228
+
233
229
  $("#tabs").tabs("disable", "#tabs-4");
234
230
  $("#tabs").tabs("disable", "#tabs-3");
235
231
  $("#tabs").tabs("disable", "#tabs-2");
@@ -239,11 +235,15 @@
239
235
  $("#divTemperatureAtSwitchOnNightTime").hide();
240
236
  $("#divColorCycle").hide();
241
237
  $("#divUpdateKNXBrightnessStatusOnHUEOnOff").hide();
242
- $("#divMinMaxBrightness").hide();
238
+ $("#divBehaviourBrightness").hide();
243
239
  $("#comboTemperatureAtSwitchOn").hide();
244
240
  $("#comboTemperatureAtSwitchOnNightTime").hide();
245
241
 
246
242
  // Enable options/tabs one by one
243
+ if (oLight.dimming !== undefined) {
244
+ $("#tabs").tabs("enable", "#tabs-2");
245
+ $("#divBehaviourBrightness").show();
246
+ }
247
247
  if (oLight.color !== undefined) {
248
248
  $("#tabs").tabs("enable", "#tabs-4");
249
249
  $("#divColorsAtSwitchOn").show();
@@ -263,7 +263,7 @@
263
263
  // Check temperature (if the light supports temperature, it support dimming as well)
264
264
  if (oLight.color_temperature !== undefined) {
265
265
  $("#tabs").tabs("enable", "#tabs-3");
266
- $("#tabs").tabs("enable", "#tabs-2");
266
+ //$("#tabs").tabs("enable", "#tabs-2");
267
267
  $("#node-input-specifySwitchOnBrightness").append(
268
268
  $("<option>")
269
269
  .val("temperature")
@@ -277,11 +277,11 @@
277
277
  $("#divTemperatureAtSwitchOn").show();
278
278
  $("#divTemperatureAtSwitchOnNightTime").show();
279
279
  $("#divUpdateKNXBrightnessStatusOnHUEOnOff").show();
280
- $("#divMinMaxBrightness").show();
280
+ $("#divBehaviourBrightness").show();
281
281
  $("#comboTemperatureAtSwitchOn").show();
282
282
  $("#comboTemperatureAtSwitchOnNightTime").show();
283
283
  } else {
284
- $("#tabs").tabs("enable", "#tabs-2");
284
+ //$("#tabs").tabs("enable", "#tabs-2");
285
285
  $("#node-input-specifySwitchOnBrightness").append(
286
286
  $("<option>")
287
287
  .val("temperature")
@@ -297,7 +297,7 @@
297
297
  $("#divTemperatureAtSwitchOn").show();
298
298
  $("#divTemperatureAtSwitchOnNightTime").show();
299
299
  $("#divUpdateKNXBrightnessStatusOnHUEOnOff").show();
300
- $("#divMinMaxBrightness").show();
300
+ //$("#divBehaviourBrightness").show();
301
301
  }
302
302
  $("#node-input-specifySwitchOnBrightness").val(node.specifySwitchOnBrightness).trigger('change');
303
303
  $("#node-input-enableDayNightLighting").val(node.enableDayNightLighting).trigger('change');
@@ -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 },
@@ -820,6 +821,8 @@
820
821
 
821
822
  </script>
822
823
 
824
+
825
+
823
826
  <script type="text/html" data-template-name="knxUltimateHueLight">
824
827
 
825
828
  <div class="form-row">
@@ -862,8 +865,7 @@
862
865
 
863
866
  <br />
864
867
 
865
-
866
- <div id="tabs" hidden>
868
+ <div id="tabs" hidden">
867
869
  <ul>
868
870
  <li><a href="#tabs-1"><i class="fa-solid fa-toggle-on fa-beat"></i> Switching</a></li>
869
871
  <li><a href="#tabs-2"><i class="fa-solid fa-arrow-up-wide-short fa-beat"></i> Dim/Brightness</a></li>
@@ -953,7 +955,27 @@
953
955
  data-i18n="knxUltimateHueLight.node-input-name"></span></label>
954
956
  <input type="text" id="node-input-nameLightBrightnessState"
955
957
  style="width:190px;margin-left: 5px; text-align: left;">
958
+ </div>
959
+ <div class="form-row">
960
+ <label for="node-input-dimSpeed" style="width:260px">
961
+ <i class="fa fa-bolt"></i> Dim Speed (ms)
962
+ </label>
963
+ <input type="text" id="node-input-dimSpeed" placeholder='Default is 5000' style="width:210px">
956
964
  </div>
965
+ <div class="form-row">
966
+ <label for="node-input-minDimLevelLight" style="width:260px;">
967
+ <i class="fa fa-clone"></i> Min Dim Brightness
968
+ </label>
969
+ <select id="node-input-minDimLevelLight">
970
+ <option value="useHueLightLevel">Use minimum brightness specified in the HUE light</option>
971
+ </select>
972
+ </div>
973
+ <div class="form-row">
974
+ <label for="node-input-maxDimLevelLight" style="width:260px;">
975
+ <i class="fa fa-clone"></i> Max Dim Brightness
976
+ </label>
977
+ <select id="node-input-maxDimLevelLight"></select>
978
+ </div>
957
979
  </p>
958
980
  </div>
959
981
  <div id="tabs-3">
@@ -1028,6 +1050,13 @@
1028
1050
  <label for="node-input-nameLightKelvinState" style="width:50px; margin-left: 0px; text-align: right;">Name</label>
1029
1051
  <input type="text" id="node-input-nameLightKelvinState" style="width:190px;margin-left: 5px; text-align: left;">
1030
1052
  </div>
1053
+ <div class="form-row">
1054
+ <label style="width:170px" for="node-input-invertDimTunableWhiteDirection">
1055
+ <i class="fa fa-shuffle"></i> Invert DIM direction
1056
+ </label>
1057
+ <input type="checkbox" id="node-input-invertDimTunableWhiteDirection"
1058
+ style="display:inline-block; width:auto; vertical-align:top;" />
1059
+ </div>
1031
1060
  </p>
1032
1061
  </div>
1033
1062
  <div id="tabs-4">
@@ -1121,102 +1150,82 @@
1121
1150
  <option value="no">Leave as is (default HUE behaviour)</option>
1122
1151
  </select>
1123
1152
  </div>
1124
- <div class="form-row">
1125
- <label for="node-input-specifySwitchOnBrightness" style="width:260px;">
1126
- <i class="fa fa-tag"></i> Switch on behaviour
1127
- </label>
1128
- <select id="node-input-specifySwitchOnBrightness">
1129
- <option value="no">None</option>
1130
- <!-- <option value="temperature">Select temperature and brightness</option>
1131
- <option value="yes">Select color</option> -->
1132
- </select>
1133
- </div>
1134
-
1135
- <div class="form-row" id="divColorsAtSwitchOn">
1136
- <label for="node-input-colorAtSwitchOnDayTime" style="width:260px">
1137
- </label>
1138
- <input type="hidden" id="node-input-colorAtSwitchOnDayTime">
1139
- <input type="color" id="colorPickerDay" style="width:260px">
1140
- <button id="getColorAtSwitchOnDayTimeButton" type="button" class="red-ui-button">Get current</button>
1141
- </div>
1142
- <div class="form-row" id="divTemperatureAtSwitchOn" hidden>
1143
- <label for="node-input-colorAtSwitchOnDayTime" style="width:260px">
1144
- </label>
1145
- <select style="width:12%;" id="comboTemperatureAtSwitchOn"></select>
1146
- <select style="width:25%;" id="comboBrightnessAtSwitchOn"></select>
1147
- </div>
1148
-
1149
- <div id="divCCSBoxAtNightLighting">
1153
+ <div id ="divBehaviourBrightness">
1150
1154
  <div class="form-row">
1151
- <label for="node-input-enableDayNightLighting" style="width:260px;">
1152
- <i class="fa fa-clone"></i> Night Lighting
1155
+ <label for="node-input-specifySwitchOnBrightness" style="width:260px;">
1156
+ <i class="fa fa-tag"></i> Switch on behaviour
1153
1157
  </label>
1154
- <select id="node-input-enableDayNightLighting">
1155
- <option value="no">No night lighting</option>
1158
+ <select id="node-input-specifySwitchOnBrightness">
1159
+ <option value="no">None</option>
1156
1160
  <!-- <option value="temperature">Select temperature and brightness</option>
1157
1161
  <option value="yes">Select color</option> -->
1158
1162
  </select>
1159
1163
  </div>
1160
1164
 
1161
- <div id="divEnableDayNightLighting">
1162
-
1163
- <div class="form-row" id="divColorsAtSwitchOnNightTime">
1164
- <label for="node-input-colorAtSwitchOnNightTime" style="width:260px"></label>
1165
- <input type="hidden" id="node-input-colorAtSwitchOnNightTime">
1166
- <input type="color" id="colorPickerNight" style="width:260px">
1167
- <button id="getColorAtSwitchOnNightTimeButton" type="button" class="red-ui-button">Get current</button>
1168
- </div>
1169
- <div class="form-row" id="divTemperatureAtSwitchOnNightTime" hidden>
1170
- <label for="node-input-colorAtSwitchOnNightTime" style="width:260px"></label>
1171
- <select style="width:25%;" id="comboTemperatureAtSwitchOnNightTime"></select>
1172
- <select style="width:25%;" id="comboBrightnessAtSwitchOnNightTime"></select>
1173
- </div>
1165
+ <div class="form-row" id="divColorsAtSwitchOn">
1166
+ <label for="node-input-colorAtSwitchOnDayTime" style="width:260px">
1167
+ </label>
1168
+ <input type="hidden" id="node-input-colorAtSwitchOnDayTime">
1169
+ <input type="color" id="colorPickerDay" style="width:260px">
1170
+ <button id="getColorAtSwitchOnDayTimeButton" type="button" class="red-ui-button">Get current</button>
1171
+ </div>
1172
+ <div class="form-row" id="divTemperatureAtSwitchOn" hidden>
1173
+ <label for="node-input-colorAtSwitchOnDayTime" style="width:260px">
1174
+ </label>
1175
+ <select style="width:12%;" id="comboTemperatureAtSwitchOn"></select>
1176
+ <select style="width:25%;" id="comboBrightnessAtSwitchOn"></select>
1177
+ </div>
1174
1178
 
1179
+ <div id="divCCSBoxAtNightLighting">
1175
1180
  <div class="form-row">
1176
- <label for="node-input-nameDaylightSensor" style="width:110px;"><i class="fa fa-clock-o"></i>
1177
- Day/Night</label>
1178
- <label for="node-input-GADaylightSensor" style="width:20px;">GA</label>
1179
- <input type="text" id="node-input-GADaylightSensor" placeholder="Ex: 1/1/1"
1180
- style="width:70px;margin-left: 5px; text-align: left;">
1181
-
1182
- <label for="node-input-dptDaylightSensor" style="width:40px; margin-left: 0px; text-align: right;">DPT</label>
1183
- <select id="node-input-dptDaylightSensor" style="width:140px;"></select>
1184
-
1185
- <label for="node-input-nameDaylightSensor" style="width:50px; margin-left: 0px; text-align: right;"><span
1186
- data-i18n="knxUltimateHueLight.node-input-name"></span></label>
1187
- <input type="text" id="node-input-nameDaylightSensor" style="width:190px;margin-left: 5px; text-align: left;">
1188
- </div>
1189
- <div class="form-row">
1190
- <label style="width:170px" for="node-input-invertDayNight">
1191
- <i class="fa fa-shuffle"></i> Invert day/night values
1181
+ <label for="node-input-enableDayNightLighting" style="width:260px;">
1182
+ <i class="fa fa-clone"></i> Night Lighting
1192
1183
  </label>
1193
- <input type="checkbox" id="node-input-invertDayNight"
1194
- style="display:inline-block; width:auto; vertical-align:top;" />
1184
+ <select id="node-input-enableDayNightLighting">
1185
+ <option value="no">No night lighting</option>
1186
+ <!-- <option value="temperature">Select temperature and brightness</option>
1187
+ <option value="yes">Select color</option> -->
1188
+ </select>
1189
+ </div>
1190
+
1191
+ <div id="divEnableDayNightLighting">
1192
+
1193
+ <div class="form-row" id="divColorsAtSwitchOnNightTime">
1194
+ <label for="node-input-colorAtSwitchOnNightTime" style="width:260px"></label>
1195
+ <input type="hidden" id="node-input-colorAtSwitchOnNightTime">
1196
+ <input type="color" id="colorPickerNight" style="width:260px">
1197
+ <button id="getColorAtSwitchOnNightTimeButton" type="button" class="red-ui-button">Get current</button>
1198
+ </div>
1199
+ <div class="form-row" id="divTemperatureAtSwitchOnNightTime" hidden>
1200
+ <label for="node-input-colorAtSwitchOnNightTime" style="width:260px"></label>
1201
+ <select style="width:25%;" id="comboTemperatureAtSwitchOnNightTime"></select>
1202
+ <select style="width:25%;" id="comboBrightnessAtSwitchOnNightTime"></select>
1203
+ </div>
1204
+
1205
+ <div class="form-row">
1206
+ <label for="node-input-nameDaylightSensor" style="width:110px;"><i class="fa fa-clock-o"></i>
1207
+ Day/Night</label>
1208
+ <label for="node-input-GADaylightSensor" style="width:20px;">GA</label>
1209
+ <input type="text" id="node-input-GADaylightSensor" placeholder="Ex: 1/1/1"
1210
+ style="width:70px;margin-left: 5px; text-align: left;">
1211
+
1212
+ <label for="node-input-dptDaylightSensor" style="width:40px; margin-left: 0px; text-align: right;">DPT</label>
1213
+ <select id="node-input-dptDaylightSensor" style="width:140px;"></select>
1214
+
1215
+ <label for="node-input-nameDaylightSensor" style="width:50px; margin-left: 0px; text-align: right;"><span
1216
+ data-i18n="knxUltimateHueLight.node-input-name"></span></label>
1217
+ <input type="text" id="node-input-nameDaylightSensor" style="width:190px;margin-left: 5px; text-align: left;">
1218
+ </div>
1219
+ <div class="form-row">
1220
+ <label style="width:170px" for="node-input-invertDayNight">
1221
+ <i class="fa fa-shuffle"></i> Invert day/night values
1222
+ </label>
1223
+ <input type="checkbox" id="node-input-invertDayNight"
1224
+ style="display:inline-block; width:auto; vertical-align:top;" />
1225
+ </div>
1195
1226
  </div>
1196
1227
  </div>
1197
- </div>
1198
- <br />
1199
- <div class="form-row">
1200
- <label for="node-input-dimSpeed" style="width:260px">
1201
- <i class="fa fa-bolt"></i> Dim Speed (ms)
1202
- </label>
1203
- <input type="text" id="node-input-dimSpeed" placeholder='Default is 5000' style="width:260px">
1204
- </div>
1205
- <div id ="divMinMaxBrightness">
1206
- <div class="form-row">
1207
- <label for="node-input-minDimLevelLight" style="width:260px;">
1208
- <i class="fa fa-clone"></i> Min Dim Brightness
1209
- </label>
1210
- <select id="node-input-minDimLevelLight">
1211
- <option value="useHueLightLevel">Use minimum brightness specified in the HUE light</option>
1212
- </select>
1213
- </div>
1214
- <div class="form-row">
1215
- <label for="node-input-maxDimLevelLight" style="width:260px;">
1216
- <i class="fa fa-clone"></i> Max Dim Brightness
1217
- </label>
1218
- <select id="node-input-maxDimLevelLight"></select>
1219
- </div>
1228
+ <br/>
1220
1229
  </div>
1221
1230
  <div class="form-row">
1222
1231
  <label for="node-input-enableNodePINS" style="width:260px;">
@@ -1271,7 +1280,10 @@ Start typing in the GA field, the name or group address of your KNX device, the
1271
1280
  |--|--|
1272
1281
  | Control | Relative DIM the HUE light. You can set the dimming speed in the **_Behaviour_** tab. |
1273
1282
  | Control % | Changes the absolute HUE light's brightness (0-100%)|
1274
- | Status| Link this to the light's brightness status group address |
1283
+ | Status| Link this to the light's brightness status KNX group address |
1284
+ | 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%. |
1285
+ | Min Dim brightness | Tha Minimum brightness that the lamp can reach. For example, if you are dimming the light down, the light will stop dimming at the specified brightness %. |
1286
+ | Max Dim brightness | Tha Maximum brightness that the lamp can reach. For example, if you are dimming the light up, the light will stop dimming at the specified brightness %. |
1275
1287
 
1276
1288
  <br/>
1277
1289
 
@@ -1283,7 +1295,7 @@ Start typing in the GA field, the name or group address of your KNX device, the
1283
1295
  | 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
1296
  | 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
1297
  | 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
-
1298
+ | Invert DIM direction | Inverts the DIM direction. |
1287
1299
  <br/>
1288
1300
 
1289
1301
  **Colors**
@@ -1311,9 +1323,6 @@ Start typing in the GA field, the name or group address of your KNX device, the
1311
1323
  | 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.|
1312
1324
  | Day/Night | Select the group address used to set the day/night behaviour. The group address value is _true_ if daytime, _false_ if nighttime. |
1313
1325
  | Invert day/night values | Invert the values of _Day/Night_ group address. Default value is **unchecked**. |
1314
- | 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%. |
1315
- | Min Dim brightness | Tha Minimum brightness that the lamp can reach. For example, if you are dimming the light down, the light will stop dimming at the specified brightness %. |
1316
- | Max Dim brightness | Tha Maximum brightness that the lamp can reach. For example, if you are dimming the light up, the light will stop dimming at the specified brightness %. |
1317
1326
  | Read status at startup | Read the status at startup and emit the event to the KNX bus at startup/reconnection. (Default "no")|
1318
1327
  | Node Input/Output PINs | Hide or show the input/output PINs. Input/output PINS allow the node to accept msg input from the flow and send msg output to the flow. Input msg must follow the HUE API v.2 Standards. This is an example msg, that turns on the light: <code>msg.on = {"on":true}</code>. Please refer to the [official HUE Api page](https://developers.meethue.com/develop/hue-api-v2/api-reference/#resource_light__id__put) |
1319
1328
  ### Note
@@ -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.
@@ -112,7 +115,7 @@ module.exports = function (RED) {
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
- 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
118
+ if (node.HUEDeviceWhileDaytime.color_temperature !== undefined && 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
119
  node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, state, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
117
120
  node.setNodeStatusHue({
118
121
  fill: "green",
@@ -139,7 +142,7 @@ module.exports = function (RED) {
139
142
  // Failsafe all on
140
143
  state = { on: { on: true }, dimming: element.dimming, color: element.color, color_temperature: element.color_temperature };
141
144
  }
142
- 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
145
+ if (element.color_temperature !== undefined && 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
143
146
  node.serverHue.hueManager.writeHueQueueAdd(element.id, state, "setLight");
144
147
  }
145
148
  node.setNodeStatusHue({
@@ -286,7 +289,7 @@ module.exports = function (RED) {
286
289
  // { decr_incr: 1, data: 1 } : Start increasing until { decr_incr: 0, data: 0 } is received.
287
290
  // { decr_incr: 0, data: 1 } : Start decreasing until { decr_incr: 0, data: 0 } is received.
288
291
  msg.payload = dptlib.fromBuffer(msg.knx.rawValue, dptlib.resolve(config.dptLightHSV));
289
- node.hueDimmingTunableWhite(msg.payload.decr_incr, msg.payload.data, config.dimSpeed);
292
+ node.hueDimmingTunableWhite(msg.payload.decr_incr, msg.payload.data, 5000);
290
293
  node.setNodeStatusHue({
291
294
  fill: "green", shape: "dot", text: "KNX->HUE", payload: JSON.stringify(msg.payload),
292
295
  });
@@ -481,106 +484,137 @@ module.exports = function (RED) {
481
484
 
482
485
  // Start dimming
483
486
  // ***********************************************************
484
- node.hueDimming = function hueDimming(_KNXaction, _KNXbrightness_delta, _dimSpeedInMillisecs = undefined) {
485
- // 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
486
489
  // i decide to go to the "step brightness" way.
487
- let hueTelegram = {};
488
- const numStep = 10; // Steps from 0 to 100 by 10
489
- if (_dimSpeedInMillisecs === undefined || _dimSpeedInMillisecs === '') _dimSpeedInMillisecs = 5000;
490
-
491
- if (_KNXbrightness_delta === 0 && _KNXaction === 0) {
492
- // STOP DIM
493
- if (node.timerStepDim !== undefined) clearInterval(node.timerStepDim);
494
- node.brightnessStep = null;
495
- return;
496
- }
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
+ }
497
500
 
498
- // Set the actual brightness to start with
499
- if (node.brightnessStep === null || node.brightnessStep === undefined) node.brightnessStep = node.currentHUEDevice.dimming.brightness || 50;
500
- node.brightnessStep = Math.ceil(Number(node.brightnessStep));
501
-
502
- // Set the speed
503
- _dimSpeedInMillisecs /= numStep;
504
-
505
- // We have also minDimLevelLight and maxDimLevelLight to take care of.
506
- let minDimLevelLight = config.minDimLevelLight === undefined ? 10 : Number(config.minDimLevelLight);
507
- if (config.minDimLevelLight === "useHueLightLevel" && node.currentHUEDevice.dimming.min_dim_level === undefined) minDimLevelLight = 10;
508
- const maxDimLevelLight = config.maxDimLevelLight === undefined ? 100 : Number(config.maxDimLevelLight);
509
-
510
- if (_KNXbrightness_delta > 0 && _KNXaction === 1) {
511
- // DIM UP
512
- if (node.timerStepDim !== undefined) clearInterval(node.timerStepDim);
513
- node.timerStepDim = setInterval(() => {
514
- node.updateKNXBrightnessState(node.brightnessStep); // Unnecessary, but necessary to set the KNX Status in real time.
515
- node.brightnessStep += numStep;
516
- if (node.brightnessStep > maxDimLevelLight) node.brightnessStep = maxDimLevelLight;
517
- hueTelegram = { dimming: { brightness: node.brightnessStep }, dynamics: { duration: _dimSpeedInMillisecs } };
518
- // Switch on the light if off
519
- if (node.currentHUEDevice.on !== undefined && node.currentHUEDevice.on.on === false) {
520
- hueTelegram.on = { on: true };
521
- }
522
- node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, hueTelegram, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
523
- if (node.brightnessStep >= maxDimLevelLight) clearInterval(node.timerStepDim);
524
- }, _dimSpeedInMillisecs);
525
- }
526
- if (_KNXbrightness_delta > 0 && _KNXaction === 0) {
527
- if (node.currentHUEDevice.on.on === false) return; // Don't dim down, if the light is already off.
528
- // DIM DOWN
529
- if (node.timerStepDim !== undefined) clearInterval(node.timerStepDim);
530
- node.timerStepDim = setInterval(() => {
531
- node.updateKNXBrightnessState(node.brightnessStep); // Unnecessary, but necessary to set the KNX Status in real time.
532
- node.brightnessStep -= numStep;
533
- if (node.brightnessStep < minDimLevelLight) node.brightnessStep = minDimLevelLight;
534
- hueTelegram = { dimming: { brightness: node.brightnessStep }, dynamics: { duration: _dimSpeedInMillisecs } };
535
- // Switch off the light if on
536
- if (node.currentHUEDevice.on !== undefined && node.currentHUEDevice.on.on === true && node.brightnessStep === 0) {
537
- hueTelegram.on = { on: false };
538
- }
539
- node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, hueTelegram, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
540
- if (node.brightnessStep <= minDimLevelLight) clearInterval(node.timerStepDim);
541
- }, _dimSpeedInMillisecs);
542
- }
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) { }
543
548
  };
544
549
  // ***********************************************************
545
550
 
546
551
  // Start dimming tunable white
547
552
  // mirek: required(integer minimum: 153, maximum: 500)
548
553
  // ***********************************************************
549
- node.hueDimmingTunableWhite = function hueDimming(_KNXaction, _KNXbrightness_delta, _dimSpeedInMillisecs = undefined) {
550
- let dimDirection = "stop";
551
- let hueTelegram = {};
552
- _dimSpeedInMillisecs = _dimSpeedInMillisecs === undefined || _dimSpeedInMillisecs === "" ? 5000 : _dimSpeedInMillisecs;
553
- let delta = 0;
554
- if (node.currentHUEDevice.color_temperature.mirek === undefined) delta = 347 - Math.round(173, 0); // Unable to read the mirek, set medium as default
555
- // We have also minDimLevelLight and maxDimLevelLight to take care of.
556
- // Mirek limits are not taken in consideration.
557
- // Maximum mirek is 347
558
- if (_KNXbrightness_delta === 0 && _KNXaction === 0) {
559
- dimDirection = "stop";
560
- hueTelegram = { color_temperature_delta: { action: dimDirection } };
561
- node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, hueTelegram, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
562
- return;
563
- }
564
- if (_KNXbrightness_delta > 0 && _KNXaction === 1) {
565
- if (node.currentHUEDevice.color_temperature.mirek !== undefined) delta = 347 - Math.round(node.currentHUEDevice.color_temperature.mirek, 0);
566
- dimDirection = "up";
567
- }
568
- if (_KNXbrightness_delta > 0 && _KNXaction === 0) {
569
- // 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)
570
- if (node.currentHUEDevice.color_temperature.mirek !== undefined) delta = Math.round(node.currentHUEDevice.color_temperature.mirek, 0);
571
- dimDirection = "down";
572
- }
573
- // Calculate the dimming time based on delta
574
- // 10000:x=347:delta
575
- // x = (10000 * delta) / 347
576
- _dimSpeedInMillisecs = Math.round((_dimSpeedInMillisecs * delta) / 347, 0);
577
-
578
- hueTelegram = { color_temperature_delta: { action: dimDirection, mirek_delta: delta }, dynamics: { duration: _dimSpeedInMillisecs } };
579
- // Switch on the light if off
580
- if (node.currentHUEDevice.on !== undefined && node.currentHUEDevice.on.on === false && dimDirection === "up") {
581
- hueTelegram.on = { on: true };
582
- }
583
- 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) { }
584
618
  };
585
619
  // ***********************************************************
586
620
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "engines": {
4
4
  "node": ">=16.0.0"
5
5
  },
6
- "version": "2.2.36",
6
+ "version": "2.2.38",
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",