node-red-contrib-knx-ultimate 2.2.31 → 2.2.33
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,14 @@
|
|
|
6
6
|
|
|
7
7
|
# CHANGELOG
|
|
8
8
|
|
|
9
|
+
**Version 2.2.33** - December 2023<br/>
|
|
10
|
+
- Quickfix: HUE Light: fixed an issue in the conversion of tunable white from Datapint 7.600 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
|
+
|
|
13
|
+
**Version 2.2.32** - December 2023<br/>
|
|
14
|
+
- Quickfix: HUE Light: fixed an issue in the conversion of tunable white from Datapoint 9.002 to mired and vice versa.<br/>
|
|
15
|
+
- WARNING: the new HUE Scene node is to be considered **BETA (= in testing with user feedback)**.<br/>
|
|
16
|
+
|
|
9
17
|
**Version 2.2.31** - December 2023<br/>
|
|
10
18
|
- 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
19
|
- 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
|
|
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
|
|
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 (
|
|
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 (
|
|
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
|
}
|
|
@@ -175,16 +175,20 @@ module.exports = function (RED) {
|
|
|
175
175
|
break;
|
|
176
176
|
case config.GALightKelvin:
|
|
177
177
|
let retMirek;
|
|
178
|
+
let kelvinValue = 0;
|
|
178
179
|
msg.payload = dptlib.fromBuffer(msg.knx.rawValue, dptlib.resolve(config.dptLightKelvin));
|
|
179
180
|
if (config.dptLightKelvin === "7.600") {
|
|
180
181
|
if (msg.payload > 65535) msg.payload = 65535;
|
|
181
182
|
if (msg.payload < 0) msg.payload = 0;
|
|
182
|
-
|
|
183
|
+
// kelvinValue = hueColorConverter.ColorConverter.mirekToKelvin(_value);
|
|
184
|
+
// knxMsgPayload.payload = hueColorConverter.ColorConverter.scale(kelvinValue, [2000, 6535], [0, 65535]);
|
|
185
|
+
kelvinValue = hueColorConverter.ColorConverter.scale(msg.payload, [0, 65535], [2000, 6535]);
|
|
186
|
+
retMirek = hueColorConverter.ColorConverter.kelvinToMirek(kelvinValue);
|
|
183
187
|
} else if (config.dptLightKelvin === "9.002") {
|
|
184
188
|
// Relative temperature in Kelvin. Use HUE scale.
|
|
185
189
|
if (msg.payload > 6535) msg.payload = 6535;
|
|
186
190
|
if (msg.payload < 2000) msg.payload = 2000;
|
|
187
|
-
retMirek = hueColorConverter.ColorConverter.
|
|
191
|
+
retMirek = hueColorConverter.ColorConverter.kelvinToMirek(msg.payload);
|
|
188
192
|
}
|
|
189
193
|
state = { color_temperature: { mirek: retMirek } };
|
|
190
194
|
node.serverHue.hueManager.writeHueQueueAdd(node.hueDevice, state, node.isGrouped_light === false ? "setLight" : "setGroupedLight");
|
|
@@ -192,7 +196,7 @@ module.exports = function (RED) {
|
|
|
192
196
|
fill: "green",
|
|
193
197
|
shape: "dot",
|
|
194
198
|
text: "KNX->HUE",
|
|
195
|
-
payload:
|
|
199
|
+
payload: kelvinValue,
|
|
196
200
|
});
|
|
197
201
|
break;
|
|
198
202
|
case config.GADaylightSensor:
|
|
@@ -526,7 +530,7 @@ module.exports = function (RED) {
|
|
|
526
530
|
// Output the msg to the flow
|
|
527
531
|
node.send(_event);
|
|
528
532
|
|
|
529
|
-
// // DEBUG
|
|
533
|
+
// // DEBUG testing enable/disable HTML UI Tabs
|
|
530
534
|
//delete _event.dimming;
|
|
531
535
|
//delete _event.color;
|
|
532
536
|
//delete _event.color_temperature;
|
|
@@ -734,12 +738,14 @@ module.exports = function (RED) {
|
|
|
734
738
|
node.updateKNXLightKelvinState = function updateKNXLightKelvinState(_value, _outputtype = "write") {
|
|
735
739
|
if (config.GALightKelvinState !== undefined && config.GALightKelvinState !== "") {
|
|
736
740
|
const knxMsgPayload = {};
|
|
741
|
+
let kelvinValue = 0;
|
|
737
742
|
knxMsgPayload.topic = config.GALightKelvinState;
|
|
738
743
|
knxMsgPayload.dpt = config.dptLightKelvinState;
|
|
739
744
|
if (config.dptLightKelvinState === "7.600") {
|
|
740
|
-
|
|
745
|
+
kelvinValue = hueColorConverter.ColorConverter.mirekToKelvin(_value);
|
|
746
|
+
knxMsgPayload.payload = hueColorConverter.ColorConverter.scale(kelvinValue, [2000, 6535], [0, 65535]);
|
|
741
747
|
} else if (config.dptLightKelvinState === "9.002") {
|
|
742
|
-
knxMsgPayload.payload = hueColorConverter.ColorConverter.
|
|
748
|
+
knxMsgPayload.payload = hueColorConverter.ColorConverter.mirekToKelvin(_value);
|
|
743
749
|
}
|
|
744
750
|
// Send to KNX bus
|
|
745
751
|
if (knxMsgPayload.topic !== "" && knxMsgPayload.topic !== undefined) {
|
|
@@ -757,7 +763,7 @@ module.exports = function (RED) {
|
|
|
757
763
|
fill: "blue",
|
|
758
764
|
shape: "ring",
|
|
759
765
|
text: "HUE->KNX Kelvin",
|
|
760
|
-
payload:
|
|
766
|
+
payload: kelvinValue,
|
|
761
767
|
});
|
|
762
768
|
}
|
|
763
769
|
}
|
|
@@ -24,11 +24,11 @@ class ColorConverter {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
static kelvinToMirek(_kelvin) {
|
|
27
|
-
return Math.
|
|
27
|
+
return Math.floor(1000000 / _kelvin);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
static mirekToKelvin(_mirek) {
|
|
31
|
-
return Math.
|
|
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.
|
|
6
|
+
"version": "2.2.33",
|
|
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",
|