homebridge-alexa 0.5.50 → 0.5.57

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,6 +2,17 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/).
4
4
 
5
+ ## 0.5.54 (2021-01-03)
6
+
7
+ ## [Version 0.5.54](https://github.com/northernman54/homebridge-alexa/compare/v0.5.52...v0.5.54)
8
+
9
+ #### Changes
10
+
11
+ - Merge current beta into master
12
+ - Expose cloud connection keep alive tuning parameter #479
13
+ - Extend filtering to routines event registration - Resolve #458 #459 #461 #465
14
+ - Reduce amount of logging
15
+
5
16
  ## 0.5.37 (2021-06-15)
6
17
 
7
18
  ## [Version 0.5.37](https://github.com/northernman54/homebridge-alexa/compare/v0.5.33...v0.5.37)
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
  <img src="docs/homebridge.png" height="200">
7
7
  </p>
8
8
 
9
- Enable Amazon Alexa to control your homebridge smart home devices and accessories. Full support for all Amazon Alexa devices, including the echo 2nd Generation and software based solutions. Uses an Amazon smart home skill based approach for integration between HomeBridge and Amazon Alexa.
9
+ Enable Amazon Alexa to control your homebridge smart home devices and accessories. Please note, that this does **NOT** bring Alexa enabled devices into homebridge. Full support for all Amazon Alexa devices, including the echo 2nd Generation and software based solutions. Uses an Amazon smart home skill based approach for integration between HomeBridge and Amazon Alexa.
10
10
 
11
11
  Country availability - The plugin is available in these countries, English (AU), German (DE), English (CA), English (US), French (FR), English (UK), Italian (IT), English (IN), Spanish (ES), Japanese (JP), Spanish(US), Portuguese (BR) and Spanish (MX).
12
12
 
@@ -879,5 +879,3 @@ See [Roadmap](Roadmap.md)
879
879
  * jelvs - Validate TV Integration for homebridge-samsung-tizen
880
880
  * krocko - bose soundlink preset / channel change
881
881
  * pwilms - deviceList feature
882
-
883
-
@@ -61,8 +61,16 @@
61
61
  "keepalive": {
62
62
  "title": "Cloud Server Connection Keepalive",
63
63
  "type": "integer",
64
- "placeholder": "1200",
65
- "description": "Frequency of keepalive messages to cloud server, in seconds. Defaults to 20 minutes. Do not change from default unless requested as part of problem investigation."
64
+ "placeholder": "20",
65
+ "description": "Frequency of keepalive messages to cloud server, in minutes. Defaults to 20 minutes. Do not change from default unless requested as part of problem investigation.",
66
+ "minimum": 1,
67
+ "maximum": 59
68
+ },
69
+ "LegacyCloudTransport": {
70
+ "title": "Cloud Server Connection Transport",
71
+ "type": "boolean",
72
+ "default": false,
73
+ "description": "Enable Legacy Transport to Cloud Servers."
66
74
  },
67
75
  "filter": {
68
76
  "title": "Instance Filter",
@@ -71,14 +79,12 @@
71
79
  "description": "Limits accessories shared with Alexa to a single homebridge instance.",
72
80
  "pattern": "^[^{}/ :\\\\]+(?::\\d+)?$"
73
81
  },
74
-
75
82
  "deviceListHandling": {
76
83
  "title": "How to handle devices in the deviceList",
77
84
  "type": "string",
78
85
  "required": true,
79
86
  "default": "allow",
80
- "oneOf": [
81
- {
87
+ "oneOf": [{
82
88
  "title": "Allow devices",
83
89
  "enum": [
84
90
  "allow"
@@ -181,7 +187,8 @@
181
187
  "expandable": true,
182
188
  "expanded": false,
183
189
  "items": [
184
- "keepalive"
190
+ "keepalive",
191
+ "LegacyCloudTransport"
185
192
  ]
186
193
  },
187
194
  {
@@ -190,34 +197,29 @@
190
197
  "description": "Devices to configure as speakers as HomeKit currently does not have a Speaker service.",
191
198
  "expandable": true,
192
199
  "expanded": false,
193
- "items": [
194
- {
195
- "notitle": true,
196
- "key": "speakers",
197
- "type": "array",
198
- "items": [
200
+ "items": [{
201
+ "notitle": true,
202
+ "key": "speakers",
203
+ "type": "array",
204
+ "items": [{
205
+ "type": "div",
206
+ "displayFlex": true,
207
+ "flex-direction": "row",
208
+ "items": [{
209
+ "key": "speakers[].manufacturer",
210
+ "flex": "1 1 50px",
211
+ "notitle": true,
212
+ "placeholder": "Manufacturer"
213
+ },
199
214
  {
200
- "type": "div",
201
- "displayFlex": true,
202
- "flex-direction": "row",
203
- "items": [
204
- {
205
- "key": "speakers[].manufacturer",
206
- "flex": "1 1 50px",
207
- "notitle": true,
208
- "placeholder": "Manufacturer"
209
- },
210
- {
211
- "key": "speakers[].name",
212
- "flex": "4 4 200px",
213
- "notitle": true,
214
- "placeholder": "Name"
215
- }
216
- ]
215
+ "key": "speakers[].name",
216
+ "flex": "4 4 200px",
217
+ "notitle": true,
218
+ "placeholder": "Name"
217
219
  }
218
220
  ]
219
- }
220
- ]
221
+ }]
222
+ }]
221
223
  },
222
224
  {
223
225
  "type": "fieldset",
@@ -225,37 +227,30 @@
225
227
  "description": "Combine disparate accessories into one common device.",
226
228
  "expandable": true,
227
229
  "expanded": false,
228
- "items": [
229
- {
230
- "notitle": true,
231
- "key": "combine",
232
- "type": "array",
233
- "items": [
230
+ "items": [{
231
+ "notitle": true,
232
+ "key": "combine",
233
+ "type": "array",
234
+ "items": [{
235
+ "type": "div",
236
+ "items": [{
237
+ "key": "combine[].into",
238
+ "title": "Into",
239
+ "placeholder": "Target Accessory Name"
240
+ },
234
241
  {
235
- "type": "div",
236
- "items": [
237
- {
238
- "key": "combine[].into",
239
- "title": "Into",
240
- "placeholder": "Target Accessory Name"
241
- },
242
- {
243
- "key": "combine[].from",
244
- "notitle": true,
245
- "items": [
246
- {
247
- "title": "From",
248
- "key": "combine[].from[]",
242
+ "key": "combine[].from",
243
+ "notitle": true,
244
+ "items": [{
245
+ "title": "From",
246
+ "key": "combine[].from[]",
249
247
 
250
- "placeholder": "Source Accessory Name"
251
- }
252
- ]
253
- }
254
- ]
248
+ "placeholder": "Source Accessory Name"
249
+ }]
255
250
  }
256
251
  ]
257
- }
258
- ]
252
+ }]
253
+ }]
259
254
  }
260
255
  ]
261
256
  }
@@ -36,9 +36,7 @@ function hapDiscovery(options) {
36
36
  alexaDiscovery.call(options, null, function() {
37
37
  // debug("Events", options);
38
38
  if (options.events) {
39
-
40
- registerEvents(messages.checkEventDeviceList.call(this, hbDevices.toEvents()));
41
-
39
+ registerEvents.call(options, messages.checkEventDeviceList.call(options, hbDevices.toEvents()));
42
40
  }
43
41
  });
44
42
  });
@@ -51,12 +49,11 @@ function hapDiscovery(options) {
51
49
  }
52
50
 
53
51
  function registerEvents(message) {
54
- debug("registerEvents", message);
52
+ // debug("registerEvents", message);
55
53
 
56
54
  var HBMessage = [];
57
55
 
58
56
  for (var key in message) {
59
- // console.log("Key", key, JSON.parse(key));
60
57
  var endpoint = JSON.parse(key);
61
58
  var device = {
62
59
  "aid": endpoint.aid,
@@ -76,10 +73,12 @@ function registerEvents(message) {
76
73
  };
77
74
  }
78
75
  }
76
+
77
+ this.log("registerEvents - registered %s event sources", Object.keys(HBMessage).length);
79
78
  for (var register in HBMessage) {
80
79
  // console.log("send", instance, HBMessage[instance]);
81
80
  var hbInstance = JSON.parse(register);
82
- debug("Event Register %s ->", hbInstance.deviceID, HBMessage[register]);
81
+ // debug("Event Register %s ->", hbInstance.deviceID, HBMessage[register]);
83
82
  homebridge.HAPeventByDeviceID(hbInstance.deviceID, JSON.stringify(HBMessage[register]), function(err, status) {
84
83
  if (!err) {
85
84
  // debug("Registered Event %s:%s ->", hbInstance.host, hbInstance.port, status);
@@ -111,7 +110,7 @@ function alexaDiscovery(message, callback) {
111
110
  for (var i = 0; i < response.event.payload.endpoints.length; i++) {
112
111
  var endpoint = response.event.payload.endpoints[i];
113
112
  if (deleteSeen[endpoint.friendlyName]) {
114
- this.log("WARNING: Duplicate device name", endpoint.friendlyName);
113
+ this.log.warn("WARNING: Duplicate device name", endpoint.friendlyName);
115
114
  // response.event.payload.endpoints.splice(i, 1);
116
115
  } else {
117
116
  deleteSeen[endpoint.friendlyName] = true;
@@ -119,7 +118,7 @@ function alexaDiscovery(message, callback) {
119
118
  }
120
119
 
121
120
  if (response && response.event.payload.endpoints.length < 1) {
122
- this.log("ERROR: HAP Discovery failed, please review config");
121
+ this.log.error("ERROR: HAP Discovery failed, please review config");
123
122
  } else {
124
123
  if (process.uptime() > 600) { // Only use console during startup
125
124
  debug("alexaDiscovery - returned %s devices", response.event.payload.endpoints.length);
@@ -127,7 +126,7 @@ function alexaDiscovery(message, callback) {
127
126
  this.log("alexaDiscovery - returned %s devices", response.event.payload.endpoints.length);
128
127
  }
129
128
  if (response.event.payload.endpoints.length > 300) {
130
- this.log("ERROR: Maximum devices/accessories of 300 exceeded.");
129
+ this.log.error("ERROR: Maximum devices/accessories of 300 exceeded.");
131
130
  }
132
131
  }
133
132
  // debug("Discovery Response", JSON.stringify(response, null, 2));
@@ -144,7 +143,7 @@ function alexaDiscovery(message, callback) {
144
143
  function removeLargeCookieEndpoints(endpoints) {
145
144
  var response = [];
146
145
  endpoints.forEach((endpoint) => {
147
- debug("Cookie Object: ", JSON.stringify(endpoint.cookie).length);
146
+ // debug("Cookie Object: ", JSON.stringify(endpoint.cookie).length);
148
147
  if (JSON.stringify(endpoint.cookie).length < 5000) {
149
148
  response.push(endpoint);
150
149
  } else {
@@ -162,7 +161,7 @@ function removeDuplicateEndpoints(endpoints) {
162
161
  var response = [];
163
162
  endpoints.forEach((endpoint) => {
164
163
  if (deleteSeen[endpoint.endpointId]) {
165
- this.log("ERROR: Parsing failed, removing duplicate endpointID =>", endpoint.friendlyName);
164
+ this.log.error("ERROR: Parsing failed, removing duplicate endpointID =>", endpoint.friendlyName);
166
165
  } else {
167
166
  response.push(endpoint);
168
167
  }
package/lib/alexaLocal.js CHANGED
@@ -16,7 +16,6 @@ var checkAlexaMessage = Validator(alexaSchema, {
16
16
  verbose: true
17
17
  });
18
18
 
19
- var connection = {};
20
19
  var count = 0;
21
20
  var username;
22
21
  var limiter;
@@ -45,24 +44,25 @@ function alexaLocal(options) {
45
44
  }
46
45
 
47
46
  limiter.on("dropped", function(dropped) {
48
- options.log("WARNING: ( homebridge-alexa) Dropped event message, message rate too high.");
47
+ options.log.warn("WARNING: ( homebridge-alexa) Dropped event message, message rate too high.");
49
48
  });
50
49
 
51
- username = options.username;
52
- connection.client = mqtt.connect(options);
53
- // connection.client.setMaxListeners(0);
54
- connection.client.on('connect', function() {
55
- debug('connect', "command/" + options.username + "/#");
50
+ username = options.mqttOptions.username;
51
+ var connection = mqtt.connect(options.mqttURL, options.mqttOptions);
52
+ connection.on('connect', function() {
53
+ debug('connect', "command/" + username + "/#");
56
54
  if (options.alexaService) {
57
55
  options.alexaService.setCharacteristic(Characteristic.ContactSensorState, Characteristic.ContactSensorState.CONTACT_DETECTED);
58
56
  }
59
- connection.client.removeAllListeners('message'); // Clean up event handlers
60
- connection.client.subscribe("command/" + options.username + "/#");
61
- connection.client.publish("presence/" + options.username + "/1", JSON.stringify({
57
+ connection.subscribe("command/" + username + "/#");
58
+ connection.publish("presence/" + username + "/1", JSON.stringify({
62
59
  Connected: options.username,
63
60
  version: packageConfig.version
64
61
  }));
65
- connection.client.on('message', function(topic, message) {
62
+ });
63
+
64
+ connection.on('message', function(topic, message) {
65
+ try {
66
66
  var msg = JSON.parse(message.toString());
67
67
 
68
68
  // debug("Count", this.listenerCount(msg.directive.header.namespace.toLowerCase()));
@@ -74,55 +74,63 @@ function alexaLocal(options) {
74
74
  response = _alexaErrorResponse(msg);
75
75
  }
76
76
  // debug("Response", JSON.stringify(response));
77
- connection.client.publish("response/" + options.username + "/1", JSON.stringify(response));
77
+ connection.publish("response/" + username + "/1", JSON.stringify(response));
78
78
  });
79
79
  } else {
80
- debug('No listener for', msg.directive.header.namespace.toLowerCase());
80
+ debug('ERROR: No alexa action listener for', msg);
81
81
  var response = _alexaErrorResponse(msg);
82
- connection.client.publish("response/" + options.username + "/1", JSON.stringify(response));
83
- debug("Response", JSON.stringify(response, null, 2));
82
+ connection.publish("response/" + username + "/1", JSON.stringify(response));
83
+ // debug("Response", JSON.stringify(response, null, 2));
84
84
  }
85
- });
85
+ } catch (err) {
86
+ options.log.error("ERROR: MQTT Message on topic \"%s\" triggered an internal error\n", topic, err);
87
+ }
86
88
  });
87
89
 
88
- connection.client.on('offline', function() {
90
+ connection.on('offline', function() {
89
91
  debug('offline');
90
92
  if (options.alexaService) {
91
93
  options.alexaService.setCharacteristic(Characteristic.ContactSensorState, Characteristic.ContactSensorState.CONTACT_NOT_DETECTED);
92
94
  }
93
95
  });
94
96
 
95
- connection.client.on('reconnect', function() {
97
+ connection.on('reconnect', function() {
96
98
  count++;
97
99
  debug('reconnect');
98
100
  if (options.alexaService) {
99
101
  options.alexaService.setCharacteristic(Characteristic.ContactSensorState, Characteristic.ContactSensorState.CONTACT_NOT_DETECTED);
100
102
  }
101
- if (count % 5 === 0) options.log("ERROR: ( homebridge-alexa) You have an issue with your installation, please review the README.");
103
+ if (count % 5 === 0) options.log.error("ERROR: ( homebridge-alexa) You have an issue with your installation, please review the README.");
102
104
  if (count > 1000) {
103
- connection.client.end({
105
+ connection.end({
104
106
  force: true
105
107
  });
106
108
  if (options.alexaService) {
107
109
  options.alexaService.setCharacteristic(Characteristic.ContactSensorState, Characteristic.ContactSensorState.CONTACT_NOT_DETECTED);
108
110
  }
109
- options.log("ERROR: ( homebridge-alexa) Stopping Home Skill connection due to excessive reconnects, please review the README.");
111
+ options.log.error("ERROR: ( homebridge-alexa) Stopping Home Skill connection due to excessive reconnects, please review the README.");
110
112
  }
111
113
  });
112
114
 
113
- connection.client.on('error', function(err) {
115
+ connection.on('error', function(err) {
114
116
  if (options.alexaService) {
115
117
  options.alexaService.setCharacteristic(Characteristic.ContactSensorState, Characteristic.ContactSensorState.CONTACT_NOT_DETECTED);
116
118
  }
119
+ debug('ERROR: %s -> %s\n', err.message, err.code, err);
117
120
  switch (err.code) {
118
121
  case 5:
119
- options.log("ERROR: ( homebridge-alexa) Login to homebridge.ca failed, please validate your credentials in config.json and restart homebridge.");
120
- connection.client.end({
121
- force: true
122
- });
122
+ if (process.uptime() < 20) { // If uptime is less than 20 seconds then error is a bad password and not a backend issue
123
+ options.log.error("ERROR: ( homebridge-alexa) Login to homebridge.ca failed, please validate your credentials in config.json and restart homebridge.");
124
+ connection.end({
125
+ force: true
126
+ });
127
+ }
128
+ break;
129
+ case 'ECONNREFUSED':
130
+ options.log.error("ERROR: Cloud service DDOS Protection tripped, please stop homebridge for 5 to 10 minutes and try again.");
123
131
  break;
124
132
  default:
125
- debug('ERROR: %s -> ', err.message, err.code);
133
+ debug('ERROR: %s -> %d\n', err.message, err.code, err);
126
134
  }
127
135
  });
128
136
  }
@@ -139,7 +147,7 @@ function alexaEvent(message) {
139
147
  var topic = "event/" + username + "/1";
140
148
  var publish = function(callback) {
141
149
  debug("Sending message", JSON.stringify(message));
142
- connection.client.publish(topic, JSON.stringify(message), {
150
+ connection.publish(topic, JSON.stringify(message), {
143
151
  retain: false
144
152
  }, callback);
145
153
  };
@@ -151,16 +159,18 @@ function alexaPriorityEvent(message) {
151
159
  var topic = "event/" + username + "/1";
152
160
  var publish = function(callback) {
153
161
  debug("Sending priority message", JSON.stringify(message));
154
- connection.client.publish(topic, JSON.stringify(message), {
162
+ connection.publish(topic, JSON.stringify(message), {
155
163
  retain: false
156
164
  }, callback);
157
165
  };
158
- limiter.submit({ priority: 4 }, publish);
166
+ limiter.submit({
167
+ priority: 4
168
+ }, publish);
159
169
 
160
170
  /*
161
171
  var topic = "event/" + username + "/1";
162
172
  debug("Sending priority message", JSON.stringify(message));
163
- connection.client.publish(topic, JSON.stringify(message));
173
+ connection.publish(topic, JSON.stringify(message));
164
174
  */
165
175
  }
166
176
 
@@ -116,6 +116,8 @@ Accessory.prototype.toAlexa = function(context) {
116
116
  var service = this.services[index];
117
117
  if ((this.television && service.service === "Speaker") || service.service === "Television" || service.service === "Input Source") {
118
118
  // Skip television accessories
119
+ } else if (service.name === "Alexa" && service.service === "Contact Sensor" && service.info.Manufacturer === "homebridge-alexa") {
120
+ // Skip the Alexa contact sensors made by the plugin
119
121
  } else {
120
122
  var alexa = service.toAlexa(context);
121
123
  if (alexa) {
@@ -91,12 +91,16 @@ Homebridges.prototype.toEvents = function(endpoint) {
91
91
  for (var index in accessory.services) {
92
92
  var service = accessory.services[index];
93
93
  // debug("characteristics", service.characteristics.length);
94
- for (var index in service.characteristics) {
95
- var hapEvents = service.characteristics[index].hapEvents;
96
- if (Object.keys(hapEvents).length > 0) {
97
- list = Object.assign(list, hapEvents);
98
- // debug("hapEvents", hapEvents, Object.keys(hapEvents).length);
99
- // debug("List", list);
94
+ if (service.name === "Alexa" && service.service === "Contact Sensor" && service.info.Manufacturer === "homebridge-alexa") {
95
+ // Skip the Alexa contact sensors made by the plugin
96
+ } else {
97
+ for (var index in service.characteristics) {
98
+ var hapEvents = service.characteristics[index].hapEvents;
99
+ if (Object.keys(hapEvents).length > 0) {
100
+ list = Object.assign(list, hapEvents);
101
+ // debug("hapEvents", hapEvents, Object.keys(hapEvents).length);
102
+ // debug("List", list);
103
+ }
100
104
  }
101
105
  }
102
106
  }
@@ -1421,12 +1421,11 @@ function checkEventDeviceList(endpoints) {
1421
1421
  if (this.deviceList && this.deviceList.length > 0 && ['allow', 'deny'].includes(this.deviceListHandling)) {
1422
1422
  debug(`INFO: DeviceList - The following devices are ${this.deviceListHandling} =>`, this.deviceList);
1423
1423
  var response = [];
1424
- // endpoints.forEach((endpoint) => {
1425
1424
  for (var key in endpoints) {
1426
1425
  var endpoint = endpoints[key];
1427
1426
  if (this.deviceListHandling === "allow") {
1428
1427
  if (verifyDeviceInList(this.deviceList, endpoint.friendlyName)) {
1429
- response.push(endpoint);
1428
+ response[key] = endpoint;
1430
1429
  debug("INFO: DeviceList - allow =>", endpoint.friendlyName);
1431
1430
  }
1432
1431
  } else if (this.deviceListHandling === "deny") {
@@ -1439,7 +1438,7 @@ function checkEventDeviceList(endpoints) {
1439
1438
  }
1440
1439
  return (response);
1441
1440
  } else {
1442
- // this.log("INFO: DeviceList empty feature not enabled or config error in deviceListHandling");
1441
+ debug("INFO: DeviceList empty feature not enabled or config error in deviceListHandling");
1443
1442
  return endpoints;
1444
1443
  }
1445
1444
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-alexa",
3
- "version": "0.5.50",
3
+ "version": "0.5.57",
4
4
  "description": "Control your Homebridge devices with Amazon Alexa.",
5
5
  "main": "plugin.js",
6
6
  "scripts": {
@@ -32,16 +32,16 @@
32
32
  "homebridge": ">=0.4.16"
33
33
  },
34
34
  "devDependencies": {
35
- "documentation": "^13.0.2",
35
+ "@oznu/hap-client": "^1.8.1",
36
+ "documentation": "^13.2.5",
36
37
  "nodemon": "^2.0.4"
37
38
  },
38
39
  "dependencies": {
39
- "@oznu/hap-client": "^1.7.2",
40
- "bottleneck": ">=2.18.0",
41
- "debug": ">2.6.9",
40
+ "bottleneck": ">=2.19.5",
41
+ "debug": ">=4.3.3",
42
42
  "hap-node-client": ">=0.1.16",
43
- "is-my-json-valid": ">=2.19.0",
44
- "mqtt": ">=2.18.8"
43
+ "is-my-json-valid": ">=2.20.6",
44
+ "mqtt": "^4.3.4"
45
45
  },
46
46
  "author": "NorthernMan54",
47
47
  "license": "Apache-2.0",
package/plugin.js CHANGED
@@ -40,7 +40,14 @@ function alexaHome(log, config, api) {
40
40
  this.deviceList = config['deviceList'] || []; // Use ea
41
41
  this.door = config['door'] || false; // Use mode controller for Garage Doors
42
42
  this.name = config['name'] || "homebridgeAlexa";
43
- this.keepalive = config['keepalive'] || 1200; // MQTT Connection Keepalive
43
+ this.LegacyCloudTransport = config['LegacyCloudTransport'] || false; // Default to new Transport
44
+ var mqttKeepalive = config['keepalive'] || 20; // MQTT Connection Keepalive
45
+
46
+ if (mqttKeepalive < 60) {
47
+ this.keepalive = mqttKeepalive * 60;
48
+ } else {
49
+ this.keepalive = mqttKeepalive;
50
+ }
44
51
 
45
52
  // Enable config based DEBUG logging enable
46
53
  this.debug = config['debug'] || false;
@@ -87,24 +94,25 @@ alexaHome.prototype = {
87
94
  };
88
95
 
89
96
  alexaHome.prototype.didFinishLaunching = function() {
90
- var host = 'alexa.homebridge.ca';
97
+ var host = (this.LegacyCloudTransport ? 'alexa.homebridge.ca' : 'www.homebridge.ca');
98
+ var reconnectPeriod = 65000; // Increased reconnect period to allow DDOS protection to reset
91
99
  if (this.beta) {
92
- host = 'alexabeta.homebridge.ca';
100
+ host = 'clone.homebridge.ca';
101
+ // reconnectPeriod = 10000;
93
102
  }
103
+
94
104
  options = {
95
105
  // Shared Options
96
106
  log: this.log,
97
107
  debug: this.debug,
98
- // MQTT Options
99
- username: this.username,
100
- password: this.password,
101
- servers: [{
102
- protocol: 'mqtt',
103
- host: host,
104
- port: 1883
105
- }],
106
- reconnectPeriod: 65000,
107
- keepalive: this.keepalive, // Reduce client timeout to 10 minutes
108
+ mqttURL: (this.LegacyCloudTransport ? "mqtt://" + host + ":1883/" : "wss://" + host + "/ws"),
109
+ mqttOptions: {
110
+ username: this.username,
111
+ password: this.password,
112
+ reconnectPeriod: reconnectPeriod, // Increased reconnect period to allow DDOS protection to reset
113
+ keepalive: (this.LegacyCloudTransport ? this.keepalive : 55), // Keep alive not required when using WSS Transport
114
+ rejectUnauthorized: false
115
+ },
108
116
  // HAP Node Client options
109
117
  pin: this.pin,
110
118
  refresh: this.refresh,
@@ -138,7 +146,13 @@ alexaHome.prototype.didFinishLaunching = function() {
138
146
  // Alexa mesages
139
147
 
140
148
  this.eventBus.on('System', function(message) {
141
- this.log.error("ERROR: ", message.directive.header.message);
149
+ this.log.error("ERROR:", message.directive.header.message);
150
+ }.bind(this));
151
+ this.eventBus.on('Warning', function(message) {
152
+ this.log.warn("Warning:", message.directive.header.message);
153
+ }.bind(this));
154
+ this.eventBus.on('Information', function(message) {
155
+ this.log("Info:", message.directive.header.message);
142
156
  }.bind(this));
143
157
  this.eventBus.on('Alexa', alexaActions.alexaMessage.bind(this));
144
158
  this.eventBus.on('Alexa.Discovery', alexaActions.alexaDiscovery.bind(this));