node-red-contrib-homebridge-automation 0.1.12-beta.17 → 0.1.12-beta.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-red-contrib-homebridge-automation",
3
- "version": "0.1.12-beta.17",
3
+ "version": "0.1.12-beta.18",
4
4
  "description": "NodeRED Automation for HomeBridge",
5
5
  "main": "src/HAP-NodeRed.js",
6
6
  "scripts": {
@@ -38,20 +38,6 @@ class HBConfigNode {
38
38
  });
39
39
  this.reqisterQueue.pause();
40
40
 
41
- this.initHomebridge(config);
42
- }
43
-
44
- // Initialize the Homebridge client
45
- initHomebridge(config) {
46
-
47
- //this.homebridge = new HAPNodeJSClient({
48
- // pin: config.username,
49
- // refresh: 900,
50
- // debug: false,
51
- // timeout: 5,
52
- // reqTimeout: 7000,
53
- // });
54
- debug('initHomebridge - hapClient', config);
55
41
  this.hapClient = new HapClient({
56
42
  config: { debug: false },
57
43
  pin: config.username,
@@ -59,9 +45,7 @@ class HBConfigNode {
59
45
  });
60
46
 
61
47
  this.waitForNoMoreDiscoveries();
62
- this.hapClient.on('instance-discovered', this.waitForNoMoreDiscoveries);
63
- // Handle 'Ready' event
64
- this.homebridge.on('Ready', this.handleReady.bind(this));
48
+ this.hapClient.on('instance-discovered', () => this.waitForNoMoreDiscoveries);
65
49
  }
66
50
 
67
51
  waitForNoMoreDiscoveries = () => {
@@ -74,15 +58,17 @@ class HBConfigNode {
74
58
  this.discoveryTimeout = setTimeout(() => {
75
59
  this.log.debug('No more instances discovered, publishing services');
76
60
  this.hapClient.removeListener('instance-discovered', this.waitForNoMoreDiscoveries);
77
- this.start();
78
- this.requestSync();
79
- this.hapClient.on('instance-discovered', this.requestSync.bind(this)); // Request sync on new instance discovery
61
+ debug('waitfornomore', this);
62
+ this.handleReady();
63
+ // this.requestSync();
64
+ // this.hapClient.on('instance-discovered', this.requestSync.bind(this)); // Request sync on new instance discovery
80
65
  }, 5000);
81
66
  };
82
67
 
83
68
  // Handle Homebridge 'Ready' event
84
69
  handleReady(accessories) {
85
- this.hbDevices = new Homebridges(accessories);
70
+ debug('handleReady', this);
71
+ this.hbDevices = this.hapClient.getAllServices(accessories);
86
72
  debug('Discovered %s new evDevices', this.hbDevices.toList({ perms: 'ev' }).length);
87
73
 
88
74
  this.evDevices = this.hbDevices.toList({ perms: 'ev' });