node-red-contrib-huemagic 4.2.1 → 4.2.2

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
@@ -1,8 +1,14 @@
1
- [![Hue Magic Logo](https://gistcdn.githack.com/Foddy/062045775c28f5993ad646aba80e678c/raw/27e90d22bde68d9c92aed520c0c0c2cb8a22b7fd/huemagicv3x.svg)](https://flows.nodered.org/node/node-red-contrib-huemagic)
1
+ [![Hue Magic Logo](https://gist.githubusercontent.com/Foddy/9b647b910d03a31cee40f97c3988dd1c/raw/7ee635bd958ad04d7ba53c6c40ec401f879bffc2/huemagic-logo.svg)](https://flows.nodered.org/node/node-red-contrib-huemagic)
2
2
 
3
3
  # Changelog
4
4
 
5
- ### v4.2.1 (latest)
5
+ ### v4.2.2 (latest)
6
+
7
+ * HueMagic can now be installed again on older Node-RED versions without official support
8
+ * Fixed an issue for Hue Group nodes not getting/updating their current status ([#342](https://github.com/Foddy/node-red-contrib-huemagic/issues/342)) (thx @bmdevx)
9
+ * Fixed an error with non-functioning node configurations
10
+
11
+ ### v4.2.1
6
12
 
7
13
  * Commands are now re-executed up to three times if they fail due to a bridge timeout
8
14
  * The "image" option on the "Hue Light" node will now set the corresponding gradient colors on supported resources
package/README.md CHANGED
@@ -796,7 +796,13 @@ If the status of the node has changed via a certain command, the entire command
796
796
 
797
797
  # Changelog
798
798
 
799
- ### v4.2.1 (latest)
799
+ ### v4.2.2 (latest)
800
+
801
+ * HueMagic can now be installed again on older Node-RED versions without official support
802
+ * Fixed an issue for Hue Group nodes not getting/updating their current status ([#342](https://github.com/Foddy/node-red-contrib-huemagic/issues/342)) (thx @bmdevx)
803
+ * Fixed an error with non-functioning node configurations
804
+
805
+ ### v4.2.1
800
806
 
801
807
  * Commands are now re-executed up to three times if they fail due to a bridge timeout
802
808
  * The "image" option on the "Hue Light" node will now set the corresponding gradient colors on supported resources
@@ -879,7 +885,7 @@ If the status of the node has changed via a certain command, the entire command
879
885
  * Other optimizations, dependency updates and clean up
880
886
 
881
887
  ### Previous versions
882
- A complete overview of the updates can be viewed in the [changelog](https://github.com/Foddy/node-red-contrib-huemagic/blob/master/CHANGELOG.md)…
888
+ The full changelog [changelog](https://github.com/Foddy/node-red-contrib-huemagic/blob/master/CHANGELOG.md) can be viewed here
883
889
 
884
890
 
885
891
  ***
@@ -34,10 +34,10 @@ module.exports = function(RED)
34
34
  this.lastStates = {};
35
35
  this.events = new events.EventEmitter();
36
36
  this.patchQueue = null;
37
- this.timerWatchDog = null; // 31/01/2022 Supergiovane: watchdog for the connection with the bridge
37
+ this.timerWatchDog = null;
38
38
 
39
39
  // RESOURCE ID PATTERN
40
- this.validResourceID = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi;
40
+ this.validResourceID = /[a-zA-Z0-9]/gi;
41
41
 
42
42
  // FIRMWARE UPDATE TIMEOUT
43
43
  this.firmwareUpdateTimeout = null;
@@ -45,20 +45,21 @@ module.exports = function(RED)
45
45
  // CREATE NODE
46
46
  RED.nodes.createNode(scope, config);
47
47
 
48
- this.startWatchdog = function() {
49
- // 31/01/2022 Supergiovane: Check wether the bridge is connected.
50
- if (this.timerWatchDog !== null) clearTimeout(this.timerWatchDog);
51
- this.timerWatchDog = setTimeout(() => {
52
- try {
48
+ // PERIODICALLY CHECK WETHER BRIDGE IS CONNECTED
49
+ this.startWatchdog = function()
50
+ {
51
+ if (this.timerWatchDog !== null) clearTimeout(this.timerWatchDog);
52
+ this.timerWatchDog = setTimeout(function()
53
+ {
54
+ try
55
+ {
53
56
  API.request({ config: config, resource: "/config", version: 1 })
54
57
  .then(function(bridgeInformation)
55
58
  {
56
- // The bridge is still connected
57
59
  scope.startWatchdog();
58
60
  })
59
61
  .catch(function(error)
60
62
  {
61
- // Error connecting to the bridge
62
63
  scope.log("Error requesting info from the bridge. Reconnect in some secs. " + error.message);
63
64
  scope.start();
64
65
  });
@@ -66,14 +67,12 @@ module.exports = function(RED)
66
67
  scope.log("Lost connection with the bridge. Reconnect in some secs. " + error.message);
67
68
  scope.start();
68
69
  }
69
-
70
70
  }, 10000);
71
71
  }
72
+
72
73
  // INITIALIZE
73
74
  this.start = function()
74
75
  {
75
- this.startWatchdog(); // 31/01/2022 Supergiovane: starts the watchdog.
76
-
77
76
  scope.log("Initializing the bridge ("+config.bridge+")…");
78
77
  API.init({ config: config })
79
78
  .then(function(bridge) {
@@ -101,6 +100,9 @@ module.exports = function(RED)
101
100
 
102
101
  // START LOOKING FOR FIRMWARE-UPDATES
103
102
  scope.autoUpdateFirmware();
103
+
104
+ // START WATCHDOG
105
+ scope.startWatchdog();
104
106
  return true;
105
107
  })
106
108
  .catch(function(error)
@@ -52,8 +52,6 @@
52
52
  {
53
53
  position: relative;
54
54
  cursor: pointer;
55
-
56
- border-radius: 20px;
57
55
  overflow: hidden;
58
56
 
59
57
  border: 2px solid #fff;
@@ -252,15 +252,16 @@ function API()
252
252
  }
253
253
 
254
254
  // RESOURCE HAS GROUPED SERVICES?
255
- if(fullResource["grouped_services"])
255
+ if (fullResource["services"])
256
256
  {
257
- for (var g = fullResource["grouped_services"].length - 1; g >= 0; g--)
257
+ for (serviceType in fullResource["services"])
258
258
  {
259
- const groupedService = fullResource["grouped_services"][g];
260
- const groupedServiceID = groupedService["rid"];
261
-
262
- if(!processedResources["_groupsOf"][groupedServiceID]) { processedResources["_groupsOf"][groupedServiceID] = []; }
263
- processedResources["_groupsOf"][groupedServiceID].push(fullResource.id);
259
+ const grouped_services = fullResource['services'][serviceType];
260
+ for (groupedServiceID in grouped_services)
261
+ {
262
+ if (!processedResources["_groupsOf"][groupedServiceID]) { processedResources["_groupsOf"][groupedServiceID] = []; }
263
+ processedResources["_groupsOf"][groupedServiceID].push(fullResource.id);
264
+ }
264
265
  }
265
266
  }
266
267
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-huemagic",
3
- "version": "4.2.1",
3
+ "version": "4.2.2",
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,7 +27,6 @@
27
27
  "iot"
28
28
  ],
29
29
  "node-red": {
30
- "version": ">=2.1.0",
31
30
  "nodes": {
32
31
  "hue-bridge": "huemagic/hue-bridge-config.js",
33
32
  "hue-bridge-node": "huemagic/hue-bridge.js",