homebridge-adt-pulse 2.2.0 → 3.0.0-beta.2
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/LICENSE +1 -1
- package/README.md +13 -13
- package/package.json +38 -17
- package/src/index.ts +18 -0
- package/src/lib/accessory.ts +405 -0
- package/src/lib/api.ts +3483 -0
- package/src/lib/detect.ts +728 -0
- package/src/lib/platform.ts +890 -0
- package/src/lib/regex.ts +167 -0
- package/src/lib/schema.ts +34 -0
- package/src/lib/utility.ts +933 -0
- package/src/scripts/repl.ts +300 -0
- package/src/scripts/test-api.ts +278 -0
- package/src/types/constant.d.ts +308 -0
- package/src/types/index.d.ts +1472 -0
- package/src/types/shared.d.ts +517 -0
- package/api-test.js +0 -280
- package/api.js +0 -878
- package/index.js +0 -1312
package/api-test.js
DELETED
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ADT Pulse Test.
|
|
3
|
-
*
|
|
4
|
-
* Test the ADT Pulse API responses using this script.
|
|
5
|
-
*
|
|
6
|
-
* Arguments:
|
|
7
|
-
* --username email@email.com
|
|
8
|
-
* --password 1234567890
|
|
9
|
-
* --fingerprint 2-factor authentication token
|
|
10
|
-
* --country "us" or "ca"
|
|
11
|
-
* --action "device-information", "device-status", "zone-status", "sync", "disarm", "arm-away", "arm-stay", or "arm-night"
|
|
12
|
-
* --overrideSensorName Sensor name as shown in ADT Pulse
|
|
13
|
-
* --overrideSensorType "sensor,glass", "sensor,motion", "sensor,co", "sensor,fire", or "sensor,doorWindow"
|
|
14
|
-
*
|
|
15
|
-
* Usage:
|
|
16
|
-
* node api-test --username ! --password % --fingerprint ^ --country # --action @ --overrideSensorName $ --overrideSensorType ~
|
|
17
|
-
*
|
|
18
|
-
* Replace:
|
|
19
|
-
* ! - Account username
|
|
20
|
-
* % - Account password
|
|
21
|
-
* ^ - Fingerprint
|
|
22
|
-
* # - Country
|
|
23
|
-
* @ - Action type
|
|
24
|
-
* $ - Override sensor name (optional)
|
|
25
|
-
* ~ - Override sensor type (optional)
|
|
26
|
-
*
|
|
27
|
-
* @type {function(object): void}
|
|
28
|
-
*
|
|
29
|
-
* @since 1.0.0
|
|
30
|
-
*/
|
|
31
|
-
const Pulse = require('./api');
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Script arguments.
|
|
35
|
-
*
|
|
36
|
-
* @since 1.0.0
|
|
37
|
-
*/
|
|
38
|
-
const username = process.argv.indexOf('--username');
|
|
39
|
-
const usernameValue = (username > -1) ? process.argv[username + 1] : '';
|
|
40
|
-
|
|
41
|
-
const password = process.argv.indexOf('--password');
|
|
42
|
-
const passwordValue = (password > -1) ? process.argv[password + 1] : '';
|
|
43
|
-
|
|
44
|
-
const fingerprint = process.argv.indexOf('--fingerprint');
|
|
45
|
-
const fingerprintValue = (fingerprint > -1) ? process.argv[fingerprint + 1] : '';
|
|
46
|
-
|
|
47
|
-
const country = process.argv.indexOf('--country');
|
|
48
|
-
const countryValue = (country > -1) ? process.argv[country + 1] : '';
|
|
49
|
-
|
|
50
|
-
const action = process.argv.indexOf('--action');
|
|
51
|
-
const actionValue = (action > -1) ? process.argv[action + 1] : '';
|
|
52
|
-
|
|
53
|
-
const overrideSensorName = process.argv.indexOf('--overrideSensorName');
|
|
54
|
-
const overrideSensorNameValue = (overrideSensorName > -1) ? process.argv[overrideSensorName + 1] : '';
|
|
55
|
-
|
|
56
|
-
const overrideSensorType = process.argv.indexOf('--overrideSensorType');
|
|
57
|
-
const overrideSensorTypeValue = (overrideSensorType > -1) ? process.argv[overrideSensorType + 1] : '';
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Sanitize arguments.
|
|
61
|
-
*
|
|
62
|
-
* @since 1.0.0
|
|
63
|
-
*/
|
|
64
|
-
if (!usernameValue || !passwordValue || !fingerprintValue || !countryValue || !actionValue) {
|
|
65
|
-
if (!usernameValue) {
|
|
66
|
-
console.error('ADT Pulse Test: Username is empty.');
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (!passwordValue) {
|
|
70
|
-
console.error('ADT Pulse Test: Password is empty.');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!fingerprintValue) {
|
|
74
|
-
console.error('ADT Pulse Test: Fingerprint is empty.');
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (!countryValue) {
|
|
78
|
-
console.error('ADT Pulse Test: Country is empty.');
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (!actionValue) {
|
|
82
|
-
console.error('ADT Pulse Test: Action is empty.');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
process.exit(1);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Initialize main script.
|
|
90
|
-
*
|
|
91
|
-
* @type {Pulse}
|
|
92
|
-
*
|
|
93
|
-
* @since 1.0.0
|
|
94
|
-
*/
|
|
95
|
-
const pulse = new Pulse({
|
|
96
|
-
username: usernameValue,
|
|
97
|
-
password: passwordValue,
|
|
98
|
-
fingerprint: fingerprintValue,
|
|
99
|
-
overrideSensors: (overrideSensorNameValue && overrideSensorTypeValue) ? [{
|
|
100
|
-
name: overrideSensorNameValue,
|
|
101
|
-
type: overrideSensorTypeValue,
|
|
102
|
-
}] : [],
|
|
103
|
-
country: countryValue,
|
|
104
|
-
debug: true,
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Actions.
|
|
109
|
-
*
|
|
110
|
-
* @since 1.0.0
|
|
111
|
-
*/
|
|
112
|
-
switch (actionValue) {
|
|
113
|
-
case 'device-information':
|
|
114
|
-
console.log('ADT Pulse Test: Getting device information...');
|
|
115
|
-
|
|
116
|
-
pulse
|
|
117
|
-
.login()
|
|
118
|
-
.then((login) => console.log(login))
|
|
119
|
-
.then(() => pulse.getDeviceInformation())
|
|
120
|
-
.then((information) => console.log(information))
|
|
121
|
-
.then(() => pulse.logout())
|
|
122
|
-
.then((logout) => console.log(logout))
|
|
123
|
-
.catch((error) => console.error(error));
|
|
124
|
-
break;
|
|
125
|
-
case 'device-status':
|
|
126
|
-
console.log('ADT Pulse Test: Getting device status...');
|
|
127
|
-
|
|
128
|
-
pulse
|
|
129
|
-
.login()
|
|
130
|
-
.then((login) => console.log(login))
|
|
131
|
-
.then(() => pulse.getDeviceStatus())
|
|
132
|
-
.then((status) => console.log(status))
|
|
133
|
-
.then(() => pulse.logout())
|
|
134
|
-
.then((logout) => console.log(logout))
|
|
135
|
-
.catch((error) => console.error(error));
|
|
136
|
-
break;
|
|
137
|
-
case 'zone-status':
|
|
138
|
-
console.log('ADT Pulse Test: Getting zone status...');
|
|
139
|
-
|
|
140
|
-
pulse
|
|
141
|
-
.login()
|
|
142
|
-
.then((login) => console.log(login))
|
|
143
|
-
.then(() => pulse.getZoneStatus())
|
|
144
|
-
.then((statuses) => console.log(statuses))
|
|
145
|
-
.then(() => pulse.logout())
|
|
146
|
-
.then((logout) => console.log(logout))
|
|
147
|
-
.catch((error) => console.error(error));
|
|
148
|
-
break;
|
|
149
|
-
case 'sync':
|
|
150
|
-
console.log('ADT Pulse Test: Performing portal sync...');
|
|
151
|
-
|
|
152
|
-
pulse
|
|
153
|
-
.login()
|
|
154
|
-
.then((login) => console.log(login))
|
|
155
|
-
.then(() => pulse.performPortalSync())
|
|
156
|
-
.then((syncCode) => console.log(syncCode))
|
|
157
|
-
.then(() => pulse.logout())
|
|
158
|
-
.then((logout) => console.log(logout))
|
|
159
|
-
.catch((error) => console.error(error));
|
|
160
|
-
break;
|
|
161
|
-
case 'disarm':
|
|
162
|
-
console.log('ADT Pulse Test: Disarming...');
|
|
163
|
-
|
|
164
|
-
pulse
|
|
165
|
-
.login()
|
|
166
|
-
.then((login) => console.log(login))
|
|
167
|
-
.then(() => pulse.getDeviceStatus())
|
|
168
|
-
.then((status) => console.log(status))
|
|
169
|
-
.then(async () => {
|
|
170
|
-
/**
|
|
171
|
-
* setDeviceStatus function may fail because a wrong armState was set.
|
|
172
|
-
*/
|
|
173
|
-
await pulse
|
|
174
|
-
.setDeviceStatus('away', 'off')
|
|
175
|
-
.then((response) => console.log(response))
|
|
176
|
-
.catch((error) => console.error(error));
|
|
177
|
-
})
|
|
178
|
-
.then(() => {
|
|
179
|
-
setTimeout(() => {
|
|
180
|
-
pulse
|
|
181
|
-
.getDeviceStatus()
|
|
182
|
-
.then((status) => console.log(status))
|
|
183
|
-
.then(() => pulse.logout())
|
|
184
|
-
.then((logout) => console.log(logout))
|
|
185
|
-
.catch((error) => console.error(error));
|
|
186
|
-
}, 1000);
|
|
187
|
-
})
|
|
188
|
-
.catch((error) => console.error(error));
|
|
189
|
-
break;
|
|
190
|
-
case 'arm-away':
|
|
191
|
-
console.log('ADT Pulse Test: Arming away...');
|
|
192
|
-
|
|
193
|
-
pulse
|
|
194
|
-
.login()
|
|
195
|
-
.then((login) => console.log(login))
|
|
196
|
-
.then(() => pulse.getDeviceStatus())
|
|
197
|
-
.then((status) => console.log(status))
|
|
198
|
-
.then(async () => {
|
|
199
|
-
/**
|
|
200
|
-
* setDeviceStatus function may fail because a wrong armState was set.
|
|
201
|
-
*/
|
|
202
|
-
await pulse
|
|
203
|
-
.setDeviceStatus('disarmed', 'away')
|
|
204
|
-
.then((response) => console.log(response))
|
|
205
|
-
.catch((error) => console.error(error));
|
|
206
|
-
})
|
|
207
|
-
.then(() => {
|
|
208
|
-
setTimeout(() => {
|
|
209
|
-
pulse
|
|
210
|
-
.getDeviceStatus()
|
|
211
|
-
.then((status) => console.log(status))
|
|
212
|
-
.then(() => pulse.logout())
|
|
213
|
-
.then((logout) => console.log(logout))
|
|
214
|
-
.catch((error) => console.error(error));
|
|
215
|
-
}, 1000);
|
|
216
|
-
})
|
|
217
|
-
.catch((error) => console.error(error));
|
|
218
|
-
break;
|
|
219
|
-
case 'arm-stay':
|
|
220
|
-
console.log('ADT Pulse Test: Arming stay...');
|
|
221
|
-
|
|
222
|
-
pulse
|
|
223
|
-
.login()
|
|
224
|
-
.then((login) => console.log(login))
|
|
225
|
-
.then(() => pulse.getDeviceStatus())
|
|
226
|
-
.then((status) => console.log(status))
|
|
227
|
-
.then(async () => {
|
|
228
|
-
/**
|
|
229
|
-
* setDeviceStatus function may fail because a wrong armState was set.
|
|
230
|
-
*/
|
|
231
|
-
await pulse
|
|
232
|
-
.setDeviceStatus('disarmed', 'stay')
|
|
233
|
-
.then((response) => console.log(response))
|
|
234
|
-
.catch((error) => console.error(error));
|
|
235
|
-
})
|
|
236
|
-
.then(() => {
|
|
237
|
-
setTimeout(() => {
|
|
238
|
-
pulse
|
|
239
|
-
.getDeviceStatus()
|
|
240
|
-
.then((status) => console.log(status))
|
|
241
|
-
.then(() => pulse.logout())
|
|
242
|
-
.then((logout) => console.log(logout))
|
|
243
|
-
.catch((error) => console.error(error));
|
|
244
|
-
}, 1000);
|
|
245
|
-
})
|
|
246
|
-
.catch((error) => console.error(error));
|
|
247
|
-
break;
|
|
248
|
-
case 'arm-night':
|
|
249
|
-
console.log('ADT Pulse Test: Arming night...');
|
|
250
|
-
|
|
251
|
-
pulse
|
|
252
|
-
.login()
|
|
253
|
-
.then((login) => console.log(login))
|
|
254
|
-
.then(() => pulse.getDeviceStatus())
|
|
255
|
-
.then((status) => console.log(status))
|
|
256
|
-
.then(async () => {
|
|
257
|
-
/**
|
|
258
|
-
* setDeviceStatus function may fail because a wrong armState was set.
|
|
259
|
-
*/
|
|
260
|
-
await pulse
|
|
261
|
-
.setDeviceStatus('disarmed', 'night')
|
|
262
|
-
.then((response) => console.log(response))
|
|
263
|
-
.catch((error) => console.error(error));
|
|
264
|
-
})
|
|
265
|
-
.then(() => {
|
|
266
|
-
setTimeout(() => {
|
|
267
|
-
pulse
|
|
268
|
-
.getDeviceStatus()
|
|
269
|
-
.then((status) => console.log(status))
|
|
270
|
-
.then(() => pulse.logout())
|
|
271
|
-
.then((logout) => console.log(logout))
|
|
272
|
-
.catch((error) => console.error(error));
|
|
273
|
-
}, 1000);
|
|
274
|
-
})
|
|
275
|
-
.catch((error) => console.error(error));
|
|
276
|
-
break;
|
|
277
|
-
default:
|
|
278
|
-
console.error(`ADT Pulse Test: Unknown action type ${actionValue}.`);
|
|
279
|
-
break;
|
|
280
|
-
}
|