homebridge2-alarmdecoder-platform 1.0.0-beta.1

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/.eslintrc.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "env": {
3
+ "es2022": true,
4
+ "node": true
5
+ },
6
+ "extends": "eslint:recommended",
7
+ "parserOptions": {
8
+ "sourceType": "module",
9
+ "ecmaVersion": 2022
10
+ },
11
+ "rules": {
12
+ "indent": ["error", 4],
13
+ "linebreak-style": ["error", "unix"],
14
+ "quotes": ["error", "single"],
15
+ "semi": ["error", "always"]
16
+ }
17
+ }
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {2018} {aficustree}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,123 @@
1
+ # homebridge2-alarmdecoder-platform
2
+
3
+ Homebridge 2.0 dynamic platform plugin for the [AlarmDecoder](https://alarmdecoder.com) interface to Honeywell/DSC and Interlogix (GE Security / Caddx / NetworX) alarm panels.
4
+
5
+ This plugin is a Homebridge 2.0–compatible fork of [homebridge-alarmdecoder-platform](https://github.com/aficustree/homebridge-alarmdecoder-platform) by aficustree, updated for modern Homebridge APIs and extended with additional features.
6
+
7
+ **Requirements:**
8
+
9
+ - **Node.js ≥ 22**
10
+ - **Homebridge ≥ 1.8.0** (fully compatible with Homebridge 2.0)
11
+ - For DSC/Honeywell: a running [AlarmDecoder WebApp](https://www.alarmdecoder.com/wiki/index.php/AlarmDecoder_WebApp) with REST API enabled
12
+ - For Interlogix/GE: the [NX584 Interface Library](https://github.com/kk7ds/pynx584) by kk7ds
13
+
14
+ ## What's New vs. the Original
15
+
16
+ - **Homebridge 2.0 compatible** — ESM module, Promise-based characteristic handlers, updated `registerPlatform` API
17
+ - **`enableNightMode` config option** — hide Night arm mode from HomeKit if your panel doesn't support it
18
+ - **"clear" switch** — momentary switch that sends the clear/off sequence and auto-resets after 1 second
19
+ - **Updated dependencies** — axios 1.x (security fixes over 0.21.x), debug 4.x
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npm install -g homebridge2-alarmdecoder-platform
25
+ ```
26
+
27
+ Or via Homebridge UI: search for `homebridge2-alarmdecoder-platform`.
28
+
29
+ ## Zone Naming Convention
30
+
31
+ Zones are named automatically from the AlarmDecoder WebApp (or `config.ini` for Interlogix). The zone name determines the HomeKit accessory type:
32
+
33
+ | Keyword in name | HomeKit type |
34
+ |---|---|
35
+ | `motion` | Motion Sensor |
36
+ | `smoke` | Smoke Sensor |
37
+ | `carbon` | Carbon Monoxide Sensor |
38
+ | *(anything else)* | Contact Sensor (default) |
39
+
40
+ Set zone names in the AlarmDecoder WebApp under **Settings → Zones**.
41
+
42
+ ## Configuration
43
+
44
+ Use the Homebridge UI (config-ui-x) for a guided setup, or edit `config.json` directly.
45
+
46
+ Platform alias: `"AlarmDecoderPlatform"`
47
+
48
+ ### Honeywell Example
49
+
50
+ ```json
51
+ {
52
+ "platforms": [
53
+ {
54
+ "platform": "AlarmDecoderPlatform",
55
+ "name": "My Alarm",
56
+ "DSCorHoneywell": "Honeywell",
57
+ "port": 8888,
58
+ "key": "YOUR_API_KEY",
59
+ "stateURL": "http://YOURIP:YOURPORT/api/v1/alarmdecoder",
60
+ "zoneURL": "http://YOURIP:YOURPORT/api/v1/zones",
61
+ "setURL": "http://YOURIP:YOURPORT/api/v1/alarmdecoder/send",
62
+ "setPIN": "1234",
63
+ "panicKey": "<S1>",
64
+ "chimeKey": "9",
65
+ "enableNightMode": true,
66
+ "useSwitches": ["panic", "chime", "clear"]
67
+ }
68
+ ]
69
+ }
70
+ ```
71
+
72
+ See also: [sample-dsc-config.json](./sample-dsc-config.json), [sample-interlogix-config.json](./sample-interlogix-config.json)
73
+
74
+ ### Key Options
75
+
76
+ | Option | Required | Description |
77
+ |---|---|---|
78
+ | `name` | Yes | Display name for the security system in HomeKit |
79
+ | `DSCorHoneywell` | Yes | Panel type: `"Honeywell"`, `"DSC"`, or `"Interlogix"` |
80
+ | `port` | Yes | Port Homebridge listens on for push notifications from AlarmDecoder |
81
+ | `stateURL` | Yes | URL for alarm state (AlarmDecoder REST API) |
82
+ | `zoneURL` | Yes | URL for zone list |
83
+ | `setURL` | Yes | URL for sending keypad commands |
84
+ | `setPIN` | Yes | Alarm PIN (base digits only, e.g. `"1234"`) |
85
+ | `key` | Honeywell/DSC | API key from AlarmDecoder WebApp |
86
+ | `enableNightMode` | No | Show Night arm mode (default: `true`) |
87
+ | `useSwitches` | No | Array of switches to create: `"panic"`, `"chime"`, `"away"`, `"stay"`, `"night"`, `"clear"` |
88
+ | `panicKey` | No | Key sequence for panic (Honeywell/DSC only) |
89
+ | `chimeKey` | No | Key for chime toggle (Honeywell/DSC only) |
90
+ | `offKey` | No | Key appended to PIN for clear command (default: `"1"`) |
91
+ | `DSCStay` | DSC only | Stay arm sequence (e.g. `"<F4>"`) |
92
+ | `DSCAway` | DSC only | Away arm sequence (e.g. `"<S5>"`) |
93
+ | `DSCReset` | DSC only | Reset sequence (e.g. `"<S7>"`) |
94
+ | `DSCExit` | DSC only | Exit sequence (e.g. `"<S8>"`) |
95
+
96
+ ### Security Note on `useSwitches`
97
+
98
+ Using `away`, `stay`, or `night` switches lets Siri arm/disarm the system **without the HomeKit security prompt** (i.e., without unlocking your device first). `panic`, `chime`, and `clear` are safe. Only enable arm/disarm switches if you're using them for automations where you accept this trade-off.
99
+
100
+ ## AlarmDecoder WebApp Notification Setup (Honeywell/DSC)
101
+
102
+ 1. Open the AlarmDecoder WebApp → Settings → Notifications → New Notification
103
+ 2. Notification Type: **Custom**
104
+ 3. Under **Notification Events**, tick:
105
+ - Alarm system is triggered / stops signaling
106
+ - A panic has been detected
107
+ - A fire is detected
108
+ - Alarm system is armed / disarmed
109
+ - A zone has faulted / been restored
110
+ 4. Under **Custom Settings**:
111
+ - URL: `http://HOMEBRIDGE_IP:PORT` (matches `port` in config)
112
+ - Path: `/`
113
+ - Method: **POST**
114
+
115
+ ## Extending to Other Panels
116
+
117
+ An [abstract base class](./alarmsystems/base.js) is provided. Implement `getAlarmState()`, `setAlarmState(state)`, and `initZones()`, then add a detection branch in `index.js`.
118
+
119
+ ## License
120
+
121
+ Copyright 2018 [aficustree](https://github.com/aficustree). Modifications copyright 2025 pabfou.
122
+
123
+ Licensed under the [Apache License, Version 2.0](./LICENSE).
@@ -0,0 +1,29 @@
1
+ export class AlarmZone {
2
+ constructor(zoneID, name, description) {
3
+ this.zoneID = zoneID;
4
+ this.name = name;
5
+ this.description = description;
6
+ this.faulted = false;
7
+ }
8
+ }
9
+
10
+ export class AlarmBase {
11
+ constructor(log) {
12
+ this.state = null;
13
+ this.log = log;
14
+ this.alarmZones = [];
15
+ }
16
+
17
+ async getAlarmState() {
18
+ throw 'must implement function updating alarm system state and state of all zones';
19
+ }
20
+
21
+ async setAlarmState(state) {
22
+ this.state = state;
23
+ throw 'must implement function updating alarm system state';
24
+ }
25
+
26
+ async initZones() {
27
+ throw 'must implement functions to populate Zones with AlarmDecoderZone(s)';
28
+ }
29
+ }
@@ -0,0 +1,139 @@
1
+ import { AlarmBase, AlarmZone } from './base.js';
2
+ import createDebug from 'debug';
3
+ import axios from 'axios';
4
+
5
+ const debug = createDebug('alarmdecoder');
6
+
7
+ export class HoneywellDSC extends AlarmBase {
8
+ constructor(log, config) {
9
+ super(log);
10
+ this.lastlogmsg = '';
11
+ this.key = config.key;
12
+ this.stateURL = config.stateURL;
13
+ this.zoneURL = config.zoneURL;
14
+ this.setURL = config.setURL;
15
+ this.setPIN = config.setPIN;
16
+ this.panicKey = config.panicKey;
17
+ this.chimeKey = config.chimeKey;
18
+ this.offKey = config.offKey || '1';
19
+ let rePlatformType = new RegExp('dsc', 'i');
20
+ if (rePlatformType.exec(config.DSCorHoneywell)) {
21
+ this.isDSC = true;
22
+ this.DSCAway = config.DSCAway;
23
+ this.DSCStay = config.DSCStay;
24
+ this.DSCReset = config.DSCReset;
25
+ this.DSCExit = config.DSCExit;
26
+ }
27
+ this.axiosHeaderConfig = {
28
+ headers: {
29
+ 'Authorization': this.key,
30
+ 'Content-Type': 'application/json',
31
+ 'Accept': 'application/json',
32
+ },
33
+ };
34
+ }
35
+
36
+ async initZones() {
37
+ try {
38
+ this.log('init zones');
39
+ const response = await axios.get(this.zoneURL, this.axiosHeaderConfig);
40
+ if (response.status !== 200 || !response.data)
41
+ throw 'initZones failed or generated null data with response status of ' + response.status;
42
+ for (let zone in response.data['zones']) {
43
+ zone = response.data['zones'][zone];
44
+ this.alarmZones.push(new AlarmZone(zone.zone_id, zone.name, zone.description));
45
+ }
46
+ return true;
47
+ } catch (e) {
48
+ this.log(e);
49
+ return false;
50
+ }
51
+ }
52
+
53
+ async getAlarmState() {
54
+ try {
55
+ const response = await axios.get(this.stateURL, this.axiosHeaderConfig);
56
+ if ((response.status === 200 || response.status === 204) && response.data) {
57
+ let stateObj = response.data;
58
+ if (stateObj.last_message_received &&
59
+ (stateObj.last_message_received.includes('NIGHT') ||
60
+ stateObj.last_message_received.includes('INSTANT')))
61
+ stateObj.panel_armed_night = true;
62
+
63
+ /* 0 = stay, 1 = away, 2 = night, 3 = disarmed, 4 = alarm */
64
+ const astate = JSON.stringify(stateObj);
65
+ if (this.lastlogmsg !== astate) {
66
+ this.log(astate);
67
+ this.lastlogmsg = astate;
68
+ }
69
+ if (stateObj.panel_alarming || stateObj.panel_panicked || stateObj.panel_fire_detected)
70
+ this.state = 4;
71
+ else if (stateObj.panel_armed_night)
72
+ this.state = 2;
73
+ else if (stateObj.panel_armed_stay)
74
+ this.state = 0;
75
+ else if (stateObj.panel_armed)
76
+ this.state = 1;
77
+ else
78
+ this.state = 3;
79
+
80
+ for (let alarmZone in this.alarmZones) {
81
+ alarmZone = this.alarmZones[alarmZone];
82
+ alarmZone.faulted = stateObj.panel_zones_faulted.indexOf(alarmZone.zoneID) !== -1;
83
+ }
84
+ return true;
85
+ } else {
86
+ throw 'getAlarmState failed with response status of ' + response.status;
87
+ }
88
+ } catch (e) {
89
+ this.log(e);
90
+ return false;
91
+ }
92
+ }
93
+
94
+ /* 0 = stay, 1 = away, 2 = night, 3 = disarmed, 4 = alarm */
95
+ async setAlarmState(state) {
96
+ let codeToSend = null;
97
+ switch (state) {
98
+ case 0:
99
+ codeToSend = this.isDSC ? this.DSCStay : this.setPIN + '3';
100
+ break;
101
+ case 1:
102
+ codeToSend = this.isDSC ? this.DSCAway : this.setPIN + '2';
103
+ break;
104
+ case 2:
105
+ codeToSend = this.setPIN + '33';
106
+ break;
107
+ case 3:
108
+ codeToSend = this.setPIN + '1';
109
+ break;
110
+ case 4:
111
+ codeToSend = this.panicKey;
112
+ state = true;
113
+ break;
114
+ case 'chime':
115
+ codeToSend = this.setPIN + this.chimeKey;
116
+ state = true;
117
+ break;
118
+ case 'clear':
119
+ codeToSend = this.setPIN + this.offKey + this.setPIN + this.offKey;
120
+ state = true;
121
+ break;
122
+ }
123
+ const body = JSON.stringify({ keys: codeToSend });
124
+ try {
125
+ if (this.isDSC && state === 3 && this.state === 3) {
126
+ debug('disarm request for DSC panel but system is already disarmed, ignoring');
127
+ return true;
128
+ }
129
+ const response = await axios.post(this.setURL, body, this.axiosHeaderConfig);
130
+ if (response.status === 200 || response.status === 204)
131
+ return true;
132
+ else
133
+ throw 'setAlarmState failed with response status of ' + response.status;
134
+ } catch (err) {
135
+ this.log(err);
136
+ return false;
137
+ }
138
+ }
139
+ }
@@ -0,0 +1,3 @@
1
+ export { HoneywellDSC } from './honeywell.js';
2
+ export { Interlogix } from './interlogix.js';
3
+ export { AlarmZone, AlarmBase } from './base.js';
@@ -0,0 +1,110 @@
1
+ import { AlarmBase, AlarmZone } from './base.js';
2
+ import axios from 'axios';
3
+
4
+ export class Interlogix extends AlarmBase {
5
+ constructor(log, config) {
6
+ super(log);
7
+ this.axiosConfig = {
8
+ headers: {
9
+ 'Content-Type': 'application/json',
10
+ 'Accept': 'application/json',
11
+ },
12
+ };
13
+ this.stateURL = config.stateURL;
14
+ this.zoneURL = config.zoneURL;
15
+ this.setURL = config.setURL;
16
+ this.setPIN = config.setPIN;
17
+ }
18
+
19
+ async getAlarmState() {
20
+ let response = null;
21
+ try {
22
+ response = await axios.get(this.zoneURL, this.axiosConfig);
23
+ if ((response.status === 200 || response.status === 204) && response.data && response.data.zones.length > 0) {
24
+ response.data['zones'].forEach((element) => {
25
+ this.alarmZones.find(v => v.zoneID === element.number).faulted = element.state;
26
+ });
27
+ } else {
28
+ throw 'getAlarmState failed or generated null data at zone query with response status of ' +
29
+ response.status + ' and data of: ' + JSON.stringify(response.data);
30
+ }
31
+
32
+ response = await axios.get(this.stateURL, this.axiosConfig);
33
+ if ((response.status === 200 || response.status === 204) && response.data) {
34
+ const mainPartition = response.data['partitions'][0];
35
+ const stayArmed = mainPartition.condition_flags.includes('Entryguard (stay mode)');
36
+ if (!(mainPartition.armed || mainPartition.condition_flags.includes('Instant')))
37
+ this.state = 3;
38
+ else {
39
+ const alarmingConditions = ['Siren on', 'Steady siren on', 'Fire'];
40
+ if (alarmingConditions.some(element => mainPartition.condition_flags.includes(element)))
41
+ this.state = 4;
42
+ else if (stayArmed)
43
+ this.state = 0;
44
+ else if (mainPartition.condition_flags.includes('Instant'))
45
+ this.state = 2;
46
+ else
47
+ this.state = 1;
48
+ }
49
+ } else {
50
+ throw 'getAlarmState failed at partition query with response status of ' + response.status;
51
+ }
52
+
53
+ return true;
54
+ } catch (e) {
55
+ this.log(e);
56
+ return false;
57
+ }
58
+ }
59
+
60
+ /* 0 = stay, 1 = away, 2 = night, 3 = disarmed, 4 = alarm */
61
+ async setAlarmState(state) {
62
+ this.state = state;
63
+ try {
64
+ switch (state) {
65
+ case 0:
66
+ this.axiosConfig.params = { 'cmd': 'arm', 'type': 'stay' };
67
+ break;
68
+ case 1:
69
+ this.axiosConfig.params = { 'cmd': 'arm', 'type': 'exit' };
70
+ break;
71
+ case 2:
72
+ this.axiosConfig.params = { 'cmd': 'arm', 'type': 'auto' };
73
+ break;
74
+ case 3:
75
+ this.axiosConfig.params = { 'cmd': 'disarm', 'type': 'stay', 'master_pin': this.setPIN };
76
+ break;
77
+ case 4:
78
+ throw 'panic button not supported';
79
+ case 'chime':
80
+ throw 'chime button not supported';
81
+ }
82
+ const response = await axios.get(this.setURL, this.axiosConfig);
83
+ if (response.status === 200 || response.status === 204)
84
+ return true;
85
+ else
86
+ throw 'setAlarmState failed with response status of ' + response.status;
87
+ } catch (e) {
88
+ this.log(e);
89
+ return false;
90
+ }
91
+ }
92
+
93
+ async initZones() {
94
+ try {
95
+ const response = await axios.get(this.zoneURL, this.axiosConfig);
96
+ if ((response.status === 200 || response.status === 204) && response.data && response.data.zones.length > 0) {
97
+ response.data['zones'].forEach(element =>
98
+ this.alarmZones.push(new AlarmZone(element.number, element.name, JSON.stringify(element.type_flags)))
99
+ );
100
+ } else {
101
+ throw 'initZones failed or generated null data with response status of ' +
102
+ response.status + ' with data of ' + JSON.stringify(response.data);
103
+ }
104
+ return true;
105
+ } catch (e) {
106
+ this.log(e);
107
+ return false;
108
+ }
109
+ }
110
+ }
@@ -0,0 +1,127 @@
1
+ {
2
+ "pluginAlias": "AlarmDecoderPlatform",
3
+ "pluginType": "platform",
4
+ "singular": true,
5
+ "headerDisplay": "Plugin for AlarmDecoder (Honeywell/DSC) and Interlogix/GE/Caddx alarm panels. Requires a running AlarmDecoder WebApp or NX584 gateway.",
6
+ "schema": {
7
+ "type": "object",
8
+ "properties": {
9
+ "name": {
10
+ "title": "Name",
11
+ "type": "string",
12
+ "default": "AlarmDecoder",
13
+ "required": true
14
+ },
15
+ "DSCorHoneywell": {
16
+ "title": "Panel Type",
17
+ "type": "string",
18
+ "enum": ["Honeywell", "DSC", "Interlogix"],
19
+ "default": "Honeywell",
20
+ "required": true
21
+ },
22
+ "port": {
23
+ "title": "Listener Port",
24
+ "description": "Port that Homebridge will listen on for push notifications from AlarmDecoder WebApp.",
25
+ "type": "integer",
26
+ "default": 8888,
27
+ "required": true
28
+ },
29
+ "stateURL": {
30
+ "title": "State URL",
31
+ "description": "URL to query alarm state (e.g. http://YOUR_IP:YOUR_PORT/api/v1/alarmdecoder).",
32
+ "type": "string",
33
+ "format": "uri",
34
+ "required": true
35
+ },
36
+ "zoneURL": {
37
+ "title": "Zone URL",
38
+ "description": "URL to query zone configuration (e.g. http://YOUR_IP:YOUR_PORT/api/v1/zones).",
39
+ "type": "string",
40
+ "format": "uri",
41
+ "required": true
42
+ },
43
+ "setURL": {
44
+ "title": "Set URL",
45
+ "description": "URL to send keypad commands (e.g. http://YOUR_IP:YOUR_PORT/api/v1/alarmdecoder/send).",
46
+ "type": "string",
47
+ "format": "uri",
48
+ "required": true
49
+ },
50
+ "setPIN": {
51
+ "title": "PIN",
52
+ "description": "Your alarm PIN (base PIN only, e.g. '1234' not '12342').",
53
+ "type": "string",
54
+ "required": true
55
+ },
56
+ "key": {
57
+ "title": "API Key",
58
+ "description": "API key from the AlarmDecoder WebApp (Honeywell/DSC only).",
59
+ "type": "string"
60
+ },
61
+ "enableNightMode": {
62
+ "title": "Enable Night Mode",
63
+ "description": "Show Night/Instant arm mode in HomeKit. Disable if your panel does not support it.",
64
+ "type": "boolean",
65
+ "default": true
66
+ },
67
+ "useSwitches": {
68
+ "title": "Extra Switches",
69
+ "description": "Create additional HomeKit switches for quick arming or special functions. Note: away/stay/night switches bypass the HomeKit security prompt.",
70
+ "type": "array",
71
+ "items": {
72
+ "title": "Switch",
73
+ "type": "string",
74
+ "enum": ["panic", "chime", "away", "stay", "night", "clear"]
75
+ }
76
+ },
77
+ "panicKey": {
78
+ "title": "Panic Key",
79
+ "description": "Keypad sequence to trigger panic (e.g. '<S1>'). Honeywell/DSC only.",
80
+ "type": "string"
81
+ },
82
+ "chimeKey": {
83
+ "title": "Chime Key",
84
+ "description": "Keypad key for chime toggle (e.g. '9'). Honeywell/DSC only.",
85
+ "type": "string"
86
+ },
87
+ "offKey": {
88
+ "title": "Off/Clear Key",
89
+ "description": "Keypad key appended to PIN for the clear command (default: '1').",
90
+ "type": "string",
91
+ "default": "1"
92
+ },
93
+ "DSCStay": {
94
+ "title": "DSC Stay Sequence",
95
+ "description": "DSC key sequence for Stay arm (e.g. '<F4>').",
96
+ "type": "string",
97
+ "condition": {
98
+ "functionBody": "return model.DSCorHoneywell === 'DSC';"
99
+ }
100
+ },
101
+ "DSCAway": {
102
+ "title": "DSC Away Sequence",
103
+ "description": "DSC key sequence for Away arm (e.g. '<S5>').",
104
+ "type": "string",
105
+ "condition": {
106
+ "functionBody": "return model.DSCorHoneywell === 'DSC';"
107
+ }
108
+ },
109
+ "DSCReset": {
110
+ "title": "DSC Reset Sequence",
111
+ "description": "DSC key sequence for Reset (e.g. '<S7>').",
112
+ "type": "string",
113
+ "condition": {
114
+ "functionBody": "return model.DSCorHoneywell === 'DSC';"
115
+ }
116
+ },
117
+ "DSCExit": {
118
+ "title": "DSC Exit Sequence",
119
+ "description": "DSC key sequence for Exit (e.g. '<S8>').",
120
+ "type": "string",
121
+ "condition": {
122
+ "functionBody": "return model.DSCorHoneywell === 'DSC';"
123
+ }
124
+ }
125
+ }
126
+ }
127
+ }
package/index.js ADDED
@@ -0,0 +1,333 @@
1
+ import http from 'http';
2
+ import createDebug from 'debug';
3
+ import * as alarms from './alarmsystems/index.js';
4
+
5
+ const debug = createDebug('alarmdecoder');
6
+
7
+ const PLATFORM_NAME = 'AlarmDecoderPlatform';
8
+ const PLUGIN_NAME = 'homebridge2-alarmdecoder-platform';
9
+
10
+ let Accessory, Service, Characteristic, UUIDGen;
11
+
12
+ export default (api) => {
13
+ Accessory = api.platformAccessory;
14
+ Service = api.hap.Service;
15
+ Characteristic = api.hap.Characteristic;
16
+ UUIDGen = api.hap.uuid;
17
+ api.registerPlatform(PLATFORM_NAME, AlarmdecoderPlatform);
18
+ };
19
+
20
+ class AlarmdecoderPlatform {
21
+ constructor(log, config, api) {
22
+ this.log = log;
23
+ this.port = config.port;
24
+ this.name = config.name;
25
+ this.switchAccessories = [];
26
+ this.alarmSystem = null;
27
+ this.createSwitch = config.useSwitches || [];
28
+ this.enableNightMode = config.enableNightMode !== undefined ? config.enableNightMode : true;
29
+ this.zoneAccessories = [];
30
+ this.api = api;
31
+
32
+ const platformType = config.DSCorHoneywell || config.platformType;
33
+
34
+ let rePlatformType = new RegExp('dsc|honeywell', 'i');
35
+ if (rePlatformType.exec(platformType))
36
+ this.alarmSystem = new alarms.HoneywellDSC(log, config);
37
+ rePlatformType = new RegExp('interlogix|ge|caddx', 'i');
38
+ if (rePlatformType.exec(platformType))
39
+ this.alarmSystem = new alarms.Interlogix(log, config);
40
+ if (!this.alarmSystem) {
41
+ this.log('no system specified, assuming Honeywell, please add DSCorHoneywell to your config.json');
42
+ this.alarmSystem = new alarms.HoneywellDSC(log, config);
43
+ }
44
+ debug('platform class in use: ' + this.alarmSystem.constructor.name);
45
+
46
+ this.api.on('didFinishLaunching', () => {
47
+ this.log('Cached Accessories Loaded');
48
+ this.initPlatform();
49
+ this.listener = http.createServer((req, res) => this.httpListener(req, res));
50
+ this.listener.listen(this.port);
51
+ this.log('listening on port ' + this.port);
52
+ });
53
+ }
54
+
55
+ configureAccessory(accessory) {
56
+ this.log(accessory.displayName, 'Configuring Accessory from Cache');
57
+ this.addAccessory(accessory, false);
58
+ }
59
+
60
+ addAccessory(accessory, publish) {
61
+ this.log('adding accessory ' + accessory.displayName);
62
+
63
+ accessory.onIdentify(() => {
64
+ this.log(accessory.displayName, 'Identify!!!');
65
+ });
66
+
67
+ if (accessory.getService(Service.ContactSensor)) {
68
+ accessory.getService(Service.ContactSensor)
69
+ .getCharacteristic(Characteristic.ContactSensorState)
70
+ .onGet(() => this.getZoneState(accessory.displayName));
71
+ this.zoneAccessories.push(accessory);
72
+ accessory.getService(Service.AccessoryInformation)
73
+ .setCharacteristic(Characteristic.Model, 'alarmdecoder contact sensor');
74
+ } else if (accessory.getService(Service.MotionSensor)) {
75
+ accessory.getService(Service.MotionSensor)
76
+ .getCharacteristic(Characteristic.MotionDetected)
77
+ .onGet(() => this.getZoneState(accessory.displayName));
78
+ this.zoneAccessories.push(accessory);
79
+ accessory.getService(Service.AccessoryInformation)
80
+ .setCharacteristic(Characteristic.Model, 'alarmdecoder motion sensor');
81
+ } else if (accessory.getService(Service.CarbonMonoxideSensor)) {
82
+ accessory.getService(Service.CarbonMonoxideSensor)
83
+ .getCharacteristic(Characteristic.CarbonMonoxideDetected)
84
+ .onGet(() => this.getZoneState(accessory.displayName));
85
+ this.zoneAccessories.push(accessory);
86
+ accessory.getService(Service.AccessoryInformation)
87
+ .setCharacteristic(Characteristic.Model, 'alarmdecoder carbon monoxide sensor');
88
+ } else if (accessory.getService(Service.SmokeSensor)) {
89
+ accessory.getService(Service.SmokeSensor)
90
+ .getCharacteristic(Characteristic.SmokeDetected)
91
+ .onGet(() => this.getZoneState(accessory.displayName));
92
+ this.zoneAccessories.push(accessory);
93
+ accessory.getService(Service.AccessoryInformation)
94
+ .setCharacteristic(Characteristic.Model, 'alarmdecoder smoke sensor');
95
+ } else if (accessory.getService(Service.SecuritySystem)) {
96
+ accessory.getService(Service.SecuritySystem)
97
+ .getCharacteristic(Characteristic.SecuritySystemCurrentState)
98
+ .setProps({ validValues: this.enableNightMode ? [0, 1, 2, 3, 4] : [0, 1, 3, 4] })
99
+ .onGet(() => this.getAlarmState());
100
+ accessory.getService(Service.SecuritySystem)
101
+ .getCharacteristic(Characteristic.SecuritySystemTargetState)
102
+ .setProps({ validValues: this.enableNightMode ? [0, 1, 2, 3] : [0, 1, 3] })
103
+ .onGet(() => this.getAlarmState())
104
+ .onSet(async (state) => {
105
+ await this.setAlarmtoState(state);
106
+ accessory.getService(Service.SecuritySystem)
107
+ .updateCharacteristic(Characteristic.SecuritySystemCurrentState, state);
108
+ });
109
+ accessory.getService(Service.AccessoryInformation)
110
+ .setCharacteristic(Characteristic.Model, 'alarmdecoder alarm system');
111
+ this.alarmSystem.accessory = accessory;
112
+ } else if (accessory.getService(Service.Switch)) {
113
+ accessory.getService(Service.Switch)
114
+ .getCharacteristic(Characteristic.On)
115
+ .onGet(() => this.getSwitchState(accessory.displayName))
116
+ .onSet((state) => this.setSwitchState(state, accessory.displayName));
117
+ accessory.getService(Service.AccessoryInformation)
118
+ .setCharacteristic(Characteristic.Model, 'alarmdecoder state switch');
119
+ this.switchAccessories.push(accessory);
120
+ }
121
+
122
+ accessory.getService(Service.AccessoryInformation)
123
+ .setCharacteristic(Characteristic.Name, accessory.displayName)
124
+ .setCharacteristic(Characteristic.Manufacturer, 'honeywell/dsc/interlogix');
125
+
126
+ if (publish) {
127
+ this.log('publishing platform accessory ' + accessory.displayName);
128
+ this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
129
+ }
130
+ return accessory;
131
+ }
132
+
133
+ async initPlatform() {
134
+ this.log('initializing platform');
135
+
136
+ if (!this.alarmSystem.accessory) {
137
+ this.log('adding security system accessory');
138
+ const uuid = UUIDGen.generate(this.name);
139
+ const newAccessory = new Accessory(this.name, uuid);
140
+ newAccessory.addService(Service.SecuritySystem, this.name);
141
+ this.addAccessory(newAccessory, true);
142
+ } else {
143
+ this.log('found security system from cache, skipping');
144
+ }
145
+
146
+ if (await this.alarmSystem.initZones()) {
147
+ for (let zone in this.zoneAccessories) {
148
+ const cachedZone = this.zoneAccessories[zone];
149
+ for (let adZone in this.alarmSystem.alarmZones) {
150
+ const tempZone = this.alarmSystem.alarmZones[adZone];
151
+ if (cachedZone.displayName === tempZone.zoneID + ' ' + tempZone.name) {
152
+ this.alarmSystem.alarmZones[adZone].accessory = cachedZone;
153
+ break;
154
+ }
155
+ }
156
+ }
157
+
158
+ for (let zone in this.alarmSystem.alarmZones) {
159
+ if (!this.alarmSystem.alarmZones[zone].accessory) {
160
+ const tempZone = this.alarmSystem.alarmZones[zone];
161
+ const uuid = UUIDGen.generate(tempZone.zoneID + ' ' + tempZone.name);
162
+ const newAccessory = new Accessory(tempZone.zoneID + ' ' + tempZone.name, uuid);
163
+ const reMotion = new RegExp('motion', 'i');
164
+ const reSmoke = new RegExp('smoke', 'i');
165
+ const reCarbon = new RegExp('carbon', 'i');
166
+ const zoneName = tempZone.zoneID + ' ' + tempZone.name;
167
+ if (reMotion.exec(zoneName))
168
+ newAccessory.addService(Service.MotionSensor, zoneName);
169
+ else if (reSmoke.exec(zoneName))
170
+ newAccessory.addService(Service.SmokeSensor, zoneName);
171
+ else if (reCarbon.exec(zoneName))
172
+ newAccessory.addService(Service.CarbonMonoxideSensor, zoneName);
173
+ else
174
+ newAccessory.addService(Service.ContactSensor, zoneName);
175
+ this.log(newAccessory);
176
+ this.alarmSystem.alarmZones[zone].accessory = newAccessory;
177
+ this.addAccessory(newAccessory, true);
178
+ } else {
179
+ this.log('found ' + this.alarmSystem.alarmZones[zone].accessory.displayName + ', from cache, skipping');
180
+ }
181
+ }
182
+ }
183
+
184
+ for (let foundSwitch in this.switchAccessories) {
185
+ this.log('found switch ' + this.switchAccessories[foundSwitch].displayName + ' from cache, skipping');
186
+ const idx = this.createSwitch.indexOf(this.switchAccessories[foundSwitch].displayName);
187
+ if (idx !== -1)
188
+ this.createSwitch.splice(idx, 1);
189
+ }
190
+
191
+ for (let switchType in this.createSwitch) {
192
+ debug('adding switch accessory ' + this.createSwitch[switchType]);
193
+ const uuid = UUIDGen.generate(this.createSwitch[switchType]);
194
+ const newAccessory = new Accessory(this.createSwitch[switchType], uuid);
195
+ newAccessory.addService(Service.Switch, this.createSwitch[switchType]);
196
+ this.addAccessory(newAccessory, true);
197
+ this.switchAccessories.push(newAccessory);
198
+ }
199
+
200
+ this._getStateFromAlarm(true);
201
+ }
202
+
203
+ httpListener(req, res) {
204
+ let data = '';
205
+ if (req.method === 'POST') {
206
+ req.on('data', (chunk) => { data += chunk; });
207
+ req.on('end', () => {
208
+ debug('Received notification and body data:');
209
+ debug(data.toString());
210
+ });
211
+ }
212
+ res.writeHead(200, { 'Content-Type': 'text/plain' });
213
+ res.end();
214
+ debug('Getting current state since ping received');
215
+ this._getStateFromAlarm(true);
216
+ }
217
+
218
+ async _getStateFromAlarm(report = false) {
219
+ try {
220
+ await this.alarmSystem.getAlarmState();
221
+ } catch (e) {
222
+ this.log(e);
223
+ return false;
224
+ }
225
+
226
+ if (report) {
227
+ this.alarmSystem.accessory.getService(Service.SecuritySystem)
228
+ .updateCharacteristic(Characteristic.SecuritySystemCurrentState, this.alarmSystem.state);
229
+ this.alarmSystem.accessory.getService(Service.SecuritySystem)
230
+ .updateCharacteristic(Characteristic.SecuritySystemTargetState, this.alarmSystem.state);
231
+
232
+ let switchToSet = null;
233
+ switch (this.alarmSystem.state) {
234
+ case 0: switchToSet = 'stay'; break;
235
+ case 1: switchToSet = 'away'; break;
236
+ case 2: switchToSet = 'night'; break;
237
+ case 4: switchToSet = 'panic'; break;
238
+ }
239
+ for (let toggle in this.switchAccessories)
240
+ this.switchAccessories[toggle].getService(Service.Switch)
241
+ .updateCharacteristic(Characteristic.On,
242
+ this.switchAccessories[toggle].displayName === switchToSet);
243
+
244
+ for (let alarmZone in this.alarmSystem.alarmZones) {
245
+ alarmZone = this.alarmSystem.alarmZones[alarmZone];
246
+ if (alarmZone.accessory.getService(Service.MotionSensor)) {
247
+ alarmZone.accessory.getService(Service.MotionSensor)
248
+ .updateCharacteristic(Characteristic.MotionDetected, alarmZone.faulted);
249
+ } else if (alarmZone.accessory.getService(Service.ContactSensor)) {
250
+ alarmZone.accessory.getService(Service.ContactSensor)
251
+ .updateCharacteristic(Characteristic.ContactSensorState, alarmZone.faulted ? 1 : 0);
252
+ } else if (alarmZone.accessory.getService(Service.CarbonMonoxideSensor)) {
253
+ alarmZone.accessory.getService(Service.CarbonMonoxideSensor)
254
+ .updateCharacteristic(Characteristic.CarbonMonoxideDetected, alarmZone.faulted ? 1 : 0);
255
+ } else if (alarmZone.accessory.getService(Service.SmokeSensor)) {
256
+ alarmZone.accessory.getService(Service.SmokeSensor)
257
+ .updateCharacteristic(Characteristic.SmokeDetected, alarmZone.faulted ? 1 : 0);
258
+ }
259
+ }
260
+ }
261
+
262
+ return true;
263
+ }
264
+
265
+ async getZoneState(displayName) {
266
+ debug('getting state for Zone: ' + displayName);
267
+ await this._getStateFromAlarm(false);
268
+ for (let alarmZone in this.alarmSystem.alarmZones) {
269
+ alarmZone = this.alarmSystem.alarmZones[alarmZone];
270
+ if ((alarmZone.zoneID + ' ' + alarmZone.name) === displayName) {
271
+ if (alarmZone.accessory.getService(Service.MotionSensor))
272
+ return alarmZone.faulted;
273
+ return alarmZone.faulted ? 1 : 0;
274
+ }
275
+ }
276
+ debug('zone ' + displayName + ' not found');
277
+ throw new Error('no zone found: ' + displayName);
278
+ }
279
+
280
+ async getAlarmState() {
281
+ debug('getting state for Alarm: ' + this.name);
282
+ if (await this._getStateFromAlarm(false) && this.alarmSystem.state >= 0)
283
+ return this.alarmSystem.state;
284
+ throw new Error('get state failed or null');
285
+ }
286
+
287
+ async getSwitchState(switchType) {
288
+ debug('getting state for Switch: ' + switchType);
289
+ await this._getStateFromAlarm(false);
290
+ /* 0 = stay, 1 = away, 2 = night, 3 = disarmed, 4 = alarm */
291
+ if (switchType === 'panic' && this.alarmSystem.state === 4) return true;
292
+ if (switchType === 'stay' && this.alarmSystem.state === 0) return true;
293
+ if (switchType === 'away' && this.alarmSystem.state === 1) return true;
294
+ if (switchType === 'night' && this.alarmSystem.state === 2) return true;
295
+ return false;
296
+ }
297
+
298
+ async setSwitchState(state, switchType) {
299
+ debug('setting switch ' + switchType + ' to ' + state);
300
+ if (!state) {
301
+ if (switchType === 'chime' || switchType === 'clear') return;
302
+ await this.setAlarmtoState(Characteristic.SecuritySystemTargetState.DISARM);
303
+ } else {
304
+ if (switchType === 'panic')
305
+ await this.setAlarmtoState(4);
306
+ else if (switchType === 'away')
307
+ await this.setAlarmtoState(Characteristic.SecuritySystemTargetState.AWAY_ARM);
308
+ else if (switchType === 'night')
309
+ await this.setAlarmtoState(Characteristic.SecuritySystemTargetState.NIGHT_ARM);
310
+ else if (switchType === 'stay')
311
+ await this.setAlarmtoState(Characteristic.SecuritySystemTargetState.STAY_ARM);
312
+ else if (switchType === 'chime')
313
+ await this.setAlarmtoState('chime');
314
+ else if (switchType === 'clear') {
315
+ await this.setAlarmtoState('clear');
316
+ setTimeout(() => {
317
+ const clearSwitch = this.switchAccessories.find(s => s.displayName === 'clear');
318
+ if (clearSwitch)
319
+ clearSwitch.getService(Service.Switch)
320
+ .updateCharacteristic(Characteristic.On, false);
321
+ }, 1000);
322
+ } else {
323
+ throw new Error('invalid switch type: ' + switchType);
324
+ }
325
+ }
326
+ }
327
+
328
+ async setAlarmtoState(state) {
329
+ debug('setting alarm state to ' + state);
330
+ if (!await this.alarmSystem.setAlarmState(state))
331
+ throw new Error('set alarm state failed');
332
+ }
333
+ }
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "homebridge2-alarmdecoder-platform",
3
+ "version": "1.0.0-beta.1",
4
+ "description": "Homebridge 2.0 dynamic platform plugin for AlarmDecoder (Honeywell/DSC and Interlogix/GE/Caddx alarm panels).",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "index.js",
8
+ "keywords": [
9
+ "homebridge-plugin",
10
+ "homebridge",
11
+ "alarmdecoder",
12
+ "homekit",
13
+ "honeywell",
14
+ "dsc",
15
+ "ademco",
16
+ "interlogix",
17
+ "ge",
18
+ "caddx",
19
+ "networkX"
20
+ ],
21
+ "engines": {
22
+ "node": ">=22.0.0",
23
+ "homebridge": ">=1.8.0"
24
+ },
25
+ "peerDependencies": {
26
+ "homebridge": ">=1.8.0"
27
+ },
28
+ "devDependencies": {
29
+ "homebridge": "^2.0.0"
30
+ },
31
+ "dependencies": {
32
+ "axios": "^1.7.0",
33
+ "debug": "^4.3.0"
34
+ },
35
+ "author": "Shaun Baker",
36
+ "contributors": [
37
+ "pabfou"
38
+ ],
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/pabfou/homebridge2-alarmdecoder-platform.git"
42
+ },
43
+ "bugs": {
44
+ "url": "https://github.com/pabfou/homebridge2-alarmdecoder-platform/issues"
45
+ },
46
+ "homepage": "https://github.com/pabfou/homebridge2-alarmdecoder-platform#readme",
47
+ "scripts": {
48
+ "test": "echo \"No tests specified\" && exit 0"
49
+ }
50
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "bridge": {
3
+ "name": "Homebridge",
4
+ "username": "CC:22:3D:E3:CE:31",
5
+ "port": 51826,
6
+ "pin": "031-45-154"
7
+ },
8
+
9
+ "description": "This is an example configuration file for the alarmdecoder-platform.",
10
+
11
+ "platforms": [
12
+ {
13
+ "platform" : "alarmdecoder-platform",
14
+ "name" : "Alarm System",
15
+ "port" : "8888",
16
+ "key" : "3ZZHVUAAHV3A",
17
+ "stateURL" : "http://localhost:2222/api/v1/alarmdecoder",
18
+ "zoneURL" : "http://localhost:2222/api/v1/zones",
19
+ "setURL" : "http://localhost:2222/api/v1/alarmdecoder/send",
20
+ "setPIN" : "1245",
21
+ "panicKey" : "<S1>",
22
+ "useSwitches" : ["panic","chime","away","stay","night","clear"],
23
+ "DSCorHoneywell" : "DSC",
24
+ "chimeKey":"9",
25
+ "offKey":"1",
26
+ "enableNightMode": true,
27
+ "DSCStay" : "<F4>",
28
+ "DSCAway" : "<S5>",
29
+ "DSCReset" : "<S7>",
30
+ "DSCExit" : "<S8>"
31
+ }
32
+ ]
33
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "bridge": {
3
+ "name": "Homebridge",
4
+ "username": "CC:22:3D:E3:CE:31",
5
+ "port": 51826,
6
+ "pin": "031-45-154"
7
+ },
8
+
9
+ "description": "This is an example configuration file for the alarmdecoder-platform.",
10
+
11
+ "platforms": [
12
+ {
13
+ "platform" : "alarmdecoder-platform",
14
+ "name" : "Alarm System",
15
+ "port" : "8888",
16
+ "key" : "3ZZHVUAAHV3A",
17
+ "stateURL" : "http://localhost:2222/api/v1/alarmdecoder",
18
+ "zoneURL" : "http://localhost:2222/api/v1/zones",
19
+ "setURL" : "http://localhost:2222/api/v1/alarmdecoder/send",
20
+ "setPIN" : "1245",
21
+ "panicKey" : "<S1>",
22
+ "useSwitches" : ["panic","chime","away","stay","night","clear"],
23
+ "DSCorHoneywell" : "Honeywell",
24
+ "chimeKey":"9",
25
+ "offKey":"1",
26
+ "enableNightMode": true
27
+ }
28
+ ]
29
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "bridge": {
3
+ "name": "Homebridge",
4
+ "username": "CC:22:3D:E3:CE:31",
5
+ "port": 51826,
6
+ "pin": "031-45-154"
7
+ },
8
+
9
+ "description": "This is an example configuration file for the alarmdecoder-platform.",
10
+
11
+ "platforms": [
12
+ {
13
+ "platform" : "alarmdecoder-platform",
14
+ "name" : "Alarm System",
15
+ "port" : "8080",
16
+ "stateURL" : "http://localhost:5007/partitions",
17
+ "zoneURL" : "http://localhost:5007/zones",
18
+ "setURL" : "http://localhost:5007/command",
19
+ "setPIN" : "1245",
20
+ "useSwitches" : ["away","stay","night","clear"],
21
+ "DSCorHoneywell" : "Interlogix",
22
+ "offKey":"1",
23
+ "enableNightMode": true
24
+ }
25
+ ]
26
+ }