node-red-contrib-huemagic 4.0.2 → 4.1.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.
Files changed (36) hide show
  1. package/README.md +31 -14
  2. package/examples/Hue Bridge.json +1 -1
  3. package/huemagic/hue-bridge-config.html +11 -4
  4. package/huemagic/hue-bridge-config.js +180 -154
  5. package/huemagic/hue-bridge.js +5 -5
  6. package/huemagic/hue-brightness.html +22 -8
  7. package/huemagic/hue-brightness.js +16 -5
  8. package/huemagic/hue-buttons.html +21 -7
  9. package/huemagic/hue-buttons.js +16 -5
  10. package/huemagic/hue-group.html +26 -12
  11. package/huemagic/hue-group.js +8 -3
  12. package/huemagic/hue-light.html +22 -8
  13. package/huemagic/hue-light.js +8 -3
  14. package/huemagic/hue-motion.html +22 -8
  15. package/huemagic/hue-motion.js +16 -5
  16. package/huemagic/hue-rules.html +20 -6
  17. package/huemagic/hue-rules.js +15 -4
  18. package/huemagic/hue-scene.html +20 -6
  19. package/huemagic/hue-scene.js +1 -1
  20. package/huemagic/hue-temperature.html +22 -8
  21. package/huemagic/hue-temperature.js +16 -5
  22. package/huemagic/locales/de/hue-bridge-config.html +8 -0
  23. package/huemagic/locales/de/hue-bridge.json +1 -1
  24. package/huemagic/locales/de/hue-group.html +1 -0
  25. package/huemagic/locales/en-US/hue-bridge-config.html +8 -0
  26. package/huemagic/locales/en-US/hue-bridge.html +1 -1
  27. package/huemagic/locales/en-US/hue-bridge.json +1 -1
  28. package/huemagic/locales/en-US/hue-buttons.html +1 -1
  29. package/huemagic/locales/en-US/hue-group.html +1 -0
  30. package/huemagic/locales/en-US/hue-light.html +1 -1
  31. package/huemagic/locales/en-US/hue-magic.html +3 -3
  32. package/huemagic/locales/en-US/hue-motion.html +1 -1
  33. package/huemagic/locales/en-US/hue-temperature.html +1 -1
  34. package/huemagic/utils/api.js +88 -94
  35. package/huemagic/utils/messages.js +134 -126
  36. package/package.json +2 -1
@@ -5,44 +5,44 @@ const colorUtils = require("./color");
5
5
  // HUE BRIDGE
6
6
  class HueBridgeMessage
7
7
  {
8
- constructor(ressource, options = {})
8
+ constructor(resource, options = {})
9
9
  {
10
10
  this.message = {};
11
11
  this.message.payload = {};
12
- this.message.payload.id = ressource.bridgeid;
13
- this.message.payload.name = ressource.name;
14
- this.message.payload.factoryNew = ressource.factorynew;
15
- this.message.payload.replacesBridgeId = ressource.replacesbridgeid ? ressource.replacesbridgeid : false;
16
- this.message.payload.dataStoreVersion = ressource.datastoreversion;
17
- this.message.payload.starterKitId = ressource.starterkitid.length > 0 ? ressource.starterkitid : false;
18
- this.message.payload.softwareVersion = ressource.swversion;
19
- this.message.payload.apiVersion = ressource.apiversion;
20
- this.message.payload.zigbeeChannel = ressource.zigbeechannel;
21
- this.message.payload.macAddress = ressource.mac;
22
- this.message.payload.ipAddress = ressource.ipaddress;
23
- this.message.payload.dhcpEnabled = ressource.dhcp;
24
- this.message.payload.netmask = ressource.netmask;
25
- this.message.payload.gateway = ressource.gateway;
26
- this.message.payload.proxyAddress = ressource.proxyaddress == "none" ? false : ressource.proxyaddress;
27
- this.message.payload.proxyPort = ressource.proxyport;
28
- this.message.payload.utcTime = ressource.UTC;
29
- this.message.payload.timeZone = ressource.timezone;
30
- this.message.payload.localTime = ressource.localtime;
31
- this.message.payload.portalServicesEnabled = ressource.portalservices;
32
- this.message.payload.portalConnected = ressource.portalconnection;
33
- this.message.payload.linkButtonEnabled = ressource.linkbutton;
34
- this.message.payload.touchlinkEnabled = (ressource["touchlink"] && ressource["touchlink"] == true) ? true : false;
12
+ this.message.payload.id = resource.bridgeid;
13
+ this.message.payload.name = resource.name;
14
+ this.message.payload.factoryNew = resource.factorynew;
15
+ this.message.payload.replacesBridgeId = resource.replacesbridgeid ? resource.replacesbridgeid : false;
16
+ this.message.payload.dataStoreVersion = resource.datastoreversion;
17
+ this.message.payload.starterKitId = resource.starterkitid.length > 0 ? resource.starterkitid : false;
18
+ this.message.payload.softwareVersion = resource.swversion;
19
+ this.message.payload.apiVersion = resource.apiversion;
20
+ this.message.payload.zigbeeChannel = resource.zigbeechannel;
21
+ this.message.payload.macAddress = resource.mac;
22
+ this.message.payload.ipAddress = resource.ipaddress;
23
+ this.message.payload.dhcpEnabled = resource.dhcp;
24
+ this.message.payload.netmask = resource.netmask;
25
+ this.message.payload.gateway = resource.gateway;
26
+ this.message.payload.proxyAddress = resource.proxyaddress == "none" ? false : resource.proxyaddress;
27
+ this.message.payload.proxyPort = resource.proxyport;
28
+ this.message.payload.utcTime = resource.UTC;
29
+ this.message.payload.timeZone = resource.timezone;
30
+ this.message.payload.localTime = resource.localtime;
31
+ this.message.payload.portalServicesEnabled = resource.portalservices;
32
+ this.message.payload.portalConnected = resource.portalconnection;
33
+ this.message.payload.linkButtonEnabled = resource.linkbutton;
34
+ this.message.payload.touchlinkEnabled = (resource["touchlink"] && resource["touchlink"] == true) ? true : false;
35
35
  this.message.payload.autoUpdatesEnabled = options["autoupdate"] ? options["autoupdate"] : false;
36
36
  this.message.payload.users = []; // NEW!
37
- this.message.payload.updated = ressource.updated; // NEW!
37
+ this.message.payload.updated = resource.updated; // NEW!
38
38
 
39
39
  this.message.payload.model = {};
40
- this.message.payload.model.id = ressource.modelid;
40
+ this.message.payload.model.id = resource.modelid;
41
41
  this.message.payload.model.manufacturer = "Philips";
42
42
  this.message.payload.model.name = "Hue v2";
43
43
 
44
44
  // GET USERS
45
- for (const [userID, user] of Object.entries(ressource["whitelist"]))
45
+ for (const [userID, user] of Object.entries(resource["whitelist"]))
46
46
  {
47
47
  this.message.payload.users.push({
48
48
  user: userID,
@@ -64,10 +64,10 @@ class HueBridgeMessage
64
64
  // HUE BRIGHTNESS
65
65
  class HueBrightnessMessage
66
66
  {
67
- constructor(ressource, options = {})
67
+ constructor(resource, options = {})
68
68
  {
69
- const service = Object.values(ressource["services"]["light_level"])[0];
70
- const connectivity = ressource.services.zigbee_connectivity ? Object.values(ressource.services.zigbee_connectivity)[0] : ((ressource.services.zgp_connectivity) ? Object.values(ressource.services.zgp_connectivity)[0] : false);
69
+ const service = Object.values(resource["services"]["light_level"])[0];
70
+ const connectivity = resource.services.zigbee_connectivity ? Object.values(resource.services.zigbee_connectivity)[0] : ((resource.services.zgp_connectivity) ? Object.values(resource.services.zgp_connectivity)[0] : false);
71
71
 
72
72
  var realLUX = service.light.light_level - 1;
73
73
  realLUX = realLUX / 10000;
@@ -80,27 +80,27 @@ class HueBrightnessMessage
80
80
  this.message.payload.connectionStatus = connectivity ? connectivity.status : "unknown"; // NEW!
81
81
  this.message.payload.lux = realLUX;
82
82
  this.message.payload.lightLevel = service.light.light_level;
83
- this.message.payload.dark = (realLUX < 200);
84
- this.message.payload.daylight = (realLUX > 200);
85
- this.message.payload.updated = ressource.updated;
83
+ this.message.payload.dark = (realLUX < 90);
84
+ this.message.payload.daylight = (realLUX >= 90);
85
+ this.message.payload.updated = resource.updated;
86
86
 
87
87
  this.message.info = {};
88
88
  this.message.info.id = service.id;
89
- this.message.info.idV1 = ressource.id_v1 ? ressource.id_v1 : false; // NEW
90
- this.message.info.uniqueId = ressource.id + "-" + service.id;
91
- this.message.info.deviceId = ressource.id; // NEW!
92
- this.message.info.name = ressource.metadata.name;
89
+ this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false; // NEW
90
+ this.message.info.uniqueId = resource.id + "-" + service.id;
91
+ this.message.info.deviceId = resource.id; // NEW!
92
+ this.message.info.name = resource.metadata.name;
93
93
  this.message.info.type = "light_level";
94
- this.message.info.softwareVersion = ressource.product_data.software_version;
95
- this.message.info.battery = Object.values(ressource.services.device_power)[0].power_state.battery_level;
96
- this.message.info.batteryState = Object.values(ressource.services.device_power)[0].power_state.battery_state; // NEW!
94
+ this.message.info.softwareVersion = resource.product_data.software_version;
95
+ 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; // NEW!
97
97
 
98
98
  this.message.info.model = {};
99
- this.message.info.model.id = ressource.product_data.model_id;
100
- this.message.info.model.manufacturer = ressource.product_data.manufacturer_name;
101
- this.message.info.model.name = ressource.product_data.product_name;
102
- this.message.info.model.type = ressource.product_data.product_archetype;
103
- this.message.info.model.certified = ressource.product_data.certified; // NEW
99
+ this.message.info.model.id = resource.product_data.model_id;
100
+ this.message.info.model.manufacturer = resource.product_data.manufacturer_name;
101
+ this.message.info.model.name = resource.product_data.product_name;
102
+ this.message.info.model.type = resource.product_data.product_archetype;
103
+ this.message.info.model.certified = resource.product_data.certified; // NEW
104
104
  }
105
105
 
106
106
  get msg()
@@ -114,20 +114,28 @@ class HueBrightnessMessage
114
114
  // HUE GROUP
115
115
  class HueGroupMessage
116
116
  {
117
- constructor(ressource, options = {})
117
+ constructor(resource, options = {})
118
118
  {
119
- let service = Object.values(ressource["services"]["grouped_light"])[0];
120
- service = options.ressources[service.id];
119
+ let service = Object.values(resource["services"]["grouped_light"])[0];
120
+ service = options.resources[service.id];
121
+
122
+ // GET ALL RESOURCES
123
+ let allResourcesInsideGroup = {};
124
+ for (const [type, resources] of Object.entries(resource["services"]))
125
+ {
126
+ allResourcesInsideGroup[type] = Object.keys(resource["services"][type]);
127
+ }
121
128
 
122
129
  this.message = {};
123
130
  this.message.payload = {};
124
131
  this.message.payload.on = service.on.on;
125
- this.message.payload.updated = ressource.updated;
132
+ this.message.payload.updated = resource.updated;
126
133
 
127
134
  this.message.info = {};
128
- this.message.info.id = ressource.id;
129
- this.message.info.idV1 = ressource.id_v1 ? ressource.id_v1 : false; // NEW
130
- this.message.info.name = ressource.metadata ? ressource.metadata.name : "all";
135
+ this.message.info.id = resource.id;
136
+ this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false; // NEW
137
+ this.message.info.name = resource.metadata ? resource.metadata.name : "all";
138
+ this.message.info.resources = allResourcesInsideGroup; // NEW
131
139
  this.message.info.type = "group";
132
140
  }
133
141
 
@@ -142,10 +150,10 @@ class HueGroupMessage
142
150
  // HUE LIGHT
143
151
  class HueLightMessage
144
152
  {
145
- constructor(ressource, options = {})
153
+ constructor(resource, options = {})
146
154
  {
147
- const service = Object.values(ressource["services"]["light"])[0];
148
- const connectivity = ressource.services.zigbee_connectivity ? Object.values(ressource.services.zigbee_connectivity)[0] : ((ressource.services.zgp_connectivity) ? Object.values(ressource.services.zgp_connectivity)[0] : false);
155
+ const service = Object.values(resource["services"]["light"])[0];
156
+ const connectivity = resource.services.zigbee_connectivity ? Object.values(resource.services.zigbee_connectivity)[0] : ((resource.services.zgp_connectivity) ? Object.values(resource.services.zgp_connectivity)[0] : false);
149
157
 
150
158
  this.message = {};
151
159
  this.message.payload = {};
@@ -154,23 +162,23 @@ class HueLightMessage
154
162
  this.message.payload.brightnessLevel = service.dimming ? Math.round((254/100)*this.message.payload.brightness) : false;
155
163
  this.message.payload.reachable = connectivity ? (connectivity.status === "connected") : "unknown";
156
164
  this.message.payload.connectionStatus = connectivity ? connectivity.status : "unknown"; // NEW!
157
- this.message.payload.updated = ressource.updated;
165
+ this.message.payload.updated = resource.updated;
158
166
 
159
167
  this.message.info = {};
160
168
  this.message.info.id = service.id;
161
- this.message.info.idV1 = ressource.id_v1 ? ressource.id_v1 : false; // NEW
162
- this.message.info.uniqueId = ressource.id + "-" + service.id;
163
- this.message.info.deviceId = ressource.id; // NEW!
169
+ this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false; // NEW
170
+ this.message.info.uniqueId = resource.id + "-" + service.id;
171
+ this.message.info.deviceId = resource.id; // NEW!
164
172
  this.message.info.name = service.metadata.name;
165
173
  this.message.info.type = "light";
166
- this.message.info.softwareVersion = ressource.product_data.software_version;
174
+ this.message.info.softwareVersion = resource.product_data.software_version;
167
175
 
168
176
  this.message.info.model = {};
169
- this.message.info.model.id = ressource.product_data.model_id;
170
- this.message.info.model.manufacturer = ressource.product_data.manufacturer_name;
171
- this.message.info.model.name = ressource.product_data.product_name;
172
- this.message.info.model.type = ressource.product_data.product_archetype;
173
- this.message.info.model.certified = ressource.product_data.certified; // NEW
177
+ this.message.info.model.id = resource.product_data.model_id;
178
+ this.message.info.model.manufacturer = resource.product_data.manufacturer_name;
179
+ this.message.info.model.name = resource.product_data.product_name;
180
+ this.message.info.model.type = resource.product_data.product_archetype;
181
+ this.message.info.model.certified = resource.product_data.certified; // NEW
174
182
  this.message.info.model.friendsOfHue = true;
175
183
 
176
184
  // HAS COLOR CAPABILITIES?
@@ -237,10 +245,10 @@ class HueLightMessage
237
245
  // HUE MOTION
238
246
  class HueMotionMessage
239
247
  {
240
- constructor(ressource, options = {})
248
+ constructor(resource, options = {})
241
249
  {
242
- const service = Object.values(ressource["services"]["motion"])[0];
243
- const connectivity = ressource.services.zigbee_connectivity ? Object.values(ressource.services.zigbee_connectivity)[0] : ((ressource.services.zgp_connectivity) ? Object.values(ressource.services.zgp_connectivity)[0] : false);
250
+ const service = Object.values(resource["services"]["motion"])[0];
251
+ const connectivity = resource.services.zigbee_connectivity ? Object.values(resource.services.zigbee_connectivity)[0] : ((resource.services.zgp_connectivity) ? Object.values(resource.services.zgp_connectivity)[0] : false);
244
252
 
245
253
  this.message = {};
246
254
  this.message.payload = {
@@ -248,26 +256,26 @@ class HueMotionMessage
248
256
  reachable: connectivity ? (connectivity.status === "connected") : "unknown",
249
257
  connectionStatus: connectivity ? connectivity.status : "unknown", // NEW!
250
258
  motion: (service.motion.motion && service.motion.motion_valid),
251
- updated: ressource.updated
259
+ updated: resource.updated
252
260
  };
253
261
 
254
262
  this.message.info = {};
255
263
  this.message.info.id = service.id;
256
- this.message.info.idV1 = ressource.id_v1 ? ressource.id_v1 : false; // NEW
257
- this.message.info.uniqueId = ressource.id + "-" + service.id;
258
- this.message.info.deviceId = ressource.id; // NEW!
259
- this.message.info.name = ressource.metadata.name;
264
+ this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false; // NEW
265
+ this.message.info.uniqueId = resource.id + "-" + service.id;
266
+ this.message.info.deviceId = resource.id; // NEW!
267
+ this.message.info.name = resource.metadata.name;
260
268
  this.message.info.type = "motion";
261
- this.message.info.softwareVersion = ressource.product_data.software_version;
262
- this.message.info.battery = Object.values(ressource.services.device_power)[0].power_state.battery_level;
263
- this.message.info.batteryState = Object.values(ressource.services.device_power)[0].power_state.battery_state; // NEW!
269
+ this.message.info.softwareVersion = resource.product_data.software_version;
270
+ this.message.info.battery = Object.values(resource.services.device_power)[0].power_state.battery_level;
271
+ this.message.info.batteryState = Object.values(resource.services.device_power)[0].power_state.battery_state; // NEW!
264
272
 
265
273
  this.message.info.model = {};
266
- this.message.info.model.id = ressource.product_data.model_id;
267
- this.message.info.model.manufacturer = ressource.product_data.manufacturer_name;
268
- this.message.info.model.name = ressource.product_data.product_name;
269
- this.message.info.model.type = ressource.product_data.product_archetype;
270
- this.message.info.model.certified = ressource.product_data.certified; // NEW
274
+ this.message.info.model.id = resource.product_data.model_id;
275
+ this.message.info.model.manufacturer = resource.product_data.manufacturer_name;
276
+ this.message.info.model.name = resource.product_data.product_name;
277
+ this.message.info.model.type = resource.product_data.product_archetype;
278
+ this.message.info.model.certified = resource.product_data.certified; // NEW
271
279
  }
272
280
 
273
281
  get msg()
@@ -281,23 +289,23 @@ class HueMotionMessage
281
289
  // HUE RULES
282
290
  class HueRulesMessage
283
291
  {
284
- constructor(ressource, options = {})
292
+ constructor(resource, options = {})
285
293
  {
286
294
  this.message = {};
287
295
  this.message.payload = {};
288
- this.message.payload.enabled = (ressource["status"] == "enabled"); // NEW!
289
- this.message.payload.triggered = (ressource["lasttriggered"] != null) ? dayjs(ressource["lasttriggered"]).format() : false;
296
+ this.message.payload.enabled = (resource["status"] == "enabled"); // NEW!
297
+ this.message.payload.triggered = (resource["lasttriggered"] != null) ? dayjs(resource["lasttriggered"]).format() : false;
290
298
 
291
299
  this.message.info = {};
292
- this.message.info.id = ressource["id"];
293
- this.message.info.created = dayjs(ressource["created"]).format();
294
- this.message.info.name = ressource["name"];
295
- this.message.info.timesTriggered = ressource["timestriggered"];
296
- this.message.info.owner = ressource["_owner"];
297
- this.message.info.status = ressource["status"];
298
-
299
- this.message.conditions = ressource["conditions"];
300
- this.message.actions = ressource["actions"];
300
+ this.message.info.id = resource["id"];
301
+ this.message.info.created = dayjs(resource["created"]).format();
302
+ this.message.info.name = resource["name"];
303
+ this.message.info.timesTriggered = resource["timestriggered"];
304
+ this.message.info.owner = resource["_owner"];
305
+ this.message.info.status = resource["status"];
306
+
307
+ this.message.conditions = resource["conditions"];
308
+ this.message.actions = resource["actions"];
301
309
  }
302
310
 
303
311
  get msg()
@@ -311,13 +319,13 @@ class HueRulesMessage
311
319
  // HUE BUTTONS
312
320
  class HueButtonsMessage
313
321
  {
314
- constructor(ressource, options = {})
322
+ constructor(resource, options = {})
315
323
  {
316
- const connectivity = ressource.services.zigbee_connectivity ? Object.values(ressource.services.zigbee_connectivity)[0] : ((ressource.services.zgp_connectivity) ? Object.values(ressource.services.zgp_connectivity)[0] : false);
324
+ const connectivity = resource.services.zigbee_connectivity ? Object.values(resource.services.zigbee_connectivity)[0] : ((resource.services.zgp_connectivity) ? Object.values(resource.services.zgp_connectivity)[0] : false);
317
325
 
318
326
  // FIND PRESSED BUTTON
319
327
  var pressedButton = false;
320
- const allButtons = Object.values(ressource.services.button);
328
+ const allButtons = Object.values(resource.services.button);
321
329
 
322
330
  for (var i = allButtons.length - 1; i >= 0; i--)
323
331
  {
@@ -334,26 +342,26 @@ class HueButtonsMessage
334
342
  connectionStatus: connectivity ? connectivity.status : "unknown", // NEW!
335
343
  button: pressedButton ? pressedButton.metadata.control_id : false, // NEW
336
344
  action: pressedButton ? pressedButton.button.last_event : false, // NEW
337
- updated: ressource.updated
345
+ updated: resource.updated
338
346
  };
339
347
 
340
348
  this.message.info = {};
341
- this.message.info.id = pressedButton ? pressedButton.id : ressource.id;
342
- this.message.info.idV1 = ressource.id_v1 ? ressource.id_v1 : false; // NEW
343
- this.message.info.uniqueId = ressource.id + "-" + (pressedButton ? pressedButton.id : "");
344
- this.message.info.deviceId = ressource.id; // NEW!
345
- this.message.info.name = ressource.metadata.name;
349
+ this.message.info.id = pressedButton ? pressedButton.id : resource.id;
350
+ this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false; // NEW
351
+ this.message.info.uniqueId = resource.id + "-" + (pressedButton ? pressedButton.id : "");
352
+ this.message.info.deviceId = resource.id; // NEW!
353
+ this.message.info.name = resource.metadata.name;
346
354
  this.message.info.type = "button";
347
- this.message.info.softwareVersion = ressource.product_data.software_version;
348
- this.message.info.battery = ressource.services.device_power ? Object.values(ressource.services.device_power)[0].power_state.battery_level : false;
349
- this.message.info.batteryState = ressource.services.device_power ? Object.values(ressource.services.device_power)[0].power_state.battery_state : false; // NEW!
355
+ this.message.info.softwareVersion = resource.product_data.software_version;
356
+ this.message.info.battery = resource.services.device_power ? Object.values(resource.services.device_power)[0].power_state.battery_level : false;
357
+ this.message.info.batteryState = resource.services.device_power ? Object.values(resource.services.device_power)[0].power_state.battery_state : false; // NEW!
350
358
 
351
359
  this.message.info.model = {};
352
- this.message.info.model.id = ressource.product_data.model_id;
353
- this.message.info.model.manufacturer = ressource.product_data.manufacturer_name;
354
- this.message.info.model.name = ressource.product_data.product_name;
355
- this.message.info.model.type = ressource.product_data.product_archetype;
356
- this.message.info.model.certified = ressource.product_data.certified; // NEW
360
+ this.message.info.model.id = resource.product_data.model_id;
361
+ this.message.info.model.manufacturer = resource.product_data.manufacturer_name;
362
+ this.message.info.model.name = resource.product_data.product_name;
363
+ this.message.info.model.type = resource.product_data.product_archetype;
364
+ this.message.info.model.certified = resource.product_data.certified; // NEW
357
365
  }
358
366
 
359
367
  get msg()
@@ -367,10 +375,10 @@ class HueButtonsMessage
367
375
  // HUE TEMPERATURE
368
376
  class HueTemperatureMessage
369
377
  {
370
- constructor(ressource, options = {})
378
+ constructor(resource, options = {})
371
379
  {
372
- const service = Object.values(ressource["services"]["temperature"])[0];
373
- const connectivity = ressource.services.zigbee_connectivity ? Object.values(ressource.services.zigbee_connectivity)[0] : ((ressource.services.zgp_connectivity) ? Object.values(ressource.services.zgp_connectivity)[0] : false);
380
+ const service = Object.values(resource["services"]["temperature"])[0];
381
+ const connectivity = resource.services.zigbee_connectivity ? Object.values(resource.services.zigbee_connectivity)[0] : ((resource.services.zgp_connectivity) ? Object.values(resource.services.zgp_connectivity)[0] : false);
374
382
 
375
383
  var deviceValue = service.temperature.temperature;
376
384
  var celsius = Math.round(deviceValue * 100) / 100;
@@ -413,26 +421,26 @@ class HueTemperatureMessage
413
421
  fahrenheit: fahrenheit,
414
422
  temperatureIs: temperatureMessage,
415
423
  deviceValue: deviceValue,
416
- updated: ressource.updated
424
+ updated: resource.updated
417
425
  };
418
426
 
419
427
  this.message.info = {};
420
428
  this.message.info.id = service.id;
421
- this.message.info.idV1 = ressource.id_v1 ? ressource.id_v1 : false; // NEW
422
- this.message.info.uniqueId = ressource.id + "-" + service.id;
423
- this.message.info.deviceId = ressource.id; // NEW!
424
- this.message.info.name = ressource.metadata.name;
429
+ this.message.info.idV1 = resource.id_v1 ? resource.id_v1 : false; // NEW
430
+ this.message.info.uniqueId = resource.id + "-" + service.id;
431
+ this.message.info.deviceId = resource.id; // NEW!
432
+ this.message.info.name = resource.metadata.name;
425
433
  this.message.info.type = "temperature";
426
- this.message.info.softwareVersion = ressource.product_data.software_version;
427
- this.message.info.battery = Object.values(ressource.services.device_power)[0].power_state.battery_level;
428
- this.message.info.batteryState = Object.values(ressource.services.device_power)[0].power_state.battery_state; // NEW!
434
+ this.message.info.softwareVersion = resource.product_data.software_version;
435
+ this.message.info.battery = Object.values(resource.services.device_power)[0].power_state.battery_level;
436
+ this.message.info.batteryState = Object.values(resource.services.device_power)[0].power_state.battery_state; // NEW!
429
437
 
430
438
  this.message.info.model = {};
431
- this.message.info.model.id = ressource.product_data.model_id;
432
- this.message.info.model.manufacturer = ressource.product_data.manufacturer_name;
433
- this.message.info.model.name = ressource.product_data.product_name;
434
- this.message.info.model.type = ressource.product_data.product_archetype;
435
- this.message.info.model.certified = ressource.product_data.certified; // NEW
439
+ this.message.info.model.id = resource.product_data.model_id;
440
+ this.message.info.model.manufacturer = resource.product_data.manufacturer_name;
441
+ this.message.info.model.name = resource.product_data.product_name;
442
+ this.message.info.model.type = resource.product_data.product_archetype;
443
+ this.message.info.model.certified = resource.product_data.certified; // NEW
436
444
  }
437
445
 
438
446
  get msg()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-huemagic",
3
- "version": "4.0.2",
3
+ "version": "4.1.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",
@@ -52,6 +52,7 @@
52
52
  "dayjs": "^1.10.7",
53
53
  "deep-object-diff": "^1.1.0",
54
54
  "eventsource": "^1.1.0",
55
+ "fastq": "^1.13.0",
55
56
  "get-image-colors": "^4.0.0"
56
57
  }
57
58
  }