node-red-contrib-knx-ultimate 2.2.11 → 2.2.13
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 +1 -1
- package/nodes/hue-config.js +85 -59
- package/nodes/knxUltimate-config.js +2 -19
- package/nodes/knxUltimateHueBattery.html +1 -1
- package/nodes/knxUltimateHueBattery.js +2 -2
- package/nodes/knxUltimateHueButton.html +1 -1
- package/nodes/knxUltimateHueButton.js +2 -1
- package/nodes/knxUltimateHueLight.html +10 -4
- package/nodes/knxUltimateHueLight.js +3 -4
- package/nodes/knxUltimateHueLightSensor.html +1 -1
- package/nodes/knxUltimateHueLightSensor.js +2 -1
- package/nodes/knxUltimateHueMotion.html +1 -1
- package/nodes/knxUltimateHueMotion.js +2 -1
- package/nodes/knxUltimateHueScene.html +1 -1
- package/nodes/knxUltimateHueScene.js +2 -5
- package/nodes/knxUltimateHueTapDial.html +1 -1
- package/nodes/knxUltimateHueTapDial.js +2 -1
- package/nodes/knxUltimateHueTemperatureSensor.html +1 -1
- package/nodes/utils/hueEngine.js +23 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# CHANGELOG
|
|
8
8
|
|
|
9
|
-
<b>Version 2.2.
|
|
9
|
+
<b>Version 2.2.13</b> - November 2023<br/>
|
|
10
10
|
<p>
|
|
11
11
|
- NEW: Hue Light: you can now enable the input/output PINs and send/receive commands to/from the light, via the msg flow, like msg.on={"on":true}. The option is "Node Input/Output PINs".<br/>
|
|
12
12
|
- NEW: Hue Scene: you can now enable the input/output PINs and send/receive commands to/from the light, via the msg flow. The option is "Node Input/Output PINs".<br/>
|
package/nodes/hue-config.js
CHANGED
|
@@ -55,27 +55,46 @@ module.exports = (RED) => {
|
|
|
55
55
|
const node = this;
|
|
56
56
|
node.host = config.host;
|
|
57
57
|
node.nodeClients = []; // Stores the registered clients
|
|
58
|
-
node.nodeClientsAwaitingInit = []; // Stores the nodes client to be initialized
|
|
59
58
|
node.loglevel = config.loglevel !== undefined ? config.loglevel : "error"; // 18/02/2020 Loglevel default error
|
|
60
59
|
node.sysLogger = null;
|
|
61
60
|
node.hueAllResources = undefined;
|
|
61
|
+
node.timerHUEConfigCheckState = null; // Timer that check the connection to the hue bridge every xx seconds
|
|
62
|
+
node.linkStatus = "disconnected";
|
|
62
63
|
try {
|
|
63
64
|
node.sysLogger = loggerEngine.get({ loglevel: node.loglevel }); // New logger to adhere to the loglevel selected in the config-window
|
|
64
65
|
} catch (error) {
|
|
65
66
|
/* empty */
|
|
66
67
|
}
|
|
67
|
-
|
|
68
68
|
node.name = config.name === undefined || config.name === "" ? node.host : config.name;
|
|
69
69
|
|
|
70
|
-
//
|
|
71
|
-
|
|
70
|
+
// Call the connect function of all hue-config nodes.
|
|
71
|
+
// function callinitHUEConnectionOfAllHUEServers() {
|
|
72
|
+
// RED.nodes.eachNode((_node) => {
|
|
73
|
+
// if (_node.type === 'hue-config') {
|
|
74
|
+
// try {
|
|
75
|
+
// RED.nodes.getNode(_node.id).initHUEConnection();
|
|
76
|
+
// } catch (error) {
|
|
77
|
+
// if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.error("callinitHUEConnectionOfAllHUEServers: Node " + _node.name + " " + error.message);
|
|
78
|
+
// }
|
|
79
|
+
// }
|
|
80
|
+
// });
|
|
81
|
+
// }
|
|
72
82
|
|
|
73
83
|
// Connect to Bridge and get the resources
|
|
74
|
-
node.
|
|
75
|
-
|
|
84
|
+
node.initHUEConnection = async () => {
|
|
85
|
+
try {
|
|
86
|
+
if (node.hueManager !== undefined) node.hueManager.close();
|
|
87
|
+
} catch (error) { }
|
|
88
|
+
try {
|
|
89
|
+
if (node.hueManager !== undefined) node.hueManager.removeAllListeners();
|
|
90
|
+
} catch (error) { }
|
|
76
91
|
// Handle events
|
|
77
92
|
try {
|
|
78
|
-
|
|
93
|
+
try {
|
|
94
|
+
// Init HUE Utility
|
|
95
|
+
node.hueManager = new HueClass(node.host, node.credentials.username, node.credentials.clientkey, config.bridgeid, node.sysLogger);
|
|
96
|
+
} catch (error) { }
|
|
97
|
+
await node.hueManager.Connect();
|
|
79
98
|
} catch (error) {
|
|
80
99
|
/* empty */
|
|
81
100
|
}
|
|
@@ -91,50 +110,58 @@ module.exports = (RED) => {
|
|
|
91
110
|
});
|
|
92
111
|
// Connected
|
|
93
112
|
node.hueManager.on("connected", () => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
})();
|
|
102
|
-
}, 10000);
|
|
113
|
+
node.linkStatus = "connected";
|
|
114
|
+
// Start the timer to do initial read.
|
|
115
|
+
if (node.timerDoInitialRead !== null) clearTimeout(node.timerDoInitialRead);
|
|
116
|
+
node.timerDoInitialRead = setTimeout(() => {
|
|
117
|
+
node.loadResourcesFromHUEBridge();
|
|
118
|
+
}, 6000); // 17/02/2020 Do initial read of all nodes requesting initial read
|
|
103
119
|
});
|
|
104
120
|
};
|
|
105
121
|
|
|
122
|
+
node.startWatchdogTimer = () => {
|
|
123
|
+
node.timerHUEConfigCheckState = setTimeout(() => {
|
|
124
|
+
(async () => {
|
|
125
|
+
if (node.linkStatus === "disconnected") {
|
|
126
|
+
await node.initHUEConnection();
|
|
127
|
+
} else {
|
|
128
|
+
// Check wether the hue connection is still alive
|
|
129
|
+
const ret = await node.hueManager.isConnected();
|
|
130
|
+
if (!ret) node.linkStatus = "disconnected";
|
|
131
|
+
}
|
|
132
|
+
node.startWatchdogTimer();
|
|
133
|
+
})();
|
|
134
|
+
}, 10000);
|
|
135
|
+
};
|
|
136
|
+
node.startWatchdogTimer();
|
|
137
|
+
|
|
106
138
|
// Query the HUE Bridge to return the resources
|
|
107
139
|
node.loadResourcesFromHUEBridge = () => {
|
|
108
140
|
(async () => {
|
|
109
141
|
// °°°°°° Load ALL resources
|
|
110
142
|
try {
|
|
111
143
|
node.hueAllResources = await node.hueManager.hueApiV2.get("/resource");
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
144
|
+
if (node.hueAllResources !== undefined) {
|
|
145
|
+
node.hueAllRooms = node.hueAllResources.filter((a) => a.type === "room");
|
|
146
|
+
// Update all KNX State of the nodes with the new hue device values
|
|
147
|
+
node.nodeClients.forEach((_node) => {
|
|
148
|
+
if (_node.hueDevice !== undefined && node.hueAllResources !== undefined) {
|
|
149
|
+
const oHUEDevice = node.hueAllResources.filter((a) => a.id === _node.hueDevice)[0];
|
|
150
|
+
if (oHUEDevice !== undefined) {
|
|
151
|
+
// Add _Node to the clients array
|
|
152
|
+
_node.setNodeStatusHue({
|
|
153
|
+
fill: "green",
|
|
154
|
+
shape: "ring",
|
|
155
|
+
text: "Ready :-)",
|
|
156
|
+
});
|
|
157
|
+
_node.currentHUEDevice = oHUEDevice;
|
|
158
|
+
if (_node.initializingAtStart === true) _node.handleSendHUE(oHUEDevice);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
119
161
|
});
|
|
120
|
-
|
|
162
|
+
} else {
|
|
163
|
+
// The config node cannot read the resources. Signalling disconnected
|
|
121
164
|
}
|
|
122
|
-
node.nodeClients.forEach((_node) => {
|
|
123
|
-
if (_node.hueDevice !== undefined && node.hueAllResources !== undefined) {
|
|
124
|
-
const oHUEDevice = node.hueAllResources.filter((a) => a.id === _node.hueDevice)[0];
|
|
125
|
-
if (oHUEDevice !== undefined) {
|
|
126
|
-
// Add _Node to the clients array
|
|
127
|
-
_node.setNodeStatusHue({
|
|
128
|
-
fill: "green",
|
|
129
|
-
shape: "ring",
|
|
130
|
-
text: "Ready from awaiting list :-)",
|
|
131
|
-
});
|
|
132
|
-
oHUEDevice.initializingAtStart = true; // Signalling first connection after restart.
|
|
133
|
-
_node.currentHUEDevice = oHUEDevice;
|
|
134
|
-
_node.handleSendHUE(oHUEDevice);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
165
|
} catch (error) {
|
|
139
166
|
if (this.sysLogger !== undefined && this.sysLogger !== null) {
|
|
140
167
|
this.sysLogger.error(`KNXUltimatehueEngine: loadResourcesFromHUEBridge: ${error.message}`);
|
|
@@ -275,28 +302,27 @@ module.exports = (RED) => {
|
|
|
275
302
|
|
|
276
303
|
node.addClient = (_Node) => {
|
|
277
304
|
// Update the node hue device, as soon as a node register itself to hue-config nodeClients
|
|
278
|
-
if (node.
|
|
279
|
-
|
|
305
|
+
if (node.nodeClients.filter((x) => x.id === _Node.id).length === 0) {
|
|
306
|
+
node.nodeClients.push(_Node);
|
|
307
|
+
if (node.hueAllResources !== undefined && node.hueAllResources !== null && _Node.initializingAtStart === true) {
|
|
280
308
|
const oHUEDevice = node.hueAllResources.filter((a) => a.id === _Node.hueDevice)[0];
|
|
281
|
-
oHUEDevice
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
309
|
+
if (oHUEDevice !== undefined) {
|
|
310
|
+
_Node.currentHUEDevice = oHUEDevice;
|
|
311
|
+
_Node.handleSendHUE(oHUEDevice);
|
|
312
|
+
// Add _Node to the clients array
|
|
313
|
+
_Node.setNodeStatusHue({
|
|
314
|
+
fill: "yellow",
|
|
315
|
+
shape: "dot",
|
|
316
|
+
text: "Initializing. Please Wait.",
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
} else {
|
|
320
|
+
node.linkStatus = "disconnected";
|
|
285
321
|
// Add _Node to the clients array
|
|
286
|
-
_Node.setNodeStatusHue({
|
|
287
|
-
fill: "green",
|
|
288
|
-
shape: "ring",
|
|
289
|
-
text: "Ready",
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
} else {
|
|
293
|
-
if (node.nodeClientsAwaitingInit.filter((x) => x.id === _Node.id).length === 0) {
|
|
294
|
-
// Put the node in the waiting list
|
|
295
|
-
node.nodeClientsAwaitingInit.push(_Node);
|
|
296
322
|
_Node.setNodeStatusHue({
|
|
297
323
|
fill: "grey",
|
|
298
|
-
shape: "
|
|
299
|
-
text: "
|
|
324
|
+
shape: "ring",
|
|
325
|
+
text: "Waiting for connection",
|
|
300
326
|
});
|
|
301
327
|
}
|
|
302
328
|
}
|
|
@@ -356,7 +382,7 @@ module.exports = (RED) => {
|
|
|
356
382
|
RED.log.error(`Errore KNXUltimateGetResourcesHUE non gestito ${error.message}`);
|
|
357
383
|
res.json({ devices: error.message });
|
|
358
384
|
// (async () => {
|
|
359
|
-
// await node.
|
|
385
|
+
// await node.initHUEConnection();
|
|
360
386
|
// })();
|
|
361
387
|
}
|
|
362
388
|
});
|
|
@@ -115,13 +115,9 @@ return msg;`,
|
|
|
115
115
|
node.KNXEthInterfaceManuallyInput = typeof config.KNXEthInterfaceManuallyInput === "undefined" ? "" : config.KNXEthInterfaceManuallyInput; // If you manually set the interface name, it will be wrote here
|
|
116
116
|
node.telegramsQueue = []; // 02/01/2020 Queue containing telegrams
|
|
117
117
|
node.timerSendTelegramFromQueue = null;
|
|
118
|
-
node.delaybetweentelegramsfurtherdelayREAD =
|
|
119
|
-
typeof config.delaybetweentelegramsfurtherdelayREAD === "undefined" || Number(config.delaybetweentelegramsfurtherdelayREAD < 1)
|
|
120
|
-
? 1
|
|
121
|
-
: Number(config.delaybetweentelegramsfurtherdelayREAD); // 18/05/2020 delay multiplicator only for "read" telegrams.
|
|
118
|
+
node.delaybetweentelegramsfurtherdelayREAD = typeof config.delaybetweentelegramsfurtherdelayREAD === "undefined" || Number(config.delaybetweentelegramsfurtherdelayREAD < 1) ? 1 : Number(config.delaybetweentelegramsfurtherdelayREAD); // 18/05/2020 delay multiplicator only for "read" telegrams.
|
|
122
119
|
node.delaybetweentelegramsREADCount = 0; // 18/05/2020 delay multiplicator only for "read" telegrams.
|
|
123
120
|
node.timerDoInitialRead = null; // 17/02/2020 Timer (timeout) to do initial read of all nodes requesting initial read, after all nodes have been registered to the sercer
|
|
124
|
-
node.timerCallConnectToHueBridgeOfAllHUEServers = null; // // Timer for the callConnectToHueBridgeOfAllHUEServers function
|
|
125
121
|
node.stopETSImportIfNoDatapoint = typeof config.stopETSImportIfNoDatapoint === "undefined" ? "stop" : config.stopETSImportIfNoDatapoint; // 09/01/2020 Stop, Import Fake or Skip the import if a group address has unset datapoint
|
|
126
122
|
node.csv = readCSV(config.csv); // Array from ETS CSV Group Addresses {ga:group address, dpt: datapoint, devicename: full device name with main and subgroups}
|
|
127
123
|
node.localEchoInTunneling = typeof config.localEchoInTunneling !== "undefined" ? config.localEchoInTunneling : true;
|
|
@@ -678,18 +674,7 @@ return msg;`,
|
|
|
678
674
|
});
|
|
679
675
|
} catch (error) { }
|
|
680
676
|
}
|
|
681
|
-
|
|
682
|
-
function callConnectToHueBridgeOfAllHUEServers() {
|
|
683
|
-
RED.nodes.eachNode((_node) => {
|
|
684
|
-
if (_node.type === 'hue-config') {
|
|
685
|
-
try {
|
|
686
|
-
RED.nodes.getNode(_node.id).ConnectToHueBridge();
|
|
687
|
-
} catch (error) {
|
|
688
|
-
if (node.sysLogger !== undefined && node.sysLogger !== null) node.sysLogger.error("callConnectToHueBridgeOfAllHUEServers: Node " + _node.name + " " + error.message);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
});
|
|
692
|
-
}
|
|
677
|
+
|
|
693
678
|
// 01/02/2020 Dinamic change of the KNX Gateway IP, Port and Physical Address
|
|
694
679
|
// This new thing has been requested by proServ RealKNX staff.
|
|
695
680
|
node.setGatewayConfig = (
|
|
@@ -947,9 +932,7 @@ return msg;`,
|
|
|
947
932
|
if (node.timerDoInitialRead !== null) clearTimeout(node.timerDoInitialRead);
|
|
948
933
|
node.timerDoInitialRead = setTimeout(() => {
|
|
949
934
|
DoInitialReadFromKNXBusOrFile();
|
|
950
|
-
callConnectToHueBridgeOfAllHUEServers();
|
|
951
935
|
}, 6000); // 17/02/2020 Do initial read of all nodes requesting initial read
|
|
952
|
-
//node.timerCallConnectToHueBridgeOfAllHUEServers = setTimeout(callConnectToHueBridgeOfAllHUEServers, 6000); // connects all hue-config nodes to the HUE Bridge.
|
|
953
936
|
const t = setTimeout(() => {
|
|
954
937
|
// 21/03/2022 fixed possible memory leak. Previously was setTimeout without "let t = ".
|
|
955
938
|
node.setAllClientsStatus("Connected.", "green", "On duty.");
|
|
@@ -227,7 +227,7 @@
|
|
|
227
227
|
|
|
228
228
|
|
|
229
229
|
</script>
|
|
230
|
-
<script src="
|
|
230
|
+
<script src="resources/node-red-contrib-knx-ultimate/11f26b4500.js"></script>
|
|
231
231
|
|
|
232
232
|
<script type="text/markdown" data-help-name="knxUltimateHueBattery">
|
|
233
233
|
This node lets you get the battery level from your HUE device. Here you can get the HUE battery level events, that represents a percentage 0-100% value, evetytime the
|
|
@@ -23,7 +23,7 @@ module.exports = function (RED) {
|
|
|
23
23
|
node.formatnegativevalue = 'leave';
|
|
24
24
|
node.formatdecimalsvalue = 2;
|
|
25
25
|
node.hueDevice = config.hueDevice;
|
|
26
|
-
|
|
26
|
+
node.initializingAtStart = !((config.readStatusAtStartup === undefined || config.readStatusAtStartup === "no"));
|
|
27
27
|
// Used to call the status update from the config node.
|
|
28
28
|
node.setNodeStatus = ({
|
|
29
29
|
fill, shape, text, payload,
|
|
@@ -49,7 +49,7 @@ module.exports = function (RED) {
|
|
|
49
49
|
if (_event.id === config.hueDevice) {
|
|
50
50
|
|
|
51
51
|
// IMPORTANT: exit if no event presen.
|
|
52
|
-
if (
|
|
52
|
+
if (!node.initializingAtStart) return;
|
|
53
53
|
if (!_event.hasOwnProperty("power_state") || _event.power_state.battery_level === undefined) return;
|
|
54
54
|
|
|
55
55
|
const knxMsgPayload = {};
|
|
@@ -404,7 +404,7 @@
|
|
|
404
404
|
|
|
405
405
|
|
|
406
406
|
</script>
|
|
407
|
-
<script src="
|
|
407
|
+
<script src="resources/node-red-contrib-knx-ultimate/11f26b4500.js"></script>
|
|
408
408
|
|
|
409
409
|
<script type="text/markdown" data-help-name="knxUltimateHueButton">
|
|
410
410
|
This node lets you get the events from your HUE button.
|
|
@@ -27,6 +27,7 @@ module.exports = function (RED) {
|
|
|
27
27
|
node.short_releaseValue = false;
|
|
28
28
|
node.isTimerDimStopRunning = false;
|
|
29
29
|
node.hueDevice = config.hueDevice;
|
|
30
|
+
node.initializingAtStart = false;
|
|
30
31
|
|
|
31
32
|
// Used to call the status update from the config node.
|
|
32
33
|
node.setNodeStatus = ({
|
|
@@ -78,7 +79,7 @@ module.exports = function (RED) {
|
|
|
78
79
|
if (_event.id === config.hueDevice) {
|
|
79
80
|
|
|
80
81
|
// IMPORTANT: exit if no button last_event present.
|
|
81
|
-
if (
|
|
82
|
+
if (!node.initializingAtStart) return;
|
|
82
83
|
if (!_event.hasOwnProperty("button") || _event.button.last_event === undefined) return;
|
|
83
84
|
|
|
84
85
|
const knxMsgPayload = {};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
<script src="resources/node-red-contrib-knx-ultimate/11f26b4500.js"></script>
|
|
2
|
+
<script src="resources/node-red-contrib-knx-ultimate/iro@5"></script>
|
|
3
|
+
|
|
1
4
|
<script type="text/javascript">
|
|
2
5
|
|
|
3
6
|
RED.nodes.registerType("knxUltimateHueLight", {
|
|
@@ -5,7 +8,7 @@
|
|
|
5
8
|
color: "#C0C7E9",
|
|
6
9
|
defaults: {
|
|
7
10
|
//buttonState: {value: true},
|
|
8
|
-
server: { type: "knxUltimate-config", required:
|
|
11
|
+
server: { type: "knxUltimate-config", required: false },
|
|
9
12
|
serverHue: { type: "hue-config", required: true },
|
|
10
13
|
name: { value: "" },
|
|
11
14
|
|
|
@@ -300,7 +303,10 @@
|
|
|
300
303
|
});
|
|
301
304
|
// Eval
|
|
302
305
|
const format = "node." + _destinationWidget.replace("#node-input-", "");
|
|
303
|
-
|
|
306
|
+
try {
|
|
307
|
+
if (format !== undefined) $(_destinationWidget).val(eval(format).toString());
|
|
308
|
+
} catch (error) { }
|
|
309
|
+
|
|
304
310
|
});
|
|
305
311
|
}
|
|
306
312
|
|
|
@@ -562,8 +568,8 @@
|
|
|
562
568
|
|
|
563
569
|
|
|
564
570
|
</script>
|
|
565
|
-
<script src="
|
|
566
|
-
<script src="
|
|
571
|
+
<script src="resources/node-red-contrib-knx-ultimate/11f26b4500.js"></script>
|
|
572
|
+
<script src="resources/node-red-contrib-knx-ultimate/iro@5"></script>
|
|
567
573
|
|
|
568
574
|
<script type="text/html" data-template-name="knxUltimateHueLight">
|
|
569
575
|
|
|
@@ -35,8 +35,7 @@ module.exports = function (RED) {
|
|
|
35
35
|
node.DayTime = true;
|
|
36
36
|
node.isGrouped_light = config.hueDevice.split("#")[1] === "grouped_light";
|
|
37
37
|
node.hueDevice = config.hueDevice.split("#")[0];
|
|
38
|
-
node.
|
|
39
|
-
if (config.readStatusAtStartup === undefined) node.readStatusAtStartup = "yes";
|
|
38
|
+
node.initializingAtStart = (config.readStatusAtStartup === undefined || config.readStatusAtStartup === "yes");
|
|
40
39
|
|
|
41
40
|
// Used to call the status update from the config node.
|
|
42
41
|
node.setNodeStatus = ({
|
|
@@ -60,7 +59,7 @@ module.exports = function (RED) {
|
|
|
60
59
|
node.handleSend = (msg) => {
|
|
61
60
|
if (node.currentHUEDevice === undefined) {
|
|
62
61
|
node.setNodeStatusHue({
|
|
63
|
-
fill: "
|
|
62
|
+
fill: "yellow",
|
|
64
63
|
shape: "ring",
|
|
65
64
|
text: "Initializing. Please wait.",
|
|
66
65
|
payload: "",
|
|
@@ -428,7 +427,7 @@ module.exports = function (RED) {
|
|
|
428
427
|
return;
|
|
429
428
|
}
|
|
430
429
|
// IMPORTANT: exit if no button last_event present.
|
|
431
|
-
if (
|
|
430
|
+
if (!node.initializingAtStart) return;
|
|
432
431
|
|
|
433
432
|
// Output the msg to the flow
|
|
434
433
|
node.send(_event);
|
|
@@ -227,7 +227,7 @@
|
|
|
227
227
|
|
|
228
228
|
|
|
229
229
|
</script>
|
|
230
|
-
<script src="
|
|
230
|
+
<script src="resources/node-red-contrib-knx-ultimate/11f26b4500.js"></script>
|
|
231
231
|
|
|
232
232
|
<script type="text/markdown" data-help-name="knxUltimateHueLightSensor">
|
|
233
233
|
This node lets you get the events from your HUE motion device.
|
|
@@ -23,6 +23,7 @@ module.exports = function (RED) {
|
|
|
23
23
|
node.formatnegativevalue = 'leave';
|
|
24
24
|
node.formatdecimalsvalue = 2;
|
|
25
25
|
node.hueDevice = config.hueDevice;
|
|
26
|
+
node.initializingAtStart = !((config.readStatusAtStartup === undefined || config.readStatusAtStartup === "no"));
|
|
26
27
|
|
|
27
28
|
// Used to call the status update from the config node.
|
|
28
29
|
node.setNodeStatus = ({ fill, shape, text, payload }) => {
|
|
@@ -45,7 +46,7 @@ module.exports = function (RED) {
|
|
|
45
46
|
if (_event.id === config.hueDevice) {
|
|
46
47
|
|
|
47
48
|
// IMPORTANT: exit if no event presen.
|
|
48
|
-
if (
|
|
49
|
+
if (!node.initializingAtStart) return;
|
|
49
50
|
if (!_event.hasOwnProperty('light') || _event.light.light_level === undefined) return;
|
|
50
51
|
|
|
51
52
|
const knxMsgPayload = {};
|
|
@@ -217,7 +217,7 @@
|
|
|
217
217
|
|
|
218
218
|
|
|
219
219
|
</script>
|
|
220
|
-
<script src="
|
|
220
|
+
<script src="resources/node-red-contrib-knx-ultimate/11f26b4500.js"></script>
|
|
221
221
|
|
|
222
222
|
<script type="text/markdown" data-help-name="knxUltimateHueMotion">
|
|
223
223
|
This node lets you get the events from your HUE motion device.
|
|
@@ -23,6 +23,7 @@ module.exports = function (RED) {
|
|
|
23
23
|
node.formatnegativevalue = "leave";
|
|
24
24
|
node.formatdecimalsvalue = 2;
|
|
25
25
|
node.hueDevice = config.hueDevice;
|
|
26
|
+
node.initializingAtStart = false;
|
|
26
27
|
|
|
27
28
|
// Used to call the status update from the config node.
|
|
28
29
|
node.setNodeStatus = ({ fill, shape, text, payload }) => { };
|
|
@@ -42,7 +43,7 @@ module.exports = function (RED) {
|
|
|
42
43
|
if (_event.id === config.hueDevice) {
|
|
43
44
|
|
|
44
45
|
// IMPORTANT: exit if no event presen.
|
|
45
|
-
if (
|
|
46
|
+
if (!node.initializingAtStart) return;
|
|
46
47
|
if (!_event.hasOwnProperty("motion") || _event.motion.motion === undefined) return;
|
|
47
48
|
|
|
48
49
|
|
|
@@ -283,7 +283,7 @@
|
|
|
283
283
|
|
|
284
284
|
|
|
285
285
|
</script>
|
|
286
|
-
<script src="
|
|
286
|
+
<script src="resources/node-red-contrib-knx-ultimate/11f26b4500.js"></script>
|
|
287
287
|
|
|
288
288
|
<script type="text/markdown" data-help-name="knxUltimateHueScene">
|
|
289
289
|
This node lets you recall a HUE scene, via KNX.
|
|
@@ -25,6 +25,7 @@ module.exports = function (RED) {
|
|
|
25
25
|
node.formatnegativevalue = 'leave';
|
|
26
26
|
node.formatdecimalsvalue = 2;
|
|
27
27
|
node.hueDevice = config.hueDevice;
|
|
28
|
+
node.initializingAtStart = false;
|
|
28
29
|
|
|
29
30
|
// Used to call the status update from the config node.
|
|
30
31
|
node.setNodeStatus = ({ fill, shape, text, payload }) => {
|
|
@@ -78,13 +79,9 @@ module.exports = function (RED) {
|
|
|
78
79
|
node.handleSendHUE = (_event) => {
|
|
79
80
|
try {
|
|
80
81
|
if (_event.id === config.hueDevice) {
|
|
81
|
-
|
|
82
|
-
// IMPORTANT: exit if no event presen.
|
|
83
|
-
if (_event.initializingAtStart === true) return;
|
|
84
|
-
|
|
82
|
+
if (!node.initializingAtStart) return;
|
|
85
83
|
// Output the msg to the flow
|
|
86
84
|
node.send(_event);
|
|
87
|
-
|
|
88
85
|
}
|
|
89
86
|
} catch (error) {
|
|
90
87
|
node.status({ fill: 'red', shape: 'dot', text: 'HUE->KNX error ' + error.message + ' (' + new Date().getDate() + ', ' + new Date().toLocaleTimeString() + ')' });
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
|
|
220
220
|
|
|
221
221
|
</script>
|
|
222
|
-
<script src="
|
|
222
|
+
<script src="resources/node-red-contrib-knx-ultimate/11f26b4500.js"></script>
|
|
223
223
|
|
|
224
224
|
<script type="text/markdown" data-help-name="knxUltimateHueTapDial">
|
|
225
225
|
This node lets you get the events from your HUE rotary device, for example the Tap Dial.
|
|
@@ -26,6 +26,7 @@ module.exports = function (RED) {
|
|
|
26
26
|
node.brightnessState = 0;
|
|
27
27
|
node.isTimerDimStopRunning = false;
|
|
28
28
|
node.hueDevice = config.hueDevice;
|
|
29
|
+
node.initializingAtStart = false;
|
|
29
30
|
|
|
30
31
|
// Used to call the status update from the config node.
|
|
31
32
|
node.setNodeStatus = ({
|
|
@@ -51,7 +52,7 @@ module.exports = function (RED) {
|
|
|
51
52
|
if (_event.id === config.hueDevice) {
|
|
52
53
|
|
|
53
54
|
// IMPORTANT: exit if no event presen.
|
|
54
|
-
if (
|
|
55
|
+
if (!node.initializingAtStart) return;
|
|
55
56
|
if (!_event.hasOwnProperty("relative_rotary")
|
|
56
57
|
|| !_event.relative_rotary.hasOwnProperty("last_event")
|
|
57
58
|
|| _event.relative_rotary.last_event === undefined
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
|
|
219
219
|
|
|
220
220
|
</script>
|
|
221
|
-
<script src="
|
|
221
|
+
<script src="resources/node-red-contrib-knx-ultimate/11f26b4500.js"></script>
|
|
222
222
|
|
|
223
223
|
<script type="text/markdown" data-help-name="knxUltimateHueTemperatureSensor" This node lets you get the events from
|
|
224
224
|
your HUE temperature device. Here you can get the HUE temperature events, that represents a celsius value, evetytime
|
package/nodes/utils/hueEngine.js
CHANGED
|
@@ -41,7 +41,13 @@ class classHUE extends EventEmitter {
|
|
|
41
41
|
} catch (error) {
|
|
42
42
|
/* empty */
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
this.es = new EventSource(`https://${this.hueBridgeIP}/eventstream/clip/v2`, options);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
console.log("hue-config: ew EventSource:" + error.message);
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
|
|
46
52
|
this.es.onmessage = (event) => {
|
|
47
53
|
try {
|
|
@@ -86,7 +92,9 @@ class classHUE extends EventEmitter {
|
|
|
86
92
|
} catch (error) {
|
|
87
93
|
/* empty */
|
|
88
94
|
}
|
|
89
|
-
|
|
95
|
+
try {
|
|
96
|
+
this.Connect();
|
|
97
|
+
} catch (error) { }
|
|
90
98
|
}, 300000);
|
|
91
99
|
};
|
|
92
100
|
|
|
@@ -176,12 +184,24 @@ class classHUE extends EventEmitter {
|
|
|
176
184
|
};
|
|
177
185
|
// ######################################
|
|
178
186
|
|
|
187
|
+
isConnected = async () => {
|
|
188
|
+
try {
|
|
189
|
+
await this.hueApiV2.get('/resource/bridge');
|
|
190
|
+
return true;
|
|
191
|
+
} catch (error) {
|
|
192
|
+
console.log("hueEngine: isConnected: " + error.message)
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
179
197
|
close = async () =>
|
|
180
198
|
new Promise((resolve, reject) => {
|
|
181
199
|
try {
|
|
182
200
|
if (this.timerReconnect !== undefined) clearInterval(this.timerReconnect);
|
|
183
201
|
this.closePushEventStream = true;
|
|
184
|
-
|
|
202
|
+
try {
|
|
203
|
+
if (this.es !== null && this.es !== undefined) this.es.close();
|
|
204
|
+
} catch (error) { }
|
|
185
205
|
this.es = null;
|
|
186
206
|
setTimeout(() => {
|
|
187
207
|
resolve(true);
|
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.13",
|
|
7
7
|
"description": "Control your KNX intallation via Node-Red! Single Node KNX IN/OUT with optional ETS group address importer. Easy to use and highly configurable. With integrated Philips HUE devices control.",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"binary-parser": "2.2.1",
|