node-red-contrib-huemagic 5.1.0 → 5.1.1

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
@@ -2,7 +2,12 @@
2
2
 
3
3
  # Changelog
4
4
 
5
- ### v5.1.0 (latest)
5
+ ### v5.1.1 (latest)
6
+
7
+ * Pressing a button on a Hue Tap Dial Switch no longer also reports the last rotation of its dial under `msg.payload.rotation`, and turning the dial no longer reports the last pressed button ([#456](https://github.com/Foddy/node-red-contrib-huemagic/pull/456)) (thx @FredBlo)
8
+ * A battery or connection update of a switch, dial or doorbell no longer repeats its last press or rotation as if it had just happened ([#456](https://github.com/Foddy/node-red-contrib-huemagic/pull/456)) (thx @FredBlo)
9
+
10
+ ### v5.1.0
6
11
 
7
12
  **New devices and features**
8
13
 
package/README.md CHANGED
@@ -1218,7 +1218,12 @@ If the status of the node has changed via a certain command, the entire command
1218
1218
 
1219
1219
  # Changelog
1220
1220
 
1221
- ### v5.1.0 (latest)
1221
+ ### v5.1.1 (latest)
1222
+
1223
+ * Pressing a button on a Hue Tap Dial Switch no longer also reports the last rotation of its dial under `msg.payload.rotation`, and turning the dial no longer reports the last pressed button ([#456](https://github.com/Foddy/node-red-contrib-huemagic/pull/456)) (thx @FredBlo)
1224
+ * A battery or connection update of a switch, dial or doorbell no longer repeats its last press or rotation as if it had just happened ([#456](https://github.com/Foddy/node-red-contrib-huemagic/pull/456)) (thx @FredBlo)
1225
+
1226
+ ### v5.1.0
1222
1227
 
1223
1228
  **New devices and features**
1224
1229
 
@@ -75,7 +75,8 @@ module.exports = function(RED)
75
75
  // SUBSCRIBE TO UPDATES FROM THE BRIDGE
76
76
  this.unsubscribe = bridge.subscribe("button", config.sensorid, function(info)
77
77
  {
78
- let currentState = bridge.get("button", info.id);
78
+ // ONLY REPORT THE SERVICE THAT FIRED THIS EVENT, NOT THE LAST PRESS OR ROTATION STILL CACHED
79
+ let currentState = bridge.get("button", info.id, { updatedType: info.updatedType });
79
80
 
80
81
  // RESOURCE FOUND?
81
82
  if(currentState !== false)
@@ -216,13 +217,15 @@ module.exports = function(RED)
216
217
  {
217
218
  scope.status({fill: "grey", shape: "dot", text: "hue-buttons.node.waiting"});
218
219
 
219
- // REMOVE OLD BUTTON STATES
220
- const buttons = (bridge.resources[config.sensorid] && bridge.resources[config.sensorid]["services"]) ? bridge.resources[config.sensorid]["services"]["button"] : false;
221
- if(!buttons) { return false; }
220
+ // REMOVE OLD BUTTON AND DIAL STATES
221
+ const services = (bridge.resources[config.sensorid] && bridge.resources[config.sensorid]["services"]) ? bridge.resources[config.sensorid]["services"] : {};
222
222
 
223
- for (const [oneButtonID, oneButton] of Object.entries(buttons))
223
+ for (const oneType of ["button", "relative_rotary"])
224
224
  {
225
- delete buttons[oneButtonID]["button"];
225
+ for (const oneService of Object.values(services[oneType] || {}))
226
+ {
227
+ delete oneService[oneType];
228
+ }
226
229
  }
227
230
  }, 3000);
228
231
  }
@@ -674,13 +674,16 @@ class HueButtonsMessage
674
674
  const connection = connectivity(resource);
675
675
  const power = battery(resource);
676
676
 
677
+ // A LIVE EVENT ONLY REPORTS THE SERVICE THAT FIRED IT, A STATUS QUERY EVERYTHING STILL CACHED
678
+ const fired = function(type) { return (!options.updatedType || options.updatedType === type); };
679
+
677
680
  // FIND PRESSED BUTTON (A DOORBELL BEHAVES EXACTLY LIKE ONE)
678
681
  var pressedButton = false;
679
682
  var isDoorbell = false;
680
683
 
681
684
  for (const oneType of ["button", "bell_button"])
682
685
  {
683
- const allButtons = resource.services[oneType] ? Object.values(resource.services[oneType]) : [];
686
+ const allButtons = (fired(oneType) && resource.services[oneType]) ? Object.values(resource.services[oneType]) : [];
684
687
 
685
688
  for (var i = allButtons.length - 1; i >= 0; i--)
686
689
  {
@@ -697,7 +700,7 @@ class HueButtonsMessage
697
700
 
698
701
  // FIND ROTATION (HUE TAP DIAL, LUTRON AURORA)
699
702
  var rotaryDial = false;
700
- const allRotaries = resource.services.relative_rotary ? Object.values(resource.services.relative_rotary) : [];
703
+ const allRotaries = (fired("relative_rotary") && resource.services.relative_rotary) ? Object.values(resource.services.relative_rotary) : [];
701
704
 
702
705
  for (var r = allRotaries.length - 1; r >= 0; r--)
703
706
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-huemagic",
3
- "version": "5.1.0",
3
+ "version": "5.1.1",
4
4
  "description": "Philips Hue nodes to control bridges, lights, groups, scenes, rules, automations, buttons, switches, dials, doorbells, speakers, motion sensors, cameras, contact sensors, temperature sensors, light level sensors and the Hue Play HDMI Sync Box using Node-RED.",
5
5
  "author": "foddy",
6
6
  "homepage": "https://github.com/Foddy/node-red-contrib-huemagic",