homebridge-texecom-full 4.2.7-beta.1 → 4.2.7
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 +5 -0
- package/README.md +1 -0
- package/index.js +52 -22
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
[](https://www.npmjs.com/package/homebridge-texecom-full)
|
|
3
3
|
[](https://www.npmjs.com/package/homebridge-texecom-full)
|
|
4
4
|
[](https://github.com/K1LL3R234/homebridge-texecom)
|
|
5
|
+
[](https://github.com/homebridge/homebridge/wiki/Verified-Plugins)
|
|
5
6
|
# homebridge-texecom-full
|
|
6
7
|
|
|
7
8
|
A plugin for [Homebridge](https://github.com/nfarina/homebridge) that creates HomeKit motion, contact, smoke, or carbon monoxide sensors for alarm zones from a Texecom Premier intruder alarm via a serial connection or COM-IP module.
|
package/index.js
CHANGED
|
@@ -13,7 +13,6 @@ class ResponseEmitter extends EventEmitter { }
|
|
|
13
13
|
const responseEmitter = new ResponseEmitter();
|
|
14
14
|
|
|
15
15
|
const LogUtil = require('./util/logutil');
|
|
16
|
-
const { platform } = require("os");
|
|
17
16
|
|
|
18
17
|
var areas_armed = []; // Creates an empty array, which can later grow dynamically
|
|
19
18
|
|
|
@@ -221,7 +220,11 @@ TexecomPlatform.prototype = {
|
|
|
221
220
|
});
|
|
222
221
|
this.texecomConnection = serialPort;
|
|
223
222
|
} else if (this.ip_address) {
|
|
224
|
-
|
|
223
|
+
|
|
224
|
+
setupConnection();
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
/*try {
|
|
225
228
|
connection = net.createConnection(platform.ip_port, platform.ip_address, function () {
|
|
226
229
|
platform.log.log('Connected via IP');
|
|
227
230
|
});
|
|
@@ -236,13 +239,10 @@ TexecomPlatform.prototype = {
|
|
|
236
239
|
processData(data);
|
|
237
240
|
});
|
|
238
241
|
|
|
239
|
-
connection.on('timeout', () => {
|
|
240
|
-
platform.log.error('Connection attempt timed out.');
|
|
241
|
-
connection.destroy(); // prevent crash
|
|
242
|
-
});
|
|
243
242
|
|
|
244
|
-
connection.on('error', (err)
|
|
245
|
-
platform.log.error(`
|
|
243
|
+
connection.on('error', function (err) {
|
|
244
|
+
platform.log.error(`IP connection error: ${err}`);
|
|
245
|
+
|
|
246
246
|
});
|
|
247
247
|
|
|
248
248
|
connection.on('end', function () {
|
|
@@ -251,27 +251,57 @@ TexecomPlatform.prototype = {
|
|
|
251
251
|
|
|
252
252
|
connection.on('close', function () {
|
|
253
253
|
platform.log.log('IP connection closed');
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
});
|
|
262
|
-
} catch (err) {
|
|
263
|
-
platform.log.error(err);
|
|
264
|
-
}
|
|
265
|
-
}, 10000);
|
|
266
|
-
|
|
254
|
+
try {
|
|
255
|
+
connection = net.createConnection(platform.ip_port, platform.ip_address, function () {
|
|
256
|
+
platform.log.log('Re-connected after loss of connection');
|
|
257
|
+
});
|
|
258
|
+
} catch (err) {
|
|
259
|
+
platform.log.error(err);
|
|
260
|
+
}
|
|
267
261
|
});
|
|
268
|
-
this.texecomConnection = connection
|
|
262
|
+
this.texecomConnection = connection;*/
|
|
269
263
|
} else {
|
|
270
264
|
this.log.log("Must set either serial_device or ip_address in configuration.");
|
|
271
265
|
}
|
|
272
266
|
}
|
|
273
267
|
}
|
|
274
268
|
|
|
269
|
+
function setupConnection() {
|
|
270
|
+
platform.log.log('Attempting connection to Texecom...');
|
|
271
|
+
|
|
272
|
+
connection = net.createConnection(platform.ip_port, platform.ip_address);
|
|
273
|
+
|
|
274
|
+
connection.setNoDelay(true);
|
|
275
|
+
|
|
276
|
+
connection.on('connect', () => {
|
|
277
|
+
platform.log.log('Connected via IP');
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
connection.on('data', function (data) {
|
|
281
|
+
platform.log.debug(`IP data received: ${data}`);
|
|
282
|
+
responseEmitter.emit('data', data);
|
|
283
|
+
processData(data);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
connection.on('error', (err) => {
|
|
287
|
+
platform.log.error('IP connection error:', err.message);
|
|
288
|
+
// We'll reconnect on 'close'
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
connection.on('close', () => {
|
|
292
|
+
platform.log.error('IP connection closed. Will attempt to reconnect in 10s.');
|
|
293
|
+
setTimeout(() => {
|
|
294
|
+
setupConnection(); // try again
|
|
295
|
+
}, 10000);
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
connection.on('end', () => {
|
|
299
|
+
platform.log.log('IP connection ended');
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
platform.texecomConnection = connection;
|
|
303
|
+
}
|
|
304
|
+
|
|
275
305
|
function TexecomAccessory(log, config) {
|
|
276
306
|
this.log = log;
|
|
277
307
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"displayName": "Homebridge Texecom",
|
|
3
3
|
"name": "homebridge-texecom-full",
|
|
4
4
|
"description": "A plugin for homebridge to integrate Texecom Premier Elite alarm systems into HomeKit",
|
|
5
|
-
"version": "4.2.7
|
|
5
|
+
"version": "4.2.7",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Chris Posthumus",
|
|
8
8
|
"email": "chris.posthumus@gmail.com"
|