node-red-contrib-knx-ultimate 2.2.31 → 2.2.32

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,10 @@
6
6
 
7
7
  # CHANGELOG
8
8
 
9
+ **Version 2.2.32** - December 2023<br/>
10
+ - Quickfix: HUE Light: fixed an issue in the conversion of tunable white from 9.002 to mired and vice versa.<br/>
11
+ - WARNING: the new HUE Scene node is to be considered **BETA (= in testing with user feedback)**.<br/>
12
+
9
13
  **Version 2.2.31** - December 2023<br/>
10
14
  - NEW: HUE Scene node: added the status GA and Datapoint, for the scene to send true/false if active/not active. This currently works only for "Single mode".<br/>
11
15
  - WARNING: the new HUE Scene node is to be considered **BETA (= in testing with user feedback)**.<br/>
@@ -11,7 +11,7 @@ const knxLog = require('./../KnxLog')
11
11
 
12
12
  const util = require('util')
13
13
  // kudos to http://croquetweak.blogspot.gr/2014/08/deconstructing-floats-frexp-and-ldexp.html
14
- function ldexp (mantissa, exponent) {
14
+ function ldexp(mantissa, exponent) {
15
15
  return exponent > 1023 // avoid multiplying by infinity
16
16
  ? mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023)
17
17
  : exponent < -1074 // avoid multiplying by zero
@@ -19,7 +19,7 @@ function ldexp (mantissa, exponent) {
19
19
  : mantissa * Math.pow(2, exponent)
20
20
  }
21
21
 
22
- function frexp (value) {
22
+ function frexp(value) {
23
23
  if (value === 0) return [value, 0]
24
24
  const data = new DataView(new ArrayBuffer(8))
25
25
  data.setFloat64(0, value)
@@ -62,6 +62,16 @@ exports.fromBuffer = function (buf) {
62
62
  knxLog.get().warn('DPT9.fromBuffer: buf should be 2 bytes long (got %d bytes)', buf.length)
63
63
  return null
64
64
  } else {
65
+
66
+ // Homeassistant:
67
+ // let data = (buf[0] * 256) + buf[1]
68
+ // let esponente = (data >> 11) & 0x0F
69
+ // let significand = data & 0x7FF
70
+ // let segno = data >> 15
71
+ // if (segno === 1) { significand = significand - 2048 }
72
+ // let value = Number.parseFloat(significand << esponente) / 100
73
+ // return value;
74
+
65
75
  const sign = buf[0] >> 7
66
76
  const exponent = (buf[0] & 0b01111000) >> 3
67
77
  let mantissa = 256 * (buf[0] & 0b00000111) + buf[1]
@@ -70,9 +70,11 @@
70
70
  if (dpt.value.startsWith(_dpt)) {
71
71
  // Adjustment for HUE Temperature
72
72
  if (dpt.value.startsWith("7.600")) {
73
- $(_destinationWidget).append($("<option></option>").attr("value", dpt.value).text(dpt.text + " - KNX Kelvin range (0K-65535K)"));
73
+ $(_destinationWidget).append($("<option></option>").attr("value", dpt.value).text(dpt.text + " - KNX Kelvin range 0-65535k (Homeassistant color_temperature_mode: absolute)"));
74
74
  } else if (dpt.value.startsWith("9.002")) {
75
- $(_destinationWidget).append($("<option></option>").attr("value", dpt.value).text(dpt.text + " - HUE Kelvin range (Default 2000K-6535K"));
75
+ $(_destinationWidget).append($("<option></option>").attr("value", dpt.value).text(dpt.text + " - HUE Kelvin range 2000-6535k (Homeassistant color_temperature_mode: absolute_float)"));
76
+ } else if (dpt.value.startsWith("5.001")) {
77
+ $(_destinationWidget).append($("<option></option>").attr("value", dpt.value).text(dpt.text + " - Homeassistant color_temperature_mode: relative"));
76
78
  } else {
77
79
  $(_destinationWidget).append($("<option></option>").attr("value", dpt.value).text(dpt.text));
78
80
  }
@@ -184,7 +184,7 @@ module.exports = function (RED) {
184
184
  // Relative temperature in Kelvin. Use HUE scale.
185
185
  if (msg.payload > 6535) msg.payload = 6535;
186
186
  if (msg.payload < 2000) msg.payload = 2000;
187
- retMirek = hueColorConverter.ColorConverter.scale(msg.payload, [2000, 6535], [500, 153]);
187
+ retMirek = hueColorConverter.ColorConverter.kelvinToMirek(msg.payload);
188
188
  }
189
189
  state = { color_temperature: { mirek: retMirek } };
190
190
  node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, state, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
@@ -739,7 +739,8 @@ module.exports = function (RED) {
739
739
  if (config.dptLightKelvinState === "7.600") {
740
740
  knxMsgPayload.payload = hueColorConverter.ColorConverter.scale(_value, [153, 500], [65535, 0]);
741
741
  } else if (config.dptLightKelvinState === "9.002") {
742
- knxMsgPayload.payload = hueColorConverter.ColorConverter.scale(_value, [153, 500], [6535, 2000]);
742
+ //knxMsgPayload.payload = hueColorConverter.ColorConverter.scale(_value, [153, 500], [6535, 2000]);
743
+ knxMsgPayload.payload = hueColorConverter.ColorConverter.mirekToKelvin(_value);
743
744
  }
744
745
  // Send to KNX bus
745
746
  if (knxMsgPayload.topic !== "" && knxMsgPayload.topic !== undefined) {
@@ -24,11 +24,11 @@ class ColorConverter {
24
24
  }
25
25
 
26
26
  static kelvinToMirek(_kelvin) {
27
- return Math.round(1000000 / _kelvin, 0);
27
+ return Math.floor(1000000 / _kelvin);
28
28
  }
29
29
 
30
30
  static mirekToKelvin(_mirek) {
31
- return Math.round(1000000 / _mirek, 0);
31
+ return Math.floor(1000000 / _mirek);
32
32
  }
33
33
 
34
34
  // Linear interpolation of input y given starting and ending ranges
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "engines": {
4
4
  "node": ">=16.0.0"
5
5
  },
6
- "version": "2.2.31",
6
+ "version": "2.2.32",
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",