homebridge-alexa 0.5.55 → 0.5.60-beta.0
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 +10 -0
- package/config.schema.json +49 -56
- package/lib/alexaActions.js +10 -8
- package/lib/alexaLocal.js +45 -32
- package/lib/parse/Accessory.js +2 -0
- package/lib/parse/Homebridges.js +10 -6
- package/package.json +2 -2
- package/plugin.js +27 -19
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
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.60 (2021-01-17)
|
|
6
|
+
|
|
7
|
+
## [Version 0.5.54](https://github.com/northernman54/homebridge-alexa/compare/v0.5.55...v0.5.60)
|
|
8
|
+
|
|
9
|
+
#### Changes
|
|
10
|
+
|
|
11
|
+
- Enable the usage of websockets instead of mqtt, to provide improved connectivity in some setups
|
|
12
|
+
- New configuration option `LegacyCloudTransport` which enables the mqtt transport
|
|
13
|
+
- Removed the Alexa contact sensor ( which shows the status of the connection to the cloud servers ) from the list of devices passed to Alexa.
|
|
14
|
+
|
|
5
15
|
## 0.5.54 (2021-01-03)
|
|
6
16
|
|
|
7
17
|
## [Version 0.5.54](https://github.com/northernman54/homebridge-alexa/compare/v0.5.52...v0.5.54)
|
package/config.schema.json
CHANGED
|
@@ -66,6 +66,12 @@
|
|
|
66
66
|
"minimum": 1,
|
|
67
67
|
"maximum": 59
|
|
68
68
|
},
|
|
69
|
+
"LegacyCloudTransport": {
|
|
70
|
+
"title": "Legacy Cloud Server Connection",
|
|
71
|
+
"type": "boolean",
|
|
72
|
+
"default": false,
|
|
73
|
+
"description": "Enable Legacy Transport ( mqtt ) to Cloud Servers ( This is from version 0.5.55 or older )."
|
|
74
|
+
},
|
|
69
75
|
"filter": {
|
|
70
76
|
"title": "Instance Filter",
|
|
71
77
|
"type": "string",
|
|
@@ -73,14 +79,12 @@
|
|
|
73
79
|
"description": "Limits accessories shared with Alexa to a single homebridge instance.",
|
|
74
80
|
"pattern": "^[^{}/ :\\\\]+(?::\\d+)?$"
|
|
75
81
|
},
|
|
76
|
-
|
|
77
82
|
"deviceListHandling": {
|
|
78
83
|
"title": "How to handle devices in the deviceList",
|
|
79
84
|
"type": "string",
|
|
80
85
|
"required": true,
|
|
81
86
|
"default": "allow",
|
|
82
|
-
"oneOf": [
|
|
83
|
-
{
|
|
87
|
+
"oneOf": [{
|
|
84
88
|
"title": "Allow devices",
|
|
85
89
|
"enum": [
|
|
86
90
|
"allow"
|
|
@@ -183,7 +187,8 @@
|
|
|
183
187
|
"expandable": true,
|
|
184
188
|
"expanded": false,
|
|
185
189
|
"items": [
|
|
186
|
-
"keepalive"
|
|
190
|
+
"keepalive",
|
|
191
|
+
"LegacyCloudTransport"
|
|
187
192
|
]
|
|
188
193
|
},
|
|
189
194
|
{
|
|
@@ -192,34 +197,29 @@
|
|
|
192
197
|
"description": "Devices to configure as speakers as HomeKit currently does not have a Speaker service.",
|
|
193
198
|
"expandable": true,
|
|
194
199
|
"expanded": false,
|
|
195
|
-
"items": [
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
"
|
|
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
|
+
},
|
|
201
214
|
{
|
|
202
|
-
"
|
|
203
|
-
"
|
|
204
|
-
"
|
|
205
|
-
"
|
|
206
|
-
{
|
|
207
|
-
"key": "speakers[].manufacturer",
|
|
208
|
-
"flex": "1 1 50px",
|
|
209
|
-
"notitle": true,
|
|
210
|
-
"placeholder": "Manufacturer"
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
"key": "speakers[].name",
|
|
214
|
-
"flex": "4 4 200px",
|
|
215
|
-
"notitle": true,
|
|
216
|
-
"placeholder": "Name"
|
|
217
|
-
}
|
|
218
|
-
]
|
|
215
|
+
"key": "speakers[].name",
|
|
216
|
+
"flex": "4 4 200px",
|
|
217
|
+
"notitle": true,
|
|
218
|
+
"placeholder": "Name"
|
|
219
219
|
}
|
|
220
220
|
]
|
|
221
|
-
}
|
|
222
|
-
]
|
|
221
|
+
}]
|
|
222
|
+
}]
|
|
223
223
|
},
|
|
224
224
|
{
|
|
225
225
|
"type": "fieldset",
|
|
@@ -227,37 +227,30 @@
|
|
|
227
227
|
"description": "Combine disparate accessories into one common device.",
|
|
228
228
|
"expandable": true,
|
|
229
229
|
"expanded": false,
|
|
230
|
-
"items": [
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
"
|
|
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
|
+
},
|
|
236
241
|
{
|
|
237
|
-
"
|
|
238
|
-
"
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
"placeholder": "Target Accessory Name"
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
"key": "combine[].from",
|
|
246
|
-
"notitle": true,
|
|
247
|
-
"items": [
|
|
248
|
-
{
|
|
249
|
-
"title": "From",
|
|
250
|
-
"key": "combine[].from[]",
|
|
242
|
+
"key": "combine[].from",
|
|
243
|
+
"notitle": true,
|
|
244
|
+
"items": [{
|
|
245
|
+
"title": "From",
|
|
246
|
+
"key": "combine[].from[]",
|
|
251
247
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
]
|
|
255
|
-
}
|
|
256
|
-
]
|
|
248
|
+
"placeholder": "Source Accessory Name"
|
|
249
|
+
}]
|
|
257
250
|
}
|
|
258
251
|
]
|
|
259
|
-
}
|
|
260
|
-
]
|
|
252
|
+
}]
|
|
253
|
+
}]
|
|
261
254
|
}
|
|
262
255
|
]
|
|
263
256
|
}
|
package/lib/alexaActions.js
CHANGED
|
@@ -36,7 +36,7 @@ function hapDiscovery(options) {
|
|
|
36
36
|
alexaDiscovery.call(options, null, function() {
|
|
37
37
|
// debug("Events", options);
|
|
38
38
|
if (options.events) {
|
|
39
|
-
registerEvents(messages.checkEventDeviceList.call(options, hbDevices.toEvents()));
|
|
39
|
+
registerEvents.call(options, messages.checkEventDeviceList.call(options, hbDevices.toEvents()));
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
42
|
});
|
|
@@ -49,7 +49,7 @@ function hapDiscovery(options) {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function registerEvents(message) {
|
|
52
|
-
debug("registerEvents", message);
|
|
52
|
+
// debug("registerEvents", message);
|
|
53
53
|
|
|
54
54
|
var HBMessage = [];
|
|
55
55
|
|
|
@@ -73,10 +73,12 @@ function registerEvents(message) {
|
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
this.log("registerEvents - registered %s event sources", Object.keys(HBMessage).length);
|
|
76
78
|
for (var register in HBMessage) {
|
|
77
79
|
// console.log("send", instance, HBMessage[instance]);
|
|
78
80
|
var hbInstance = JSON.parse(register);
|
|
79
|
-
debug("Event Register %s ->", hbInstance.deviceID, HBMessage[register]);
|
|
81
|
+
// debug("Event Register %s ->", hbInstance.deviceID, HBMessage[register]);
|
|
80
82
|
homebridge.HAPeventByDeviceID(hbInstance.deviceID, JSON.stringify(HBMessage[register]), function(err, status) {
|
|
81
83
|
if (!err) {
|
|
82
84
|
// debug("Registered Event %s:%s ->", hbInstance.host, hbInstance.port, status);
|
|
@@ -108,7 +110,7 @@ function alexaDiscovery(message, callback) {
|
|
|
108
110
|
for (var i = 0; i < response.event.payload.endpoints.length; i++) {
|
|
109
111
|
var endpoint = response.event.payload.endpoints[i];
|
|
110
112
|
if (deleteSeen[endpoint.friendlyName]) {
|
|
111
|
-
this.log("WARNING: Duplicate device name", endpoint.friendlyName);
|
|
113
|
+
this.log.warn("WARNING: Duplicate device name", endpoint.friendlyName);
|
|
112
114
|
// response.event.payload.endpoints.splice(i, 1);
|
|
113
115
|
} else {
|
|
114
116
|
deleteSeen[endpoint.friendlyName] = true;
|
|
@@ -116,7 +118,7 @@ function alexaDiscovery(message, callback) {
|
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
if (response && response.event.payload.endpoints.length < 1) {
|
|
119
|
-
this.log("ERROR: HAP Discovery failed, please review config");
|
|
121
|
+
this.log.error("ERROR: HAP Discovery failed, please review config");
|
|
120
122
|
} else {
|
|
121
123
|
if (process.uptime() > 600) { // Only use console during startup
|
|
122
124
|
debug("alexaDiscovery - returned %s devices", response.event.payload.endpoints.length);
|
|
@@ -124,7 +126,7 @@ function alexaDiscovery(message, callback) {
|
|
|
124
126
|
this.log("alexaDiscovery - returned %s devices", response.event.payload.endpoints.length);
|
|
125
127
|
}
|
|
126
128
|
if (response.event.payload.endpoints.length > 300) {
|
|
127
|
-
this.log("ERROR: Maximum devices/accessories of 300 exceeded.");
|
|
129
|
+
this.log.error("ERROR: Maximum devices/accessories of 300 exceeded.");
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
// debug("Discovery Response", JSON.stringify(response, null, 2));
|
|
@@ -141,7 +143,7 @@ function alexaDiscovery(message, callback) {
|
|
|
141
143
|
function removeLargeCookieEndpoints(endpoints) {
|
|
142
144
|
var response = [];
|
|
143
145
|
endpoints.forEach((endpoint) => {
|
|
144
|
-
debug("Cookie Object: ", JSON.stringify(endpoint.cookie).length);
|
|
146
|
+
// debug("Cookie Object: ", JSON.stringify(endpoint.cookie).length);
|
|
145
147
|
if (JSON.stringify(endpoint.cookie).length < 5000) {
|
|
146
148
|
response.push(endpoint);
|
|
147
149
|
} else {
|
|
@@ -159,7 +161,7 @@ function removeDuplicateEndpoints(endpoints) {
|
|
|
159
161
|
var response = [];
|
|
160
162
|
endpoints.forEach((endpoint) => {
|
|
161
163
|
if (deleteSeen[endpoint.endpointId]) {
|
|
162
|
-
this.log("ERROR: Parsing failed, removing duplicate endpointID =>", endpoint.friendlyName);
|
|
164
|
+
this.log.error("ERROR: Parsing failed, removing duplicate endpointID =>", endpoint.friendlyName);
|
|
163
165
|
} else {
|
|
164
166
|
response.push(endpoint);
|
|
165
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,28 @@ 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
|
|
53
|
-
|
|
54
|
-
|
|
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.
|
|
60
|
-
connection.
|
|
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
|
-
version: packageConfig.version
|
|
60
|
+
version: packageConfig.version,
|
|
61
|
+
transport: options.transport,
|
|
62
|
+
keepalive: options.mqttOptions.keepalive,
|
|
63
|
+
routines: options.events
|
|
64
64
|
}));
|
|
65
|
-
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
connection.on('message', function(topic, message) {
|
|
68
|
+
try {
|
|
66
69
|
var msg = JSON.parse(message.toString());
|
|
67
70
|
|
|
68
71
|
// debug("Count", this.listenerCount(msg.directive.header.namespace.toLowerCase()));
|
|
@@ -74,55 +77,63 @@ function alexaLocal(options) {
|
|
|
74
77
|
response = _alexaErrorResponse(msg);
|
|
75
78
|
}
|
|
76
79
|
// debug("Response", JSON.stringify(response));
|
|
77
|
-
connection.
|
|
80
|
+
connection.publish("response/" + username + "/1", JSON.stringify(response));
|
|
78
81
|
});
|
|
79
82
|
} else {
|
|
80
|
-
debug('No listener for', msg
|
|
83
|
+
debug('ERROR: No alexa action listener for', msg);
|
|
81
84
|
var response = _alexaErrorResponse(msg);
|
|
82
|
-
connection.
|
|
83
|
-
debug("Response", JSON.stringify(response, null, 2));
|
|
85
|
+
connection.publish("response/" + username + "/1", JSON.stringify(response));
|
|
86
|
+
// debug("Response", JSON.stringify(response, null, 2));
|
|
84
87
|
}
|
|
85
|
-
})
|
|
88
|
+
} catch (err) {
|
|
89
|
+
options.log.error("ERROR: MQTT Message on topic \"%s\" triggered an internal error\n", topic, err);
|
|
90
|
+
}
|
|
86
91
|
});
|
|
87
92
|
|
|
88
|
-
connection.
|
|
93
|
+
connection.on('offline', function() {
|
|
89
94
|
debug('offline');
|
|
90
95
|
if (options.alexaService) {
|
|
91
96
|
options.alexaService.setCharacteristic(Characteristic.ContactSensorState, Characteristic.ContactSensorState.CONTACT_NOT_DETECTED);
|
|
92
97
|
}
|
|
93
98
|
});
|
|
94
99
|
|
|
95
|
-
connection.
|
|
100
|
+
connection.on('reconnect', function() {
|
|
96
101
|
count++;
|
|
97
102
|
debug('reconnect');
|
|
98
103
|
if (options.alexaService) {
|
|
99
104
|
options.alexaService.setCharacteristic(Characteristic.ContactSensorState, Characteristic.ContactSensorState.CONTACT_NOT_DETECTED);
|
|
100
105
|
}
|
|
101
|
-
if (count % 5 === 0) options.log("ERROR: ( homebridge-alexa) You have an issue with your installation, please review the README.");
|
|
106
|
+
if (count % 5 === 0) options.log.error("ERROR: ( homebridge-alexa) You have an issue with your installation, please review the README.");
|
|
102
107
|
if (count > 1000) {
|
|
103
|
-
connection.
|
|
108
|
+
connection.end({
|
|
104
109
|
force: true
|
|
105
110
|
});
|
|
106
111
|
if (options.alexaService) {
|
|
107
112
|
options.alexaService.setCharacteristic(Characteristic.ContactSensorState, Characteristic.ContactSensorState.CONTACT_NOT_DETECTED);
|
|
108
113
|
}
|
|
109
|
-
options.log("ERROR: ( homebridge-alexa) Stopping Home Skill connection due to excessive reconnects, please review the README.");
|
|
114
|
+
options.log.error("ERROR: ( homebridge-alexa) Stopping Home Skill connection due to excessive reconnects, please review the README.");
|
|
110
115
|
}
|
|
111
116
|
});
|
|
112
117
|
|
|
113
|
-
connection.
|
|
118
|
+
connection.on('error', function(err) {
|
|
114
119
|
if (options.alexaService) {
|
|
115
120
|
options.alexaService.setCharacteristic(Characteristic.ContactSensorState, Characteristic.ContactSensorState.CONTACT_NOT_DETECTED);
|
|
116
121
|
}
|
|
122
|
+
debug('ERROR: %s -> %s\n', err.message, err.code, err);
|
|
117
123
|
switch (err.code) {
|
|
118
124
|
case 5:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
if (process.uptime() < 20) { // If uptime is less than 20 seconds then error is a bad password and not a backend issue
|
|
126
|
+
options.log.error("ERROR: ( homebridge-alexa) Login to homebridge.ca failed, please validate your credentials in config.json and restart homebridge.");
|
|
127
|
+
connection.end({
|
|
128
|
+
force: true
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
132
|
+
case 'ECONNREFUSED':
|
|
133
|
+
options.log.error("ERROR: Cloud service DDOS Protection tripped, please stop homebridge for 5 to 10 minutes and try again.");
|
|
123
134
|
break;
|
|
124
135
|
default:
|
|
125
|
-
debug('ERROR: %s -> ', err.message, err.code);
|
|
136
|
+
debug('ERROR: %s -> %d\n', err.message, err.code, err);
|
|
126
137
|
}
|
|
127
138
|
});
|
|
128
139
|
}
|
|
@@ -139,7 +150,7 @@ function alexaEvent(message) {
|
|
|
139
150
|
var topic = "event/" + username + "/1";
|
|
140
151
|
var publish = function(callback) {
|
|
141
152
|
debug("Sending message", JSON.stringify(message));
|
|
142
|
-
connection.
|
|
153
|
+
connection.publish(topic, JSON.stringify(message), {
|
|
143
154
|
retain: false
|
|
144
155
|
}, callback);
|
|
145
156
|
};
|
|
@@ -151,16 +162,18 @@ function alexaPriorityEvent(message) {
|
|
|
151
162
|
var topic = "event/" + username + "/1";
|
|
152
163
|
var publish = function(callback) {
|
|
153
164
|
debug("Sending priority message", JSON.stringify(message));
|
|
154
|
-
connection.
|
|
165
|
+
connection.publish(topic, JSON.stringify(message), {
|
|
155
166
|
retain: false
|
|
156
167
|
}, callback);
|
|
157
168
|
};
|
|
158
|
-
limiter.submit({
|
|
169
|
+
limiter.submit({
|
|
170
|
+
priority: 4
|
|
171
|
+
}, publish);
|
|
159
172
|
|
|
160
173
|
/*
|
|
161
174
|
var topic = "event/" + username + "/1";
|
|
162
175
|
debug("Sending priority message", JSON.stringify(message));
|
|
163
|
-
connection.
|
|
176
|
+
connection.publish(topic, JSON.stringify(message));
|
|
164
177
|
*/
|
|
165
178
|
}
|
|
166
179
|
|
package/lib/parse/Accessory.js
CHANGED
|
@@ -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) {
|
package/lib/parse/Homebridges.js
CHANGED
|
@@ -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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-alexa",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.60-beta.0",
|
|
4
4
|
"description": "Control your Homebridge devices with Amazon Alexa.",
|
|
5
5
|
"main": "plugin.js",
|
|
6
6
|
"scripts": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"debug": ">=4.3.3",
|
|
42
42
|
"hap-node-client": ">=0.1.16",
|
|
43
43
|
"is-my-json-valid": ">=2.20.6",
|
|
44
|
-
"mqtt": "4.
|
|
44
|
+
"mqtt": "^4.3.4"
|
|
45
45
|
},
|
|
46
46
|
"author": "NorthernMan54",
|
|
47
47
|
"license": "Apache-2.0",
|
package/plugin.js
CHANGED
|
@@ -40,14 +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.LegacyCloudTransport = config['LegacyCloudTransport'] || false; // Default to new Transport
|
|
43
44
|
var mqttKeepalive = config['keepalive'] || 20; // MQTT Connection Keepalive
|
|
44
45
|
|
|
45
|
-
if(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
46
|
+
if (mqttKeepalive < 60) {
|
|
47
|
+
this.keepalive = mqttKeepalive * 60;
|
|
48
|
+
} else {
|
|
49
|
+
this.keepalive = mqttKeepalive;
|
|
50
|
+
}
|
|
51
51
|
|
|
52
52
|
// Enable config based DEBUG logging enable
|
|
53
53
|
this.debug = config['debug'] || false;
|
|
@@ -94,24 +94,26 @@ alexaHome.prototype = {
|
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
alexaHome.prototype.didFinishLaunching = function() {
|
|
97
|
-
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
|
|
98
99
|
if (this.beta) {
|
|
99
|
-
host = '
|
|
100
|
+
host = 'clone.homebridge.ca';
|
|
101
|
+
// reconnectPeriod = 10000;
|
|
100
102
|
}
|
|
103
|
+
|
|
101
104
|
options = {
|
|
102
105
|
// Shared Options
|
|
103
106
|
log: this.log,
|
|
104
107
|
debug: this.debug,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
keepalive: this.keepalive, // Reduce client timeout to 10 minutes
|
|
108
|
+
mqttURL: (this.LegacyCloudTransport ? "mqtt://" + host + ":1883/" : "wss://" + host + "/ws"),
|
|
109
|
+
transport: (this.LegacyCloudTransport ? "mqtt" : "wss"),
|
|
110
|
+
mqttOptions: {
|
|
111
|
+
username: this.username,
|
|
112
|
+
password: this.password,
|
|
113
|
+
reconnectPeriod: reconnectPeriod, // Increased reconnect period to allow DDOS protection to reset
|
|
114
|
+
keepalive: (this.LegacyCloudTransport ? this.keepalive : 55), // Keep alive not required when using WSS Transport
|
|
115
|
+
rejectUnauthorized: false
|
|
116
|
+
},
|
|
115
117
|
// HAP Node Client options
|
|
116
118
|
pin: this.pin,
|
|
117
119
|
refresh: this.refresh,
|
|
@@ -145,7 +147,13 @@ alexaHome.prototype.didFinishLaunching = function() {
|
|
|
145
147
|
// Alexa mesages
|
|
146
148
|
|
|
147
149
|
this.eventBus.on('System', function(message) {
|
|
148
|
-
this.log.error("ERROR:
|
|
150
|
+
this.log.error("ERROR:", message.directive.header.message);
|
|
151
|
+
}.bind(this));
|
|
152
|
+
this.eventBus.on('Warning', function(message) {
|
|
153
|
+
this.log.warn("Warning:", message.directive.header.message);
|
|
154
|
+
}.bind(this));
|
|
155
|
+
this.eventBus.on('Information', function(message) {
|
|
156
|
+
this.log("Info:", message.directive.header.message);
|
|
149
157
|
}.bind(this));
|
|
150
158
|
this.eventBus.on('Alexa', alexaActions.alexaMessage.bind(this));
|
|
151
159
|
this.eventBus.on('Alexa.Discovery', alexaActions.alexaDiscovery.bind(this));
|