@brandonarrindell/homebridge-envisalink 1.3.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.
Files changed (84) hide show
  1. package/.eslintrc.json +38 -0
  2. package/.github/FUNDING.yml +2 -0
  3. package/.github/ISSUE_TEMPLATE/bug-report.md +44 -0
  4. package/.github/ISSUE_TEMPLATE/config.yml +5 -0
  5. package/.github/ISSUE_TEMPLATE/feature-request.md +23 -0
  6. package/.github/ISSUE_TEMPLATE/support-request.md +38 -0
  7. package/.github/dependabot.yml +9 -0
  8. package/.github/workflows/build.yml +31 -0
  9. package/LICENSE +21 -0
  10. package/README.md +207 -0
  11. package/config.schema.json +240 -0
  12. package/dist/configTypes.d.ts +39 -0
  13. package/dist/configTypes.d.ts.map +1 -0
  14. package/dist/configTypes.js +3 -0
  15. package/dist/configTypes.js.map +1 -0
  16. package/dist/constants.d.ts +4 -0
  17. package/dist/constants.d.ts.map +1 -0
  18. package/dist/constants.js +7 -0
  19. package/dist/constants.js.map +1 -0
  20. package/dist/customCommandAccessory.d.ts +17 -0
  21. package/dist/customCommandAccessory.d.ts.map +1 -0
  22. package/dist/customCommandAccessory.js +51 -0
  23. package/dist/customCommandAccessory.js.map +1 -0
  24. package/dist/index.d.ts +7 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +7 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/networkScanner.d.ts +42 -0
  29. package/dist/networkScanner.d.ts.map +1 -0
  30. package/dist/networkScanner.js +191 -0
  31. package/dist/networkScanner.js.map +1 -0
  32. package/dist/nodeAlarmProxyTypes.d.ts +17 -0
  33. package/dist/nodeAlarmProxyTypes.d.ts.map +1 -0
  34. package/dist/nodeAlarmProxyTypes.js +3 -0
  35. package/dist/nodeAlarmProxyTypes.js.map +1 -0
  36. package/dist/panicAccessory.d.ts +23 -0
  37. package/dist/panicAccessory.d.ts.map +1 -0
  38. package/dist/panicAccessory.js +69 -0
  39. package/dist/panicAccessory.js.map +1 -0
  40. package/dist/partitionAccessory.d.ts +21 -0
  41. package/dist/partitionAccessory.d.ts.map +1 -0
  42. package/dist/partitionAccessory.js +202 -0
  43. package/dist/partitionAccessory.js.map +1 -0
  44. package/dist/platform.d.ts +58 -0
  45. package/dist/platform.d.ts.map +1 -0
  46. package/dist/platform.js +529 -0
  47. package/dist/platform.js.map +1 -0
  48. package/dist/settings.d.ts +9 -0
  49. package/dist/settings.d.ts.map +1 -0
  50. package/dist/settings.js +12 -0
  51. package/dist/settings.js.map +1 -0
  52. package/dist/types.d.ts +55 -0
  53. package/dist/types.d.ts.map +1 -0
  54. package/dist/types.js +52 -0
  55. package/dist/types.js.map +1 -0
  56. package/dist/util.d.ts +8 -0
  57. package/dist/util.d.ts.map +1 -0
  58. package/dist/util.js +75 -0
  59. package/dist/util.js.map +1 -0
  60. package/dist/zoneAccessory.d.ts +19 -0
  61. package/dist/zoneAccessory.d.ts.map +1 -0
  62. package/dist/zoneAccessory.js +74 -0
  63. package/dist/zoneAccessory.js.map +1 -0
  64. package/docs/EnvisaLinkTPI-1-08.pdf +0 -0
  65. package/jest.config.ts +30 -0
  66. package/nodemon.json +12 -0
  67. package/package.json +69 -0
  68. package/src/configTypes.ts +43 -0
  69. package/src/constants.ts +3 -0
  70. package/src/customCommandAccessory.ts +52 -0
  71. package/src/index.ts +11 -0
  72. package/src/networkScanner.ts +211 -0
  73. package/src/nodeAlarmProxyTypes.ts +20 -0
  74. package/src/panicAccessory.ts +72 -0
  75. package/src/partitionAccessory.ts +219 -0
  76. package/src/platform.ts +544 -0
  77. package/src/settings.ts +9 -0
  78. package/src/types.ts +85 -0
  79. package/src/util.ts +75 -0
  80. package/src/zoneAccessory.ts +95 -0
  81. package/test/integration.spec.ts +121 -0
  82. package/test/networkScanner.spec.ts +283 -0
  83. package/test/util.spec.ts +106 -0
  84. package/tsconfig.json +27 -0
@@ -0,0 +1,529 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.EnvisalinkHomebridgePlatform = exports.REPORT_ERROR_TXT = void 0;
30
+ const nap = require("nodealarmproxy");
31
+ const dateformat_1 = __importDefault(require("dateformat"));
32
+ const settings_1 = require("./settings");
33
+ const util_1 = require("./util");
34
+ const types_1 = require("./types");
35
+ const zoneAccessory_1 = require("./zoneAccessory");
36
+ const partitionAccessory_1 = require("./partitionAccessory");
37
+ const panicAccessory_1 = require("./panicAccessory");
38
+ const customCommandAccessory_1 = require("./customCommandAccessory");
39
+ const networkScanner_1 = require("./networkScanner");
40
+ const envisalinkCodes = require("nodealarmproxy/envisalink.js");
41
+ const util = __importStar(require("util"));
42
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
43
+ const packageJSON = require('../package.json');
44
+ exports.REPORT_ERROR_TXT = '\nPlease report all bugs at ' + packageJSON.bugs.url + '\n';
45
+ const MILLIS_BETWEEN_WAIT = 100;
46
+ const MILLIS_MAX_WAIT = 30000;
47
+ const MILLIS_BETWEEN_RECONNECTS = 60000;
48
+ const promisifiedNapCommand = util.promisify(nap.manualCommand);
49
+ /**
50
+ * HomebridgePlatform
51
+ * This class is the main constructor for your plugin, this is where you should
52
+ * parse the user config and discover/register accessories with Homebridge.
53
+ */
54
+ class EnvisalinkHomebridgePlatform {
55
+ constructor(log, config, api) {
56
+ this.log = log;
57
+ this.config = config;
58
+ this.api = api;
59
+ this.Service = this.api.hap.Service;
60
+ this.Characteristic = this.api.hap.Characteristic;
61
+ // this is used to track restored cached accessories
62
+ this.accessories = new Map();
63
+ this.chimeInitialized = false;
64
+ this.log.debug('Finished initializing platform:', this.config.name);
65
+ const co = this.getConfig();
66
+ this.alarm = undefined;
67
+ this.zoneConfigs = new Map();
68
+ if (!co || !co.password || !co.pin) {
69
+ this.log.warn('Platform will be skipped because config is missing password and/or pin.');
70
+ return;
71
+ }
72
+ if (!co.partitions || co.partitions.length === 0) {
73
+ this.log.warn('Platform will be skipped partitions were not configured.');
74
+ return;
75
+ }
76
+ if (!co.zones || co.zones.length === 0) {
77
+ this.log.warn('Platform will be skipped zones were not configured.');
78
+ return;
79
+ }
80
+ // When this event is fired it means Homebridge has restored all cached accessories from disk.
81
+ // Dynamic Platform plugins should only register new accessories after this event was fired,
82
+ // in order to ensure they weren't added to homebridge already. This event can also be used
83
+ // to start discovery of new accessories.
84
+ this.api.on('didFinishLaunching', async () => {
85
+ log.debug('Executed didFinishLaunching callback');
86
+ // If host is not provided and auto-discovery is enabled, try to discover the device
87
+ if (!co.host && co.enableAutoDiscovery !== false) {
88
+ try {
89
+ const discoveredHost = await this.discoverEnvisalinkDevice(co.port || 4025);
90
+ if (discoveredHost) {
91
+ co.host = discoveredHost;
92
+ this.log.info(`Auto-discovered Envisalink device at ${co.host}`);
93
+ }
94
+ else {
95
+ this.log.error('No Envisalink devices found on the network. Please specify the host manually.');
96
+ return;
97
+ }
98
+ }
99
+ catch (error) {
100
+ this.log.error('Error during auto-discovery:', error);
101
+ this.log.error('Please specify the host manually.');
102
+ return;
103
+ }
104
+ }
105
+ if (!co.host) {
106
+ this.log.error('No host specified and auto-discovery is disabled. Please specify the host manually.');
107
+ return;
108
+ }
109
+ this.log.info(`Configuring Envisalink platform, Host: ${co.host} Port: ${co.port}`);
110
+ try {
111
+ await this.resetConnection(null);
112
+ let increment = 0;
113
+ this.zoneConfigs = co.zones.reduce((map, zoneConfig) => {
114
+ increment++;
115
+ if (!zoneConfig.zoneNumber) {
116
+ zoneConfig.zoneNumber = increment;
117
+ }
118
+ if (!zoneConfig.name) {
119
+ zoneConfig.name = `Zone ${increment}`;
120
+ }
121
+ map.set(`${zoneConfig.zoneNumber}`, zoneConfig);
122
+ return map;
123
+ }, new Map());
124
+ this.discoverPanicAccessories();
125
+ this.discoverCustomCommandAccessories();
126
+ // Wait for full initialization first
127
+ setTimeout(this.setTime.bind(this), 60000);
128
+ }
129
+ catch (error) {
130
+ this.log.error('Failed to initialize homebridge-envisalink.', error);
131
+ return;
132
+ }
133
+ });
134
+ }
135
+ /**
136
+ * This function is invoked when homebridge restores cached accessories from disk at startup.
137
+ * It should be used to setup event handlers for characteristics and update respective values.
138
+ */
139
+ configureAccessory(accessory) {
140
+ this.log.debug(`Loading accessory from cache: ${accessory.displayName}`);
141
+ this.accessories.set(accessory.UUID, accessory);
142
+ }
143
+ async handleDisconnect() {
144
+ this.resetConnection(new Error('Unknown disconnect occurred.'));
145
+ }
146
+ async resetConnection(err) {
147
+ try {
148
+ this.log.info('Attempting connect to Envisalink..');
149
+ if (err) {
150
+ this.log.error(`Caught connection error. Sleeping ${MILLIS_BETWEEN_RECONNECTS / 1000} seconds and trying again. `, err);
151
+ await new Promise(f => setTimeout(f, MILLIS_BETWEEN_RECONNECTS));
152
+ }
153
+ const co = this.getConfig();
154
+ const maxZoneNumber = Math.max(...co.zones.map((zone) => {
155
+ return zone.zoneNumber || -1;
156
+ }));
157
+ this.alarm = this.initializeNodeAlarmProxy(co.partitions.length, Math.max(maxZoneNumber, co.zones.length));
158
+ }
159
+ catch (e) {
160
+ this.log.error('Fatal error in reset connection', e);
161
+ }
162
+ }
163
+ initializeNodeAlarmProxy(partitionCount, zoneCount) {
164
+ const co = this.getConfig();
165
+ const proxyEnabled = !!co.proxyPort;
166
+ const alarmConfig = {
167
+ password: co.password,
168
+ serverpassword: co.password,
169
+ actualhost: co.host,
170
+ actualport: co.port ? co.port : 4025,
171
+ serverhost: '0.0.0.0',
172
+ serverport: co.proxyPort ? co.proxyPort : 4026,
173
+ zone: zoneCount,
174
+ userPrograms: null,
175
+ partition: partitionCount,
176
+ proxyenable: proxyEnabled,
177
+ atomicEvents: true,
178
+ logger: this.log,
179
+ };
180
+ const nodeAlarm = nap.initConfig(alarmConfig);
181
+ if (proxyEnabled) {
182
+ this.log.info(`Node alarm proxy started. Listening for connections at: ${alarmConfig.serverhost}:${alarmConfig.serverport}`);
183
+ }
184
+ else {
185
+ this.log.info('Node alarm proxy started. Proxy is disabled');
186
+ }
187
+ nodeAlarm.on('data', this.dataUpdate.bind(this));
188
+ nodeAlarm.on('connecterror', this.resetConnection.bind(this));
189
+ nodeAlarm.on('connectionended', this.handleDisconnect.bind(this));
190
+ nodeAlarm.on('zoneupdate', this.zoneUpdate.bind(this));
191
+ nodeAlarm.on('partitionupdate', this.partitionUpdate.bind(this));
192
+ nodeAlarm.on('partitionuserupdate', this.partitionUserUpdate.bind(this));
193
+ nodeAlarm.on('systemupdate', this.systemUpdate.bind(this));
194
+ nodeAlarm.on('coderequired', this.codeRequired.bind(this));
195
+ return nodeAlarm;
196
+ }
197
+ discoverCustomCommandAccessories() {
198
+ if (!this.getConfig().customCommands || this.getConfig().customCommands.length === 0) {
199
+ this.log.debug('No custom commands configured.');
200
+ return;
201
+ }
202
+ this.getConfig().customCommands.forEach(customCommand => {
203
+ const uuid = this.api.hap.uuid.generate(`envisalink.customCommand.${customCommand.command}`);
204
+ let accessory = this.accessories.get(uuid);
205
+ if (accessory) {
206
+ this.log.debug('Restoring existing custom command accessory from cache:', accessory.displayName);
207
+ accessory.displayName = customCommand.name;
208
+ this.api.updatePlatformAccessories([accessory]);
209
+ new customCommandAccessory_1.EnvisalinkCustomCommandAccessory(this, accessory, customCommand.name, customCommand.command);
210
+ }
211
+ else {
212
+ this.log.debug('Adding new custom command accessory because accessory was not restored from cache.');
213
+ accessory = new this.api.platformAccessory(customCommand.name, uuid);
214
+ this.accessories.set(uuid, accessory);
215
+ new customCommandAccessory_1.EnvisalinkCustomCommandAccessory(this, accessory, customCommand.name, customCommand.command);
216
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
217
+ }
218
+ });
219
+ }
220
+ discoverPanicAccessories() {
221
+ var _a, _b, _c;
222
+ const co = this.getConfig();
223
+ if (!((_a = co.policePanic) === null || _a === void 0 ? void 0 : _a.enabled) && !((_b = co.firePanic) === null || _b === void 0 ? void 0 : _b.enabled) && !((_c = co.ambulancePanic) === null || _c === void 0 ? void 0 : _c.enabled)) {
224
+ this.log.info('Panic buttons disabled. Will not install panic switches.');
225
+ return;
226
+ }
227
+ const uuid = this.api.hap.uuid.generate('envisalink.panic');
228
+ let accessory = this.accessories.get(uuid);
229
+ if (accessory) {
230
+ this.log.debug('Restoring existing panic accessory from cache:', accessory.displayName);
231
+ this.api.updatePlatformAccessories([accessory]);
232
+ new panicAccessory_1.EnvisalinkPanicAccessory(this, accessory, this.getConfig());
233
+ }
234
+ else {
235
+ this.log.debug('Adding new panic accessory because accessory was not restored from cache.');
236
+ accessory = new this.api.platformAccessory('Panic', uuid);
237
+ this.accessories.set(uuid, accessory);
238
+ new panicAccessory_1.EnvisalinkPanicAccessory(this, accessory, this.getConfig());
239
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
240
+ }
241
+ }
242
+ async setTime() {
243
+ if (!this.getConfig().suppressClockReset) {
244
+ try {
245
+ const date = (0, dateformat_1.default)(new Date(), 'HHMMmmddyy');
246
+ this.log.debug(`Setting the current time on the alarm system to: ${date}`);
247
+ await this.sendAlarmCommand(`010${date}`);
248
+ this.log.debug('Time set successfully');
249
+ }
250
+ catch (error) {
251
+ this.log.error('Error setting time', error);
252
+ }
253
+ // Once per hour.
254
+ setTimeout(this.setTime.bind(this), 60 * 60 * 1000);
255
+ }
256
+ }
257
+ updateZoneAccessory(zone) {
258
+ const uuid = this.api.hap.uuid.generate(`envisalink.${zone.partition}.${zone.number}`);
259
+ let accessory = this.accessories.get(uuid);
260
+ if (accessory) {
261
+ this.log.debug('Restoring existing zone accessory from cache:', accessory.displayName);
262
+ accessory.context = zone;
263
+ this.api.updatePlatformAccessories([accessory]);
264
+ new zoneAccessory_1.EnvisalinkZoneAccessory(this, accessory);
265
+ }
266
+ else {
267
+ this.log.debug(`Adding new zone accessory because ${accessory} was not restored from cache:`, zone.name);
268
+ accessory = new this.api.platformAccessory(zone.name, uuid);
269
+ accessory.context = zone;
270
+ this.accessories.set(uuid, accessory);
271
+ new zoneAccessory_1.EnvisalinkZoneAccessory(this, accessory);
272
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
273
+ }
274
+ }
275
+ async bypassAllOpenZones(partition) {
276
+ try {
277
+ this.log.debug(`Bypassing open zones in partition: ${partition}. Checking ${this.accessories.size} accessories.`);
278
+ let bypassedCount = 0;
279
+ for (const accessory of this.accessories.values()) {
280
+ if (accessory.context && Object.prototype.hasOwnProperty.call(accessory.context, 'type')) {
281
+ const zone = accessory.context;
282
+ if (zone.partition === partition && types_1.CONTACT_SENSORS.has(zone.type) && zone.status.text === 'open') {
283
+ this.log.info(`Bypassing open zone: ${zone.name}`);
284
+ const zoneString = String(zone.number).padStart(2, '0');
285
+ await this.sendAlarmCommand(`071${partition}*1${zoneString}#`, partition);
286
+ bypassedCount++;
287
+ }
288
+ }
289
+ }
290
+ this.log.info(`${bypassedCount} open zones were bypassed.`);
291
+ }
292
+ catch (error) {
293
+ this.log.error('Failed to bypass open zones', error);
294
+ }
295
+ }
296
+ getPartitionStatus(partitionNumber) {
297
+ for (const accessory of this.accessories.values()) {
298
+ //Hack.
299
+ if (accessory.context && Object.prototype.hasOwnProperty.call(accessory.context, 'enableChimeSwitch')) {
300
+ const partition = accessory.context;
301
+ if (partition.number === partitionNumber) {
302
+ return partition.status;
303
+ }
304
+ }
305
+ }
306
+ throw new Error(`Could not find partition: ${partitionNumber}`);
307
+ }
308
+ updatePartitionAccessory(partition) {
309
+ var _a, _b;
310
+ const uuid = this.api.hap.uuid.generate(`envisalink.${partition.number}`);
311
+ let accessory = this.accessories.get(uuid);
312
+ partition.pin = partition.pin || this.getConfig().pin;
313
+ if (accessory) {
314
+ this.log.debug('Restoring existing partition accessory from cache:', accessory.displayName);
315
+ const previousChimeStatus = (_a = accessory.context) === null || _a === void 0 ? void 0 : _a.chimeActive;
316
+ // Restore chime status in case this update was unrelated to chime.
317
+ if (partition.chimeActive === undefined) {
318
+ partition.chimeActive = previousChimeStatus;
319
+ }
320
+ const previousBypassEnabled = (_b = accessory.context) === null || _b === void 0 ? void 0 : _b.bypassEnabled;
321
+ // Restore bypass enabled in case this update was unrelated to bypass.
322
+ if (partition.bypassEnabled === undefined) {
323
+ partition.bypassEnabled = previousBypassEnabled;
324
+ }
325
+ accessory.context = partition;
326
+ this.api.updatePlatformAccessories([accessory]);
327
+ new partitionAccessory_1.EnvisalinkPartitionAccessory(this, accessory);
328
+ }
329
+ else {
330
+ this.log.debug(`Adding new partition accessory because ${accessory} was not restored from cache:`, partition.name);
331
+ accessory = new this.api.platformAccessory(partition.name, uuid);
332
+ accessory.context = partition;
333
+ this.accessories.set(uuid, accessory);
334
+ new partitionAccessory_1.EnvisalinkPartitionAccessory(this, accessory);
335
+ this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
336
+ }
337
+ if (partition.enableChimeSwitch && !this.chimeInitialized) {
338
+ this.chimeInitialized = true;
339
+ // Super hacky, but toggle chime such that the initial status is reflected correctly.
340
+ // Wait 10 seconds for initial system startup (i.e. time sync)
341
+ const waitForStatusCodes = new Set([types_1.EnvisalinkStatusCode.ChimeEnabled, types_1.EnvisalinkStatusCode.ChimeDisabled]);
342
+ this.sendAlarmCommand(partition.chimeCommand, partition.number, waitForStatusCodes).then(() => {
343
+ this.sendAlarmCommand(partition.chimeCommand, partition.number, waitForStatusCodes).then(() => {
344
+ this.log.debug('Chime toggled twice successfully to fetch initial status.');
345
+ }).catch(error => this.log.error('Second set chime failed while fetching status', error));
346
+ }).catch(error => this.log.error('First set chime failed while fetching status', error));
347
+ }
348
+ }
349
+ dataUpdate(data) {
350
+ // Example:
351
+ // {
352
+ // "zone": {
353
+ // "1": {
354
+ // "send": "restore",
355
+ // "name": "Zone Alarm Restore",
356
+ // "code": "61000128"
357
+ // },
358
+ // },
359
+ // "partition": {
360
+ // "1": {
361
+ // "send": "readyforce",
362
+ // "name": "Partition Ready - Force Arming Enabled",
363
+ // "code": "6531CF"
364
+ // }
365
+ // },
366
+ // "user": {}
367
+ // }
368
+ try {
369
+ if (this.getConfig().enableVerboseLogging) {
370
+ this.log.debug(`Inside dataUpdate: ${this.json(data)}`);
371
+ }
372
+ const zoneUpdates = new Map(Object.entries(data.zone));
373
+ Object.values((0, util_1.transformZoneStatuses)(this.zoneConfigs, zoneUpdates)).forEach(zone => this.updateZoneAccessory(zone));
374
+ const partitionUpdates = new Map(Object.entries(data.partition));
375
+ (0, util_1.transformPartitionStatuses)(this.getConfig().partitions, partitionUpdates).forEach(partition => this.updatePartitionAccessory(partition));
376
+ }
377
+ catch (error) {
378
+ this.log.error(`Caught error in dataUpdate. Data: ${this.json(data)}`, error);
379
+ }
380
+ }
381
+ partitionUpdate(data) {
382
+ var _a;
383
+ // Example:
384
+ // {
385
+ // "partition": 1,
386
+ // "code": "650"
387
+ // }
388
+ try {
389
+ if (this.getConfig().enableVerboseLogging) {
390
+ this.log.debug(`Inside partitionUpdate: ${this.json(data)}`);
391
+ }
392
+ const partition = (0, util_1.transformPartitionStatus)(this.getConfig().partitions, data.partition, data);
393
+ this.updatePartitionAccessory(partition);
394
+ this.log.debug(`${partition.name} ${(_a = partition.status) === null || _a === void 0 ? void 0 : _a.verbSuffix}`);
395
+ }
396
+ catch (error) {
397
+ this.log.error(`Caught error in partitionUpdate. Data: ${this.json(data)}`, error);
398
+ }
399
+ }
400
+ setPartitionStatus(partitionNumber, statusCode) {
401
+ this.log.debug(`Forcing partition status to ${statusCode}: ${envisalinkCodes.tpicommands[statusCode].name}`);
402
+ const partition = (0, util_1.transformPartitionStatus)(this.getConfig().partitions, partitionNumber, {
403
+ code: statusCode,
404
+ });
405
+ this.updatePartitionAccessory(partition);
406
+ }
407
+ partitionUserUpdate(data) {
408
+ try {
409
+ this.log.debug(`Inside partitionUserUpdate: ${this.json(data)}`);
410
+ // TODO.
411
+ }
412
+ catch (error) {
413
+ this.log.error(`Caught error in systemUpdate. Data: ${this.json(data)}`, error);
414
+ }
415
+ }
416
+ zoneUpdate(data) {
417
+ var _a;
418
+ try {
419
+ // Example:
420
+ // {
421
+ // "zone": 6,
422
+ // "code": "610"
423
+ // }
424
+ if (this.getConfig().enableVerboseLogging) {
425
+ this.log.debug(`Inside zoneUpdate: ${this.json(data)}`);
426
+ }
427
+ const zone = (0, util_1.transformZoneStatus)(this.zoneConfigs, data.zone, data);
428
+ if (zone === null) {
429
+ this.log.debug(`Zone ${data.zone} returned null because of missing config. Assuming non-consecutive zones.`);
430
+ return;
431
+ }
432
+ this.updateZoneAccessory(zone);
433
+ this.log.debug(`${zone.name} ${(_a = zone.status) === null || _a === void 0 ? void 0 : _a.verbSuffix}`);
434
+ }
435
+ catch (error) {
436
+ this.log.error(`Caught error in zoneUpdate. Data: ${this.json(data)}`, error);
437
+ }
438
+ }
439
+ /**
440
+ * Haven't actually seen this fire yet. Log it to see if we need to handle.
441
+ * @param data
442
+ */
443
+ systemUpdate(data) {
444
+ try {
445
+ if (this.getConfig().enableVerboseLogging) {
446
+ this.log.debug(`Inside systemUpdate: ${this.json(data)}`);
447
+ }
448
+ }
449
+ catch (error) {
450
+ this.log.error(`Caught error in systemUpdate. Data: ${this.json(data)}`, error);
451
+ }
452
+ }
453
+ async codeRequired() {
454
+ try {
455
+ if (this.getConfig().enableVerboseLogging) {
456
+ this.log.debug('Inside codeRequired.');
457
+ }
458
+ if (!this.lastPartitionAction) {
459
+ this.log.error('Can\'t handle pin request from panel because last partition is null. ' +
460
+ 'Previous command will be ignored.');
461
+ return;
462
+ }
463
+ this.log.info('Panel has requested code (900 response). Sending PIN...');
464
+ await this.sendAlarmCommand(`200${this.lastPartitionAction.pin}`);
465
+ }
466
+ catch (error) {
467
+ this.log.error('Caught error in codeRequired.', error);
468
+ }
469
+ }
470
+ json(data) {
471
+ return JSON.stringify(data, null, 2);
472
+ }
473
+ getConfig() {
474
+ return this.config;
475
+ }
476
+ setLastPartitionAction(partition) {
477
+ this.lastPartitionAction = partition;
478
+ }
479
+ sleep(millis) {
480
+ return new Promise(resolve => setTimeout(resolve, millis));
481
+ }
482
+ async sendAlarmCommand(command, waitForReadyPartition, waitForStatusCodes) {
483
+ if (waitForReadyPartition) {
484
+ // Force to busy.
485
+ this.setPartitionStatus(waitForReadyPartition, types_1.EnvisalinkStatusCode.Busy);
486
+ }
487
+ this.log.debug(`Sending command to NAP ${command}`);
488
+ try {
489
+ await promisifiedNapCommand(command);
490
+ }
491
+ catch (err) {
492
+ const errorMessage = types_1.ERROR_CODES.get(err);
493
+ throw new Error(`Command ${command} resulted in error from alarm: ${err}: ${errorMessage}`);
494
+ }
495
+ if (waitForReadyPartition) {
496
+ let status = this.getPartitionStatus(waitForReadyPartition).shortCode;
497
+ this.log.debug(`Command ${command} succeeded. Waiting until partition is ready. Current: ${status}`);
498
+ let totalSleepTime = 0;
499
+ while (MILLIS_MAX_WAIT > totalSleepTime && (waitForStatusCodes ? !waitForStatusCodes.has(status) : status === types_1.EnvisalinkStatusCode.Busy)) {
500
+ this.log.debug(`Partition still ${this.getPartitionStatus(waitForReadyPartition).shortCode}. ` +
501
+ `Waiting for ${(waitForStatusCodes ? Array.from(waitForStatusCodes).join(',') : types_1.EnvisalinkStatusCode.Busy)}`);
502
+ totalSleepTime += MILLIS_BETWEEN_WAIT;
503
+ await this.sleep(MILLIS_BETWEEN_WAIT);
504
+ status = this.getPartitionStatus(waitForReadyPartition).shortCode;
505
+ }
506
+ this.log.debug(`Partition status is ${status} after wait. Continuing.`);
507
+ }
508
+ else {
509
+ this.log.debug(`Command ${command} succeeded.`);
510
+ }
511
+ }
512
+ /**
513
+ * Discover Envisalink device on the network
514
+ */
515
+ async discoverEnvisalinkDevice(port) {
516
+ const scanner = new networkScanner_1.EnvisalinkNetworkScanner(this.log);
517
+ const discoveredDevices = await scanner.discoverDevices(port);
518
+ if (discoveredDevices.length === 0) {
519
+ return null;
520
+ }
521
+ // If multiple devices are found, use the first one
522
+ if (discoveredDevices.length > 1) {
523
+ this.log.warn(`Multiple Envisalink devices found: ${discoveredDevices.join(', ')}. Using the first one: ${discoveredDevices[0]}`);
524
+ }
525
+ return discoveredDevices[0];
526
+ }
527
+ }
528
+ exports.EnvisalinkHomebridgePlatform = EnvisalinkHomebridgePlatform;
529
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,sCAAuC;AACvC,4DAAoC;AACpC,yCAAsD;AAEtD,iCAKgB;AAChB,mCAA6G;AAC7G,mDAAwD;AACxD,6DAAkE;AAElE,qDAA0D;AAC1D,qEAA0E;AAC1E,qDAA0D;AAC1D,gEAAiE;AACjE,2CAA6B;AAC7B,8DAA8D;AAC9D,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAClC,QAAA,gBAAg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B,CAAC,CAAC,SAAS,CAAC;aACrE;YACD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,uBAAuB,MAAM,0BAA0B,CAAC,CAAC;SAC3E;aAAM;YACH,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,OAAO,aAAa,CAAC,CAAC;SACnD;IACL,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,wBAAwB,CAAC,IAAY;QAC/C,MAAM,OAAO,GAAG,IAAI,yCAAwB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACvD,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAE9D,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE;YAChC,OAAO,IAAI,CAAC;SACf;QAED,mDAAmD;QACnD,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;YAC9B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,sCAAsC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,0BAA0B,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;SACrI;QAED,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;CACJ;AAnfD,oEAmfC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This is the name of the platform that users will use to register the plugin in the Homebridge config.json
3
+ */
4
+ export declare const PLATFORM_NAME = "Envisalink";
5
+ /**
6
+ * This must match the name of your plugin as defined the package.json
7
+ */
8
+ export declare const PLUGIN_NAME = "homebridge-envisalink";
9
+ //# sourceMappingURL=settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,aAAa,eAAe,CAAC;AAE1C;;GAEG;AACH,eAAO,MAAM,WAAW,0BAA0B,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PLUGIN_NAME = exports.PLATFORM_NAME = void 0;
4
+ /**
5
+ * This is the name of the platform that users will use to register the plugin in the Homebridge config.json
6
+ */
7
+ exports.PLATFORM_NAME = 'Envisalink';
8
+ /**
9
+ * This must match the name of your plugin as defined the package.json
10
+ */
11
+ exports.PLUGIN_NAME = 'homebridge-envisalink';
12
+ //# sourceMappingURL=settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,aAAa,GAAG,YAAY,CAAC;AAE1C;;GAEG;AACU,QAAA,WAAW,GAAG,uBAAuB,CAAC"}
@@ -0,0 +1,55 @@
1
+ export declare enum ZoneType {
2
+ Door = "door",
3
+ Window = "window",
4
+ Leak = "leak",
5
+ Smoke = "smoke",
6
+ Motion = "motion"
7
+ }
8
+ export declare const CONTACT_SENSORS: Set<ZoneType>;
9
+ export declare enum PartitionMode {
10
+ Away = "away",
11
+ Stay = "stay",
12
+ AwayZeroEntry = "zero-entry-away",
13
+ StayZeroEntry = "zero-entry-stay"
14
+ }
15
+ type Status = {
16
+ shortCode: string;
17
+ longCode: string;
18
+ description?: string;
19
+ text?: string;
20
+ action?: string;
21
+ verbSuffix?: string;
22
+ };
23
+ export type ZoneStatus = Status;
24
+ export type PartitionStatus = {
25
+ mode?: PartitionMode;
26
+ } & Status;
27
+ export type Zone = {
28
+ name: string;
29
+ number: number;
30
+ partition: number;
31
+ type: ZoneType;
32
+ status: ZoneStatus;
33
+ };
34
+ export type Partition = {
35
+ name: string;
36
+ number: number;
37
+ status: PartitionStatus;
38
+ enableChimeSwitch: boolean;
39
+ chimeCommand: string;
40
+ pin?: string;
41
+ chimeActive?: boolean;
42
+ bypassEnabled?: boolean;
43
+ currentState?: number;
44
+ targetState?: number;
45
+ };
46
+ export declare const ERROR_CODES: Map<string, string>;
47
+ export declare enum EnvisalinkStatusCode {
48
+ Busy = "673",
49
+ ChimeEnabled = "663",
50
+ ChimeDisabled = "664",
51
+ Ready = "650",
52
+ NotReady = "651"
53
+ }
54
+ export {};
55
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAChB,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,MAAM,WAAW;CACpB;AAED,eAAO,MAAM,eAAe,eAA4C,CAAC;AAGzE,oBAAY,aAAa;IACrB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,aAAa,oBAAoB;IACjC,aAAa,oBAAoB;CACpC;AAED,KAAK,MAAM,GAAG;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAK,MAAM,CAAC;AAElC,MAAM,MAAM,eAAe,GAAG;IAC1B,IAAI,CAAC,EAAE,aAAa,CAAC;CACxB,GAAG,MAAM,CAAC;AAEX,MAAM,MAAM,IAAI,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,MAAM,EAAE,UAAU,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAA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