node-red-contrib-homebridge-automation 0.1.12-beta.40 → 0.1.12-beta.42

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.
@@ -7,7 +7,7 @@ class HbControlNode extends hbBaseNode {
7
7
  }
8
8
 
9
9
  async handleInput(message, send, done) {
10
- debug('handleInput', message.payload, this.name);
10
+ debug('handleInput', this.name, JSON.stringify(message.payload));
11
11
 
12
12
  if (!this.hbDevice) {
13
13
  this.handleWarning('HB not initialized');
@@ -4,12 +4,21 @@ const debug = require('debug')('hapNodeRed:hbResumeNode');
4
4
  class HbResumeNode extends HbBaseNode {
5
5
  constructor(config, RED) {
6
6
  super(config, RED);
7
-
7
+ this.lastOutputTime = Date.now();
8
8
  this.storedState = null;
9
9
  }
10
10
 
11
+ handleHBEventMessage(service) {
12
+ debug('hbEvent for', this.id, service.serviceName, JSON.stringify(service.values));
13
+
14
+ if (service.values && Date.now() - this.lastOutputTime > 1000) { // Ignore messages within 1 second of last output
15
+ this.storedState = JSON.parse(JSON.stringify(this.hbDevice.values));
16
+ debug('Storing state', this.name, JSON.stringify(this.storedState));
17
+ }
18
+ }
19
+
11
20
  handleInput(message, send) {
12
- debug('handleInput', message.payload, this.name);
21
+ debug('handleInput', this.id, message.payload, this.name);
13
22
 
14
23
  if (!this.hbDevice) {
15
24
  this.handleWarning('HB not initialized');
@@ -32,10 +41,10 @@ class HbResumeNode extends HbBaseNode {
32
41
 
33
42
  if (message.payload.On) {
34
43
  this.storedState = JSON.parse(JSON.stringify(this.hbDevice.values));
35
- debug('Storing state', this.storedState);
44
+ debug('Storing state', this.name, JSON.stringify(this.storedState));
36
45
  } else if (this.storedState) {
37
- debug('Restoring state', this.storedState);
38
- message.payload = { ...this.storedState, ...message.payload };
46
+ debug('Restoring state', this.name, JSON.stringify(this.storedState));
47
+ message.payload = { ...message.payload, ...this.storedState };
39
48
  this.storedState = null;
40
49
  }
41
50
 
@@ -45,6 +54,7 @@ class HbResumeNode extends HbBaseNode {
45
54
  fill: 'green',
46
55
  });
47
56
 
57
+ this.lastOutputTime = Date.now();;
48
58
  send(message);
49
59
  }
50
60
 
@@ -15,6 +15,9 @@
15
15
  "tours": {
16
16
  "welcome": "4.0.2"
17
17
  }
18
+ },
19
+ "debug": {
20
+ "filter": "filterCurrent"
18
21
  }
19
22
  }
20
23
  }
@@ -11,6 +11,9 @@
11
11
  "view-node-show-label": true,
12
12
  "view-show-tips": true,
13
13
  "view-show-welcome-tours": true
14
+ },
15
+ "tours": {
16
+ "welcome": "4.0.2"
14
17
  }
15
18
  }
16
19
  }