node-red-contrib-huemagic 4.0.4 → 4.2.0
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/README.md +27 -4
- package/huemagic/hue-bridge-config.html +7 -0
- package/huemagic/hue-bridge-config.js +168 -88
- package/huemagic/hue-brightness.html +15 -1
- package/huemagic/hue-brightness.js +30 -3
- package/huemagic/hue-buttons.html +14 -0
- package/huemagic/hue-buttons.js +5 -0
- package/huemagic/hue-group.html +15 -1
- package/huemagic/hue-group.js +153 -55
- package/huemagic/hue-light.html +15 -1
- package/huemagic/hue-light.js +196 -71
- package/huemagic/hue-motion.html +15 -1
- package/huemagic/hue-motion.js +30 -3
- package/huemagic/hue-rules.html +15 -1
- package/huemagic/hue-rules.js +30 -6
- package/huemagic/hue-scene.html +15 -1
- package/huemagic/hue-scene.js +62 -16
- package/huemagic/hue-temperature.html +15 -1
- package/huemagic/hue-temperature.js +30 -3
- package/huemagic/locales/de/hue-bridge-config.html +8 -0
- package/huemagic/locales/de/hue-group.html +1 -0
- package/huemagic/locales/en-US/hue-bridge-config.html +8 -0
- package/huemagic/locales/en-US/hue-bridge.html +1 -1
- package/huemagic/locales/en-US/hue-group.html +1 -0
- package/huemagic/locales/en-US/hue-light.html +1 -1
- package/huemagic/locales/en-US/hue-magic.html +1 -1
- package/huemagic/utils/api.js +3 -10
- package/huemagic/utils/messages.js +61 -51
- package/package.json +8 -3
|
@@ -14,7 +14,7 @@ class HueBridgeMessage
|
|
|
14
14
|
this.message.payload.factoryNew = resource.factorynew;
|
|
15
15
|
this.message.payload.replacesBridgeId = resource.replacesbridgeid ? resource.replacesbridgeid : false;
|
|
16
16
|
this.message.payload.dataStoreVersion = resource.datastoreversion;
|
|
17
|
-
this.message.payload.starterKitId = resource.starterkitid.length > 0 ? resource.starterkitid : false;
|
|
17
|
+
this.message.payload.starterKitId = resource.starterkitid && resource.starterkitid.length > 0 ? resource.starterkitid : false;
|
|
18
18
|
this.message.payload.softwareVersion = resource.swversion;
|
|
19
19
|
this.message.payload.apiVersion = resource.apiversion;
|
|
20
20
|
this.message.payload.zigbeeChannel = resource.zigbeechannel;
|
|
@@ -33,8 +33,8 @@ class HueBridgeMessage
|
|
|
33
33
|
this.message.payload.linkButtonEnabled = resource.linkbutton;
|
|
34
34
|
this.message.payload.touchlinkEnabled = (resource["touchlink"] && resource["touchlink"] == true) ? true : false;
|
|
35
35
|
this.message.payload.autoUpdatesEnabled = options["autoupdate"] ? options["autoupdate"] : false;
|
|
36
|
-
this.message.payload.users = [];
|
|
37
|
-
this.message.payload.updated = resource.updated;
|
|
36
|
+
this.message.payload.users = [];
|
|
37
|
+
this.message.payload.updated = resource.updated;
|
|
38
38
|
|
|
39
39
|
this.message.payload.model = {};
|
|
40
40
|
this.message.payload.model.id = resource.modelid;
|
|
@@ -42,14 +42,16 @@ class HueBridgeMessage
|
|
|
42
42
|
this.message.payload.model.name = "Hue v2";
|
|
43
43
|
|
|
44
44
|
// GET USERS
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
if (resource["whitelist"]) {
|
|
46
|
+
for (const [userID, user] of Object.entries(resource["whitelist"]))
|
|
47
|
+
{
|
|
48
|
+
this.message.payload.users.push({
|
|
49
|
+
user: userID,
|
|
50
|
+
name: user["name"],
|
|
51
|
+
created: user["create date"],
|
|
52
|
+
lastAccess: user["last use date"]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
57
|
|
|
@@ -75,32 +77,32 @@ class HueBrightnessMessage
|
|
|
75
77
|
|
|
76
78
|
this.message = {};
|
|
77
79
|
this.message.payload = {};
|
|
78
|
-
this.message.payload.active = service.enabled;
|
|
79
|
-
this.message.payload.reachable = connectivity ? (connectivity.status === "connected") : "unknown";
|
|
80
|
-
this.message.payload.connectionStatus = connectivity ? connectivity.status : "unknown";
|
|
80
|
+
this.message.payload.active = service.enabled;
|
|
81
|
+
this.message.payload.reachable = connectivity ? (connectivity.status === "connected") : "unknown";
|
|
82
|
+
this.message.payload.connectionStatus = connectivity ? connectivity.status : "unknown";
|
|
81
83
|
this.message.payload.lux = realLUX;
|
|
82
84
|
this.message.payload.lightLevel = service.light.light_level;
|
|
83
|
-
this.message.payload.dark = (realLUX <
|
|
84
|
-
this.message.payload.daylight = (realLUX
|
|
85
|
+
this.message.payload.dark = (realLUX < 90);
|
|
86
|
+
this.message.payload.daylight = (realLUX >= 90);
|
|
85
87
|
this.message.payload.updated = resource.updated;
|
|
86
88
|
|
|
87
89
|
this.message.info = {};
|
|
88
90
|
this.message.info.id = service.id;
|
|
89
|
-
this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false;
|
|
91
|
+
this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false;
|
|
90
92
|
this.message.info.uniqueId = resource.id + "-" + service.id;
|
|
91
|
-
this.message.info.deviceId = resource.id;
|
|
93
|
+
this.message.info.deviceId = resource.id;
|
|
92
94
|
this.message.info.name = resource.metadata.name;
|
|
93
95
|
this.message.info.type = "light_level";
|
|
94
96
|
this.message.info.softwareVersion = resource.product_data.software_version;
|
|
95
97
|
this.message.info.battery = Object.values(resource.services.device_power)[0].power_state.battery_level;
|
|
96
|
-
this.message.info.batteryState = Object.values(resource.services.device_power)[0].power_state.battery_state;
|
|
98
|
+
this.message.info.batteryState = Object.values(resource.services.device_power)[0].power_state.battery_state;
|
|
97
99
|
|
|
98
100
|
this.message.info.model = {};
|
|
99
101
|
this.message.info.model.id = resource.product_data.model_id;
|
|
100
102
|
this.message.info.model.manufacturer = resource.product_data.manufacturer_name;
|
|
101
103
|
this.message.info.model.name = resource.product_data.product_name;
|
|
102
104
|
this.message.info.model.type = resource.product_data.product_archetype;
|
|
103
|
-
this.message.info.model.certified = resource.product_data.certified;
|
|
105
|
+
this.message.info.model.certified = resource.product_data.certified;
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
get msg()
|
|
@@ -119,6 +121,13 @@ class HueGroupMessage
|
|
|
119
121
|
let service = Object.values(resource["services"]["grouped_light"])[0];
|
|
120
122
|
service = options.resources[service.id];
|
|
121
123
|
|
|
124
|
+
// GET ALL RESOURCES
|
|
125
|
+
let allResourcesInsideGroup = {};
|
|
126
|
+
for (const [type, resources] of Object.entries(resource["services"]))
|
|
127
|
+
{
|
|
128
|
+
allResourcesInsideGroup[type] = Object.keys(resource["services"][type]);
|
|
129
|
+
}
|
|
130
|
+
|
|
122
131
|
this.message = {};
|
|
123
132
|
this.message.payload = {};
|
|
124
133
|
this.message.payload.on = service.on.on;
|
|
@@ -126,8 +135,9 @@ class HueGroupMessage
|
|
|
126
135
|
|
|
127
136
|
this.message.info = {};
|
|
128
137
|
this.message.info.id = resource.id;
|
|
129
|
-
this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false;
|
|
138
|
+
this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false;
|
|
130
139
|
this.message.info.name = resource.metadata ? resource.metadata.name : "all";
|
|
140
|
+
this.message.info.resources = allResourcesInsideGroup;
|
|
131
141
|
this.message.info.type = "group";
|
|
132
142
|
}
|
|
133
143
|
|
|
@@ -153,14 +163,14 @@ class HueLightMessage
|
|
|
153
163
|
this.message.payload.brightness = service.dimming ? service.dimming.brightness : false;
|
|
154
164
|
this.message.payload.brightnessLevel = service.dimming ? Math.round((254/100)*this.message.payload.brightness) : false;
|
|
155
165
|
this.message.payload.reachable = connectivity ? (connectivity.status === "connected") : "unknown";
|
|
156
|
-
this.message.payload.connectionStatus = connectivity ? connectivity.status : "unknown";
|
|
166
|
+
this.message.payload.connectionStatus = connectivity ? connectivity.status : "unknown";
|
|
157
167
|
this.message.payload.updated = resource.updated;
|
|
158
168
|
|
|
159
169
|
this.message.info = {};
|
|
160
170
|
this.message.info.id = service.id;
|
|
161
|
-
this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false;
|
|
171
|
+
this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false;
|
|
162
172
|
this.message.info.uniqueId = resource.id + "-" + service.id;
|
|
163
|
-
this.message.info.deviceId = resource.id;
|
|
173
|
+
this.message.info.deviceId = resource.id;
|
|
164
174
|
this.message.info.name = service.metadata.name;
|
|
165
175
|
this.message.info.type = "light";
|
|
166
176
|
this.message.info.softwareVersion = resource.product_data.software_version;
|
|
@@ -170,7 +180,7 @@ class HueLightMessage
|
|
|
170
180
|
this.message.info.model.manufacturer = resource.product_data.manufacturer_name;
|
|
171
181
|
this.message.info.model.name = resource.product_data.product_name;
|
|
172
182
|
this.message.info.model.type = resource.product_data.product_archetype;
|
|
173
|
-
this.message.info.model.certified = resource.product_data.certified;
|
|
183
|
+
this.message.info.model.certified = resource.product_data.certified;
|
|
174
184
|
this.message.info.model.friendsOfHue = true;
|
|
175
185
|
|
|
176
186
|
// HAS COLOR CAPABILITIES?
|
|
@@ -179,7 +189,7 @@ class HueLightMessage
|
|
|
179
189
|
let RGB = colorUtils.xyBriToRgb(service.color.xy.x, service.color.xy.y, (service.dimming ? service.dimming.brightness : 100));
|
|
180
190
|
this.message.payload.rgb = [RGB.r, RGB.g, RGB.b];
|
|
181
191
|
this.message.payload.hex = colorUtils.rgbHex(RGB.r, RGB.g, RGB.b);
|
|
182
|
-
this.message.payload.xyColor = service.color.xy;
|
|
192
|
+
this.message.payload.xyColor = service.color.xy;
|
|
183
193
|
|
|
184
194
|
if(options.colornames == true)
|
|
185
195
|
{
|
|
@@ -187,8 +197,8 @@ class HueLightMessage
|
|
|
187
197
|
this.message.payload.color = cNamesArray.basic[0]["name"];
|
|
188
198
|
}
|
|
189
199
|
|
|
190
|
-
this.message.info.model.colorGamut = service.color.gamut;
|
|
191
|
-
this.message.info.model.colorGamutType = service.color.gamut_type;
|
|
200
|
+
this.message.info.model.colorGamut = service.color.gamut;
|
|
201
|
+
this.message.info.model.colorGamutType = service.color.gamut_type;
|
|
192
202
|
}
|
|
193
203
|
|
|
194
204
|
// HAS COLOR TEMPERATURE CAPABILITIES?
|
|
@@ -197,14 +207,14 @@ class HueLightMessage
|
|
|
197
207
|
this.message.payload.colorTemp = service.color_temperature.mirek ? service.color_temperature.mirek : false;
|
|
198
208
|
|
|
199
209
|
if(!this.message.payload.colorTemp) { this.message.payload.colorTempName = "unknown"; }
|
|
200
|
-
else if(this.message.payload.colorTemp < 200) { this.message.payload.colorTempName = "cold"; }
|
|
210
|
+
else if(this.message.payload.colorTemp < 200) { this.message.payload.colorTempName = "cold"; }
|
|
201
211
|
else if(this.message.payload.colorTemp < 350) { this.message.payload.colorTempName = "normal"; }
|
|
202
212
|
else if(this.message.payload.colorTemp < 410) { this.message.payload.colorTempName = "warm"; }
|
|
203
213
|
else { this.message.payload.colorTempName = "hot"; }
|
|
204
214
|
}
|
|
205
215
|
|
|
206
216
|
// HAS GRADIENT COLOR CAPABILITIES?
|
|
207
|
-
if(service["gradient"])
|
|
217
|
+
if(service["gradient"])
|
|
208
218
|
{
|
|
209
219
|
this.message.payload.gradient = {};
|
|
210
220
|
this.message.payload.gradient.colors = [];
|
|
@@ -246,28 +256,28 @@ class HueMotionMessage
|
|
|
246
256
|
this.message.payload = {
|
|
247
257
|
active: service.enabled,
|
|
248
258
|
reachable: connectivity ? (connectivity.status === "connected") : "unknown",
|
|
249
|
-
connectionStatus: connectivity ? connectivity.status : "unknown",
|
|
259
|
+
connectionStatus: connectivity ? connectivity.status : "unknown",
|
|
250
260
|
motion: (service.motion.motion && service.motion.motion_valid),
|
|
251
261
|
updated: resource.updated
|
|
252
262
|
};
|
|
253
263
|
|
|
254
264
|
this.message.info = {};
|
|
255
265
|
this.message.info.id = service.id;
|
|
256
|
-
this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false;
|
|
266
|
+
this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false;
|
|
257
267
|
this.message.info.uniqueId = resource.id + "-" + service.id;
|
|
258
|
-
this.message.info.deviceId = resource.id;
|
|
268
|
+
this.message.info.deviceId = resource.id;
|
|
259
269
|
this.message.info.name = resource.metadata.name;
|
|
260
270
|
this.message.info.type = "motion";
|
|
261
271
|
this.message.info.softwareVersion = resource.product_data.software_version;
|
|
262
272
|
this.message.info.battery = Object.values(resource.services.device_power)[0].power_state.battery_level;
|
|
263
|
-
this.message.info.batteryState = Object.values(resource.services.device_power)[0].power_state.battery_state;
|
|
273
|
+
this.message.info.batteryState = Object.values(resource.services.device_power)[0].power_state.battery_state;
|
|
264
274
|
|
|
265
275
|
this.message.info.model = {};
|
|
266
276
|
this.message.info.model.id = resource.product_data.model_id;
|
|
267
277
|
this.message.info.model.manufacturer = resource.product_data.manufacturer_name;
|
|
268
278
|
this.message.info.model.name = resource.product_data.product_name;
|
|
269
279
|
this.message.info.model.type = resource.product_data.product_archetype;
|
|
270
|
-
this.message.info.model.certified = resource.product_data.certified;
|
|
280
|
+
this.message.info.model.certified = resource.product_data.certified;
|
|
271
281
|
}
|
|
272
282
|
|
|
273
283
|
get msg()
|
|
@@ -285,7 +295,7 @@ class HueRulesMessage
|
|
|
285
295
|
{
|
|
286
296
|
this.message = {};
|
|
287
297
|
this.message.payload = {};
|
|
288
|
-
this.message.payload.enabled = (resource["status"] == "enabled");
|
|
298
|
+
this.message.payload.enabled = (resource["status"] == "enabled");
|
|
289
299
|
this.message.payload.triggered = (resource["lasttriggered"] != null) ? dayjs(resource["lasttriggered"]).format() : false;
|
|
290
300
|
|
|
291
301
|
this.message.info = {};
|
|
@@ -330,30 +340,30 @@ class HueButtonsMessage
|
|
|
330
340
|
|
|
331
341
|
this.message = {};
|
|
332
342
|
this.message.payload = {
|
|
333
|
-
reachable: connectivity ? (connectivity.status === "connected") : "unknown",
|
|
334
|
-
connectionStatus: connectivity ? connectivity.status : "unknown",
|
|
335
|
-
button: pressedButton ? pressedButton.metadata.control_id : false,
|
|
336
|
-
action: pressedButton ? pressedButton.button.last_event : false,
|
|
343
|
+
reachable: connectivity ? (connectivity.status === "connected") : "unknown",
|
|
344
|
+
connectionStatus: connectivity ? connectivity.status : "unknown",
|
|
345
|
+
button: pressedButton ? pressedButton.metadata.control_id : false,
|
|
346
|
+
action: pressedButton ? pressedButton.button.last_event : false,
|
|
337
347
|
updated: resource.updated
|
|
338
348
|
};
|
|
339
349
|
|
|
340
350
|
this.message.info = {};
|
|
341
351
|
this.message.info.id = pressedButton ? pressedButton.id : resource.id;
|
|
342
|
-
this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false;
|
|
352
|
+
this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false;
|
|
343
353
|
this.message.info.uniqueId = resource.id + "-" + (pressedButton ? pressedButton.id : "");
|
|
344
|
-
this.message.info.deviceId = resource.id;
|
|
354
|
+
this.message.info.deviceId = resource.id;
|
|
345
355
|
this.message.info.name = resource.metadata.name;
|
|
346
356
|
this.message.info.type = "button";
|
|
347
357
|
this.message.info.softwareVersion = resource.product_data.software_version;
|
|
348
358
|
this.message.info.battery = resource.services.device_power ? Object.values(resource.services.device_power)[0].power_state.battery_level : false;
|
|
349
|
-
this.message.info.batteryState = resource.services.device_power ? Object.values(resource.services.device_power)[0].power_state.battery_state : false;
|
|
359
|
+
this.message.info.batteryState = resource.services.device_power ? Object.values(resource.services.device_power)[0].power_state.battery_state : false;
|
|
350
360
|
|
|
351
361
|
this.message.info.model = {};
|
|
352
362
|
this.message.info.model.id = resource.product_data.model_id;
|
|
353
363
|
this.message.info.model.manufacturer = resource.product_data.manufacturer_name;
|
|
354
364
|
this.message.info.model.name = resource.product_data.product_name;
|
|
355
365
|
this.message.info.model.type = resource.product_data.product_archetype;
|
|
356
|
-
this.message.info.model.certified = resource.product_data.certified;
|
|
366
|
+
this.message.info.model.certified = resource.product_data.certified;
|
|
357
367
|
}
|
|
358
368
|
|
|
359
369
|
get msg()
|
|
@@ -406,9 +416,9 @@ class HueTemperatureMessage
|
|
|
406
416
|
|
|
407
417
|
this.message = {};
|
|
408
418
|
this.message.payload = {
|
|
409
|
-
active: service.enabled,
|
|
410
|
-
reachable: connectivity ? (connectivity.status === "connected") : "unknown",
|
|
411
|
-
connectionStatus: connectivity ? connectivity.status : "unknown",
|
|
419
|
+
active: service.enabled,
|
|
420
|
+
reachable: connectivity ? (connectivity.status === "connected") : "unknown",
|
|
421
|
+
connectionStatus: connectivity ? connectivity.status : "unknown",
|
|
412
422
|
celsius: celsius,
|
|
413
423
|
fahrenheit: fahrenheit,
|
|
414
424
|
temperatureIs: temperatureMessage,
|
|
@@ -418,21 +428,21 @@ class HueTemperatureMessage
|
|
|
418
428
|
|
|
419
429
|
this.message.info = {};
|
|
420
430
|
this.message.info.id = service.id;
|
|
421
|
-
this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false;
|
|
431
|
+
this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false;
|
|
422
432
|
this.message.info.uniqueId = resource.id + "-" + service.id;
|
|
423
|
-
this.message.info.deviceId = resource.id;
|
|
433
|
+
this.message.info.deviceId = resource.id;
|
|
424
434
|
this.message.info.name = resource.metadata.name;
|
|
425
435
|
this.message.info.type = "temperature";
|
|
426
436
|
this.message.info.softwareVersion = resource.product_data.software_version;
|
|
427
437
|
this.message.info.battery = Object.values(resource.services.device_power)[0].power_state.battery_level;
|
|
428
|
-
this.message.info.batteryState = Object.values(resource.services.device_power)[0].power_state.battery_state;
|
|
438
|
+
this.message.info.batteryState = Object.values(resource.services.device_power)[0].power_state.battery_state;
|
|
429
439
|
|
|
430
440
|
this.message.info.model = {};
|
|
431
441
|
this.message.info.model.id = resource.product_data.model_id;
|
|
432
442
|
this.message.info.model.manufacturer = resource.product_data.manufacturer_name;
|
|
433
443
|
this.message.info.model.name = resource.product_data.product_name;
|
|
434
444
|
this.message.info.model.type = resource.product_data.product_archetype;
|
|
435
|
-
this.message.info.model.certified = resource.product_data.certified;
|
|
445
|
+
this.message.info.model.certified = resource.product_data.certified;
|
|
436
446
|
}
|
|
437
447
|
|
|
438
448
|
get msg()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-huemagic",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Philips Hue node to control bridges, lights, groups, scenes, rules, taps, switches, buttons, motion sensors, temperature sensors and Lux sensors using Node-RED.",
|
|
5
5
|
"author": "foddy",
|
|
6
6
|
"homepage": "https://github.com/Foddy/node-red-contrib-huemagic",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"iot"
|
|
28
28
|
],
|
|
29
29
|
"node-red": {
|
|
30
|
+
"version": ">=2.1.0",
|
|
30
31
|
"nodes": {
|
|
31
32
|
"hue-bridge": "huemagic/hue-bridge-config.js",
|
|
32
33
|
"hue-bridge-node": "huemagic/hue-bridge.js",
|
|
@@ -41,17 +42,21 @@
|
|
|
41
42
|
"hue-rules": "huemagic/hue-rules.js"
|
|
42
43
|
}
|
|
43
44
|
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=14.0.0"
|
|
47
|
+
},
|
|
44
48
|
"publishConfig": {
|
|
45
49
|
"access": "public"
|
|
46
50
|
},
|
|
47
51
|
"dependencies": {
|
|
48
52
|
"async": "^3.2.2",
|
|
49
|
-
"axios": "^0.
|
|
53
|
+
"axios": "^0.26.1",
|
|
50
54
|
"color-namer": "^1.4.0",
|
|
51
55
|
"colornames": "^1.1.1",
|
|
52
56
|
"dayjs": "^1.10.7",
|
|
53
57
|
"deep-object-diff": "^1.1.0",
|
|
54
|
-
"eventsource": "^
|
|
58
|
+
"eventsource": "^2.0.0",
|
|
59
|
+
"fastq": "^1.13.0",
|
|
55
60
|
"get-image-colors": "^4.0.0"
|
|
56
61
|
}
|
|
57
62
|
}
|