homebridge-adt-pulse 3.0.0-beta.4 → 3.0.0-beta.6
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/README.md +7 -8
- package/build/config.schema.json +308 -0
- package/build/src/index.js +6 -0
- package/build/src/index.js.map +1 -0
- package/build/src/lib/accessory.js +216 -0
- package/build/src/lib/accessory.js.map +1 -0
- package/build/src/lib/api.js +1876 -0
- package/build/src/lib/api.js.map +1 -0
- package/build/src/lib/detect.js +443 -0
- package/build/src/lib/detect.js.map +1 -0
- package/build/src/lib/platform.js +446 -0
- package/build/src/lib/platform.js.map +1 -0
- package/{src/lib/regex.ts → build/src/lib/regex.js} +1 -143
- package/build/src/lib/regex.js.map +1 -0
- package/build/src/lib/schema.js +38 -0
- package/build/src/lib/schema.js.map +1 -0
- package/build/src/lib/utility.js +434 -0
- package/build/src/lib/utility.js.map +1 -0
- package/build/src/scripts/repl.js +173 -0
- package/build/src/scripts/repl.js.map +1 -0
- package/build/src/scripts/test-api.js +171 -0
- package/build/src/scripts/test-api.js.map +1 -0
- package/config.schema.json +289 -218
- package/package.json +5 -6
- package/src/index.ts +0 -18
- package/src/lib/accessory.ts +0 -405
- package/src/lib/api.ts +0 -3483
- package/src/lib/detect.ts +0 -728
- package/src/lib/platform.ts +0 -890
- package/src/lib/schema.ts +0 -34
- package/src/lib/utility.ts +0 -933
- package/src/scripts/repl.ts +0 -300
- package/src/scripts/test-api.ts +0 -278
- package/src/types/constant.d.ts +0 -308
- package/src/types/index.d.ts +0 -1472
- package/src/types/shared.d.ts +0 -517
- package/tsconfig.json +0 -32
package/src/lib/detect.ts
DELETED
|
@@ -1,728 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import { env } from 'node:process';
|
|
4
|
-
import { serializeError } from 'serialize-error';
|
|
5
|
-
|
|
6
|
-
import { debugLog, removePersonalIdentifiableInformation, stackTracer } from '@/lib/utility.js';
|
|
7
|
-
import type {
|
|
8
|
-
DetectedNewDoSubmitHandlersDebugMode,
|
|
9
|
-
DetectedNewDoSubmitHandlersHandlers,
|
|
10
|
-
DetectedNewDoSubmitHandlersKnownRelativeUrls,
|
|
11
|
-
DetectedNewDoSubmitHandlersKnownRelativeUrlsVersion,
|
|
12
|
-
DetectedNewDoSubmitHandlersKnownUrlParamsArm,
|
|
13
|
-
DetectedNewDoSubmitHandlersKnownUrlParamsArmState,
|
|
14
|
-
DetectedNewDoSubmitHandlersKnownUrlParamsHref,
|
|
15
|
-
DetectedNewDoSubmitHandlersLogger,
|
|
16
|
-
DetectedNewDoSubmitHandlersReturns,
|
|
17
|
-
DetectedNewGatewayInformationDebugMode,
|
|
18
|
-
DetectedNewGatewayInformationDevice,
|
|
19
|
-
DetectedNewGatewayInformationKnownStatuses,
|
|
20
|
-
DetectedNewGatewayInformationLogger,
|
|
21
|
-
DetectedNewGatewayInformationReturns,
|
|
22
|
-
DetectedNewOrbSecurityButtonsButtons,
|
|
23
|
-
DetectedNewOrbSecurityButtonsDebugMode,
|
|
24
|
-
DetectedNewOrbSecurityButtonsKnownButtonText,
|
|
25
|
-
DetectedNewOrbSecurityButtonsKnownLoadingText,
|
|
26
|
-
DetectedNewOrbSecurityButtonsKnownRelativeUrl,
|
|
27
|
-
DetectedNewOrbSecurityButtonsKnownUrlParamsArm,
|
|
28
|
-
DetectedNewOrbSecurityButtonsKnownUrlParamsArmState,
|
|
29
|
-
DetectedNewOrbSecurityButtonsKnownUrlParamsHref,
|
|
30
|
-
DetectedNewOrbSecurityButtonsLogger,
|
|
31
|
-
DetectedNewOrbSecurityButtonsReturns,
|
|
32
|
-
DetectedNewPanelInformationDebugMode,
|
|
33
|
-
DetectedNewPanelInformationDevice,
|
|
34
|
-
DetectedNewPanelInformationKnownStatuses,
|
|
35
|
-
DetectedNewPanelInformationLogger,
|
|
36
|
-
DetectedNewPanelInformationReturns,
|
|
37
|
-
DetectedNewPanelStatusDebugMode,
|
|
38
|
-
DetectedNewPanelStatusKnownStates,
|
|
39
|
-
DetectedNewPanelStatusKnownStatuses,
|
|
40
|
-
DetectedNewPanelStatusKnownStatusesSensorsOpen,
|
|
41
|
-
DetectedNewPanelStatusLogger,
|
|
42
|
-
DetectedNewPanelStatusReturns,
|
|
43
|
-
DetectedNewPanelStatusSummary,
|
|
44
|
-
DetectedNewPortalVersionDebugMode,
|
|
45
|
-
DetectedNewPortalVersionKnownVersions,
|
|
46
|
-
DetectedNewPortalVersionLogger,
|
|
47
|
-
DetectedNewPortalVersionReturns,
|
|
48
|
-
DetectedNewPortalVersionVersion,
|
|
49
|
-
DetectedNewSensorsInformationDebugMode,
|
|
50
|
-
DetectedNewSensorsInformationKnownDeviceTypes,
|
|
51
|
-
DetectedNewSensorsInformationKnownStatuses,
|
|
52
|
-
DetectedNewSensorsInformationLogger,
|
|
53
|
-
DetectedNewSensorsInformationReturns,
|
|
54
|
-
DetectedNewSensorsInformationSensors,
|
|
55
|
-
DetectedNewSensorsStatusDebugMode,
|
|
56
|
-
DetectedNewSensorsStatusKnownIcons,
|
|
57
|
-
DetectedNewSensorsStatusKnownStatuses,
|
|
58
|
-
DetectedNewSensorsStatusLogger,
|
|
59
|
-
DetectedNewSensorsStatusReturns,
|
|
60
|
-
DetectedNewSensorsStatusSensors,
|
|
61
|
-
} from '@/types/index.d.ts';
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Detected do submit handlers.
|
|
65
|
-
*
|
|
66
|
-
* @param {DetectedNewDoSubmitHandlersHandlers} handlers - Handlers.
|
|
67
|
-
* @param {DetectedNewDoSubmitHandlersLogger} logger - Logger.
|
|
68
|
-
* @param {DetectedNewDoSubmitHandlersDebugMode} debugMode - Debug mode.
|
|
69
|
-
*
|
|
70
|
-
* @returns {DetectedNewDoSubmitHandlersReturns}
|
|
71
|
-
*
|
|
72
|
-
* @since 1.0.0
|
|
73
|
-
*/
|
|
74
|
-
export async function detectedNewDoSubmitHandlers(handlers: DetectedNewDoSubmitHandlersHandlers, logger: DetectedNewDoSubmitHandlersLogger, debugMode: DetectedNewDoSubmitHandlersDebugMode): DetectedNewDoSubmitHandlersReturns {
|
|
75
|
-
const knownRelativeUrls: DetectedNewDoSubmitHandlersKnownRelativeUrls = [
|
|
76
|
-
'16.0.0-131',
|
|
77
|
-
'17.0.0-69',
|
|
78
|
-
'18.0.0-78',
|
|
79
|
-
'19.0.0-89',
|
|
80
|
-
'20.0.0-221',
|
|
81
|
-
'20.0.0-244',
|
|
82
|
-
'21.0.0-344',
|
|
83
|
-
'21.0.0-353',
|
|
84
|
-
'21.0.0-354',
|
|
85
|
-
'22.0.0-233',
|
|
86
|
-
'23.0.0-99',
|
|
87
|
-
'24.0.0-117',
|
|
88
|
-
'25.0.0-21',
|
|
89
|
-
'26.0.0-32',
|
|
90
|
-
'27.0.0-140',
|
|
91
|
-
].map((version) => `/myhome/${version}/quickcontrol/serv/RunRRACommand` as DetectedNewDoSubmitHandlersKnownRelativeUrlsVersion);
|
|
92
|
-
const knownUrlParamsArm: DetectedNewDoSubmitHandlersKnownUrlParamsArm = [
|
|
93
|
-
'away',
|
|
94
|
-
'night',
|
|
95
|
-
'stay',
|
|
96
|
-
];
|
|
97
|
-
const knownUrlParamsArmState: DetectedNewDoSubmitHandlersKnownUrlParamsArmState = [
|
|
98
|
-
'forcearm',
|
|
99
|
-
];
|
|
100
|
-
const knownUrlParamsHref: DetectedNewDoSubmitHandlersKnownUrlParamsHref = [
|
|
101
|
-
'rest/adt/ui/client/security/setForceArm',
|
|
102
|
-
'rest/adt/ui/client/security/setCancelProtest',
|
|
103
|
-
];
|
|
104
|
-
|
|
105
|
-
// Compare with data above.
|
|
106
|
-
const detectedNewHandlers = handlers.filter((handler) => (
|
|
107
|
-
!knownRelativeUrls.includes(handler.relativeUrl)
|
|
108
|
-
|| (
|
|
109
|
-
handler.urlParams.arm !== null
|
|
110
|
-
&& !knownUrlParamsArm.includes(handler.urlParams.arm)
|
|
111
|
-
)
|
|
112
|
-
|| (
|
|
113
|
-
handler.urlParams.armState !== null
|
|
114
|
-
&& !knownUrlParamsArmState.includes(handler.urlParams.armState)
|
|
115
|
-
)
|
|
116
|
-
|| !knownUrlParamsHref.includes(handler.urlParams.href)
|
|
117
|
-
));
|
|
118
|
-
|
|
119
|
-
if (detectedNewHandlers.length > 0) {
|
|
120
|
-
const cleanedData = removePersonalIdentifiableInformation(detectedNewHandlers);
|
|
121
|
-
|
|
122
|
-
if (logger !== null) {
|
|
123
|
-
logger.warn('Plugin has detected new do submit handlers. Notifying plugin author about this discovery ...');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// This is intentionally duplicated if using Homebridge debug mode.
|
|
127
|
-
if (debugMode) {
|
|
128
|
-
debugLog(logger, 'detect.ts / detectedNewDoSubmitHandlers()', 'warn', 'Plugin has detected new do submit handlers. Notifying plugin author about this discovery');
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Show content being sent to author.
|
|
132
|
-
stackTracer('detect-content', cleanedData);
|
|
133
|
-
|
|
134
|
-
try {
|
|
135
|
-
await axios.post(
|
|
136
|
-
'https://9wv5o73w.ntfy.mrjackyliang.com',
|
|
137
|
-
JSON.stringify({
|
|
138
|
-
title: 'Detected new do submit handlers',
|
|
139
|
-
description: 'New do submit handlers detected. Please update the plugin as soon as possible.',
|
|
140
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
141
|
-
}),
|
|
142
|
-
{
|
|
143
|
-
family: 4,
|
|
144
|
-
headers: {
|
|
145
|
-
'Content-Type': 'application/json',
|
|
146
|
-
'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? '0.1.0'}`,
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
);
|
|
150
|
-
} catch (error) {
|
|
151
|
-
if (debugMode === true) {
|
|
152
|
-
debugLog(logger, 'detect.ts / detectedNewDoSubmitHandlers()', 'error', 'Failed to notify plugin author about the new do submit handlers');
|
|
153
|
-
stackTracer('serialize-error', serializeError(error));
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return true;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* Detected new gateway information.
|
|
165
|
-
*
|
|
166
|
-
* @param {DetectedNewGatewayInformationDevice} device - Device.
|
|
167
|
-
* @param {DetectedNewGatewayInformationLogger} logger - Logger.
|
|
168
|
-
* @param {DetectedNewGatewayInformationDebugMode} debugMode - Debug mode.
|
|
169
|
-
*
|
|
170
|
-
* @returns {DetectedNewGatewayInformationReturns}
|
|
171
|
-
*
|
|
172
|
-
* @since 1.0.0
|
|
173
|
-
*/
|
|
174
|
-
export async function detectedNewGatewayInformation(device: DetectedNewGatewayInformationDevice, logger: DetectedNewGatewayInformationLogger, debugMode: DetectedNewGatewayInformationDebugMode): DetectedNewGatewayInformationReturns {
|
|
175
|
-
const knownStatuses: DetectedNewGatewayInformationKnownStatuses = [
|
|
176
|
-
'Online',
|
|
177
|
-
'Status Unknown',
|
|
178
|
-
];
|
|
179
|
-
|
|
180
|
-
// Compare with data above. Detection does not need to know if values are "null".
|
|
181
|
-
const detectedNewStatus = (device.status !== null && !knownStatuses.includes(device.status));
|
|
182
|
-
|
|
183
|
-
if (detectedNewStatus) {
|
|
184
|
-
const cleanedData = removePersonalIdentifiableInformation(device);
|
|
185
|
-
|
|
186
|
-
if (logger !== null) {
|
|
187
|
-
logger.warn('Plugin has detected new gateway information. Notifying plugin author about this discovery ...');
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// This is intentionally duplicated if using Homebridge debug mode.
|
|
191
|
-
if (debugMode) {
|
|
192
|
-
debugLog(logger, 'detect.ts / detectedNewGatewayInformation()', 'warn', 'Plugin has detected new gateway information. Notifying plugin author about this discovery');
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// Show content being sent to author.
|
|
196
|
-
stackTracer('detect-content', cleanedData);
|
|
197
|
-
|
|
198
|
-
try {
|
|
199
|
-
await axios.post(
|
|
200
|
-
'https://9wv5o73w.ntfy.mrjackyliang.com',
|
|
201
|
-
JSON.stringify({
|
|
202
|
-
title: 'Detected new gateway information',
|
|
203
|
-
description: 'New gateway information detected. Please update the plugin as soon as possible.',
|
|
204
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
205
|
-
}),
|
|
206
|
-
{
|
|
207
|
-
family: 4,
|
|
208
|
-
headers: {
|
|
209
|
-
'Content-Type': 'application/json',
|
|
210
|
-
'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? '0.1.0'}`,
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
);
|
|
214
|
-
} catch (error) {
|
|
215
|
-
if (debugMode === true) {
|
|
216
|
-
debugLog(logger, 'detect.ts / detectedNewGatewayInformation()', 'error', 'Failed to notify plugin author about the new gateway information');
|
|
217
|
-
stackTracer('serialize-error', serializeError(error));
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Detected orb security buttons.
|
|
229
|
-
*
|
|
230
|
-
* @param {DetectedNewOrbSecurityButtonsButtons} buttons - Buttons.
|
|
231
|
-
* @param {DetectedNewOrbSecurityButtonsLogger} logger - Logger.
|
|
232
|
-
* @param {DetectedNewOrbSecurityButtonsDebugMode} debugMode - Debug mode.
|
|
233
|
-
*
|
|
234
|
-
* @returns {DetectedNewOrbSecurityButtonsReturns}
|
|
235
|
-
*
|
|
236
|
-
* @since 1.0.0
|
|
237
|
-
*/
|
|
238
|
-
export async function detectedNewOrbSecurityButtons(buttons: DetectedNewOrbSecurityButtonsButtons, logger: DetectedNewOrbSecurityButtonsLogger, debugMode: DetectedNewOrbSecurityButtonsDebugMode): DetectedNewOrbSecurityButtonsReturns {
|
|
239
|
-
const knownButtonText: DetectedNewOrbSecurityButtonsKnownButtonText = [
|
|
240
|
-
'Arm Away',
|
|
241
|
-
'Arm Night',
|
|
242
|
-
'Arm Stay',
|
|
243
|
-
'Clear Alarm',
|
|
244
|
-
'Disarm',
|
|
245
|
-
];
|
|
246
|
-
const knownLoadingText: DetectedNewOrbSecurityButtonsKnownLoadingText = [
|
|
247
|
-
'Arming Away',
|
|
248
|
-
'Arming Night',
|
|
249
|
-
'Arming Stay',
|
|
250
|
-
'Disarming',
|
|
251
|
-
];
|
|
252
|
-
const knownRelativeUrl: DetectedNewOrbSecurityButtonsKnownRelativeUrl = [
|
|
253
|
-
'quickcontrol/armDisarm.jsp',
|
|
254
|
-
];
|
|
255
|
-
const knownUrlParamsArm: DetectedNewOrbSecurityButtonsKnownUrlParamsArm = [
|
|
256
|
-
'away',
|
|
257
|
-
'night',
|
|
258
|
-
'off',
|
|
259
|
-
'stay',
|
|
260
|
-
];
|
|
261
|
-
const knownUrlParamsArmState: DetectedNewOrbSecurityButtonsKnownUrlParamsArmState = [
|
|
262
|
-
'away',
|
|
263
|
-
'disarmed',
|
|
264
|
-
'disarmed_with_alarm',
|
|
265
|
-
'disarmed+with+alarm',
|
|
266
|
-
'night',
|
|
267
|
-
'night+stay',
|
|
268
|
-
'off',
|
|
269
|
-
'stay',
|
|
270
|
-
];
|
|
271
|
-
const knownUrlParamsHref: DetectedNewOrbSecurityButtonsKnownUrlParamsHref = [
|
|
272
|
-
'rest/adt/ui/client/security/setArmState',
|
|
273
|
-
];
|
|
274
|
-
|
|
275
|
-
// Compare with data above.
|
|
276
|
-
const detectedNewButtons = buttons.filter((button) => (
|
|
277
|
-
(
|
|
278
|
-
!button.buttonDisabled
|
|
279
|
-
&& (
|
|
280
|
-
(
|
|
281
|
-
button.buttonText !== null
|
|
282
|
-
&& !knownButtonText.includes(button.buttonText)
|
|
283
|
-
)
|
|
284
|
-
|| !knownLoadingText.includes(button.loadingText)
|
|
285
|
-
|| !knownRelativeUrl.includes(button.relativeUrl)
|
|
286
|
-
|| !knownUrlParamsArm.includes(button.urlParams.arm)
|
|
287
|
-
|| !knownUrlParamsArmState.includes(button.urlParams.armState)
|
|
288
|
-
|| !knownUrlParamsHref.includes(button.urlParams.href)
|
|
289
|
-
)
|
|
290
|
-
)
|
|
291
|
-
|| (
|
|
292
|
-
button.buttonDisabled
|
|
293
|
-
&& (
|
|
294
|
-
button.buttonText !== null
|
|
295
|
-
&& !knownLoadingText.includes(button.buttonText)
|
|
296
|
-
)
|
|
297
|
-
)
|
|
298
|
-
));
|
|
299
|
-
|
|
300
|
-
if (detectedNewButtons.length > 0) {
|
|
301
|
-
const cleanedData = removePersonalIdentifiableInformation(detectedNewButtons);
|
|
302
|
-
|
|
303
|
-
if (logger !== null) {
|
|
304
|
-
logger.warn('Plugin has detected new orb security buttons. Notifying plugin author about this discovery ...');
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// This is intentionally duplicated if using Homebridge debug mode.
|
|
308
|
-
if (debugMode) {
|
|
309
|
-
debugLog(logger, 'detect.ts / detectedNewOrbSecurityButtons()', 'warn', 'Plugin has detected new orb security buttons. Notifying plugin author about this discovery');
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// Show content being sent to author.
|
|
313
|
-
stackTracer('detect-content', cleanedData);
|
|
314
|
-
|
|
315
|
-
try {
|
|
316
|
-
await axios.post(
|
|
317
|
-
'https://9wv5o73w.ntfy.mrjackyliang.com',
|
|
318
|
-
JSON.stringify({
|
|
319
|
-
title: 'Detected new orb security buttons',
|
|
320
|
-
description: 'New orb security buttons detected. Please update the plugin as soon as possible.',
|
|
321
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
322
|
-
}),
|
|
323
|
-
{
|
|
324
|
-
family: 4,
|
|
325
|
-
headers: {
|
|
326
|
-
'Content-Type': 'application/json',
|
|
327
|
-
'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? '0.1.0'}`,
|
|
328
|
-
},
|
|
329
|
-
},
|
|
330
|
-
);
|
|
331
|
-
} catch (error) {
|
|
332
|
-
if (debugMode === true) {
|
|
333
|
-
debugLog(logger, 'detect.ts / detectedNewOrbSecurityButtons()', 'error', 'Failed to notify plugin author about the new orb security buttons');
|
|
334
|
-
stackTracer('serialize-error', serializeError(error));
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
return true;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
return false;
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/**
|
|
345
|
-
* Detected new panel information.
|
|
346
|
-
*
|
|
347
|
-
* @param {DetectedNewPanelInformationDevice} device - Device.
|
|
348
|
-
* @param {DetectedNewPanelInformationLogger} logger - Logger.
|
|
349
|
-
* @param {DetectedNewPanelInformationDebugMode} debugMode - Debug mode.
|
|
350
|
-
*
|
|
351
|
-
* @returns {DetectedNewPanelInformationReturns}
|
|
352
|
-
*
|
|
353
|
-
* @since 1.0.0
|
|
354
|
-
*/
|
|
355
|
-
export async function detectedNewPanelInformation(device: DetectedNewPanelInformationDevice, logger: DetectedNewPanelInformationLogger, debugMode: DetectedNewPanelInformationDebugMode): DetectedNewPanelInformationReturns {
|
|
356
|
-
const knownStatuses: DetectedNewPanelInformationKnownStatuses = [
|
|
357
|
-
'Online',
|
|
358
|
-
'Status Unknown',
|
|
359
|
-
];
|
|
360
|
-
|
|
361
|
-
// Compare with data above. Detection does not need to know if values are "null".
|
|
362
|
-
const detectedNewStatus = (device.status !== null && !knownStatuses.includes(device.status));
|
|
363
|
-
|
|
364
|
-
if (detectedNewStatus) {
|
|
365
|
-
const cleanedData = removePersonalIdentifiableInformation(device);
|
|
366
|
-
|
|
367
|
-
if (logger !== null) {
|
|
368
|
-
logger.warn('Plugin has detected new panel information. Notifying plugin author about this discovery ...');
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
// This is intentionally duplicated if using Homebridge debug mode.
|
|
372
|
-
if (debugMode) {
|
|
373
|
-
debugLog(logger, 'detect.ts / detectedNewPanelInformation()', 'warn', 'Plugin has detected new panel information. Notifying plugin author about this discovery');
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// Show content being sent to author.
|
|
377
|
-
stackTracer('detect-content', cleanedData);
|
|
378
|
-
|
|
379
|
-
try {
|
|
380
|
-
await axios.post(
|
|
381
|
-
'https://9wv5o73w.ntfy.mrjackyliang.com',
|
|
382
|
-
JSON.stringify({
|
|
383
|
-
title: 'Detected new panel information',
|
|
384
|
-
description: 'New panel information detected. Please update the plugin as soon as possible.',
|
|
385
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
386
|
-
}),
|
|
387
|
-
{
|
|
388
|
-
family: 4,
|
|
389
|
-
headers: {
|
|
390
|
-
'Content-Type': 'application/json',
|
|
391
|
-
'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? '0.1.0'}`,
|
|
392
|
-
},
|
|
393
|
-
},
|
|
394
|
-
);
|
|
395
|
-
} catch (error) {
|
|
396
|
-
if (debugMode === true) {
|
|
397
|
-
debugLog(logger, 'detect.ts / detectedNewPanelInformation()', 'error', 'Failed to notify plugin author about the new panel information');
|
|
398
|
-
stackTracer('serialize-error', serializeError(error));
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
return true;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
return false;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Detected new panel status.
|
|
410
|
-
*
|
|
411
|
-
* @param {DetectedNewPanelStatusSummary} summary - Summary.
|
|
412
|
-
* @param {DetectedNewPanelStatusLogger} logger - Logger.
|
|
413
|
-
* @param {DetectedNewPanelStatusDebugMode} debugMode - Debug mode.
|
|
414
|
-
*
|
|
415
|
-
* @returns {DetectedNewPanelStatusReturns}
|
|
416
|
-
*
|
|
417
|
-
* @since 1.0.0
|
|
418
|
-
*/
|
|
419
|
-
export async function detectedNewPanelStatus(summary: DetectedNewPanelStatusSummary, logger: DetectedNewPanelStatusLogger, debugMode: DetectedNewPanelStatusDebugMode): DetectedNewPanelStatusReturns {
|
|
420
|
-
const knownStates: DetectedNewPanelStatusKnownStates = [
|
|
421
|
-
'Armed Away',
|
|
422
|
-
'Armed Night',
|
|
423
|
-
'Armed Stay',
|
|
424
|
-
'Disarmed',
|
|
425
|
-
'Status Unavailable',
|
|
426
|
-
];
|
|
427
|
-
const knownStatuses: DetectedNewPanelStatusKnownStatuses = [
|
|
428
|
-
'1 Sensor Open',
|
|
429
|
-
..._.range(256).map((_value, index) => `${index + 1} Sensors Open` as DetectedNewPanelStatusKnownStatusesSensorsOpen),
|
|
430
|
-
'All Quiet',
|
|
431
|
-
'BURGLARY ALARM',
|
|
432
|
-
'Carbon Monoxide Alarm',
|
|
433
|
-
'FIRE ALARM',
|
|
434
|
-
'Motion',
|
|
435
|
-
'Sensor Bypassed',
|
|
436
|
-
'Sensor Problem',
|
|
437
|
-
'Sensors Bypassed',
|
|
438
|
-
'Sensors Tripped',
|
|
439
|
-
'Sensor Tripped',
|
|
440
|
-
'Uncleared Alarm',
|
|
441
|
-
'WATER ALARM',
|
|
442
|
-
];
|
|
443
|
-
|
|
444
|
-
// Compare with data above. Detection does not need to know if values are "null".
|
|
445
|
-
const detectedNewState = (summary.state !== null && !knownStates.includes(summary.state));
|
|
446
|
-
const detectedNewStatus = (summary.status !== null && !knownStatuses.includes(summary.status));
|
|
447
|
-
|
|
448
|
-
if (detectedNewState || detectedNewStatus) {
|
|
449
|
-
const cleanedData = removePersonalIdentifiableInformation(summary);
|
|
450
|
-
|
|
451
|
-
if (logger !== null) {
|
|
452
|
-
logger.warn('Plugin has detected a new panel state and/or status. Notifying plugin author about this discovery ...');
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// This is intentionally duplicated if using Homebridge debug mode.
|
|
456
|
-
if (debugMode) {
|
|
457
|
-
debugLog(logger, 'detect.ts / detectedNewPanelStatus()', 'warn', 'Plugin has detected a new panel state and/or status. Notifying plugin author about this discovery');
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
// Show content being sent to author.
|
|
461
|
-
stackTracer('detect-content', cleanedData);
|
|
462
|
-
|
|
463
|
-
try {
|
|
464
|
-
await axios.post(
|
|
465
|
-
'https://9wv5o73w.ntfy.mrjackyliang.com',
|
|
466
|
-
JSON.stringify({
|
|
467
|
-
title: 'Detected a new panel state and/or status',
|
|
468
|
-
description: 'A new panel state and/or status detected. Please update the plugin as soon as possible.',
|
|
469
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
470
|
-
}),
|
|
471
|
-
{
|
|
472
|
-
family: 4,
|
|
473
|
-
headers: {
|
|
474
|
-
'Content-Type': 'application/json',
|
|
475
|
-
'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? '0.1.0'}`,
|
|
476
|
-
},
|
|
477
|
-
},
|
|
478
|
-
);
|
|
479
|
-
} catch (error) {
|
|
480
|
-
if (debugMode === true) {
|
|
481
|
-
debugLog(logger, 'detect.ts / detectedNewPanelStatus()', 'error', 'Failed to notify plugin author about the new panel state and/or status');
|
|
482
|
-
stackTracer('serialize-error', serializeError(error));
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
return true;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
return false;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* Detected new portal version.
|
|
494
|
-
*
|
|
495
|
-
* @param {DetectedNewPortalVersionVersion} version - Version.
|
|
496
|
-
* @param {DetectedNewPortalVersionLogger} logger - Logger.
|
|
497
|
-
* @param {DetectedNewPortalVersionDebugMode} debugMode - Debug mode.
|
|
498
|
-
*
|
|
499
|
-
* @returns {DetectedNewPortalVersionReturns}
|
|
500
|
-
*
|
|
501
|
-
* @since 1.0.0
|
|
502
|
-
*/
|
|
503
|
-
export async function detectedNewPortalVersion(version: DetectedNewPortalVersionVersion, logger: DetectedNewPortalVersionLogger, debugMode: DetectedNewPortalVersionDebugMode): DetectedNewPortalVersionReturns {
|
|
504
|
-
const knownVersions: DetectedNewPortalVersionKnownVersions = [
|
|
505
|
-
'16.0.0-131',
|
|
506
|
-
'17.0.0-69',
|
|
507
|
-
'18.0.0-78',
|
|
508
|
-
'19.0.0-89',
|
|
509
|
-
'20.0.0-221',
|
|
510
|
-
'20.0.0-244',
|
|
511
|
-
'21.0.0-344',
|
|
512
|
-
'21.0.0-353',
|
|
513
|
-
'21.0.0-354',
|
|
514
|
-
'22.0.0-233',
|
|
515
|
-
'23.0.0-99',
|
|
516
|
-
'24.0.0-117',
|
|
517
|
-
'25.0.0-21',
|
|
518
|
-
'26.0.0-32',
|
|
519
|
-
'27.0.0-140',
|
|
520
|
-
];
|
|
521
|
-
|
|
522
|
-
// Compare with data above. Detection does not need to know if values are "null".
|
|
523
|
-
const detectedNewVersion = (version.version !== null && !knownVersions.includes(version.version));
|
|
524
|
-
|
|
525
|
-
if (detectedNewVersion) {
|
|
526
|
-
const cleanedData = removePersonalIdentifiableInformation(version);
|
|
527
|
-
|
|
528
|
-
if (logger !== null) {
|
|
529
|
-
logger.warn('Plugin has detected a new portal version. Notifying plugin author about this discovery ...');
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
// This is intentionally duplicated if using Homebridge debug mode.
|
|
533
|
-
if (debugMode) {
|
|
534
|
-
debugLog(logger, 'detect.ts / detectedNewPortalVersion()', 'warn', 'Plugin has detected a new portal version. Notifying plugin author about this discovery');
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
// Show content being sent to author.
|
|
538
|
-
stackTracer('detect-content', cleanedData);
|
|
539
|
-
|
|
540
|
-
try {
|
|
541
|
-
await axios.post(
|
|
542
|
-
'https://9wv5o73w.ntfy.mrjackyliang.com',
|
|
543
|
-
JSON.stringify({
|
|
544
|
-
title: 'Detected a new portal version',
|
|
545
|
-
description: 'A new portal version detected. Please update the plugin as soon as possible.',
|
|
546
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
547
|
-
}),
|
|
548
|
-
{
|
|
549
|
-
family: 4,
|
|
550
|
-
headers: {
|
|
551
|
-
'Content-Type': 'application/json',
|
|
552
|
-
'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? '0.1.0'}`,
|
|
553
|
-
},
|
|
554
|
-
},
|
|
555
|
-
);
|
|
556
|
-
} catch (error) {
|
|
557
|
-
if (debugMode === true) {
|
|
558
|
-
debugLog(logger, 'detect.ts / detectedNewPortalVersion()', 'error', 'Failed to notify plugin author about the new portal version');
|
|
559
|
-
stackTracer('serialize-error', serializeError(error));
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
return true;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
return false;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
/**
|
|
570
|
-
* Detected new sensors' information.
|
|
571
|
-
*
|
|
572
|
-
* @param {DetectedNewSensorsInformationSensors} sensors - Sensors.
|
|
573
|
-
* @param {DetectedNewSensorsInformationLogger} logger - Logger.
|
|
574
|
-
* @param {DetectedNewSensorsInformationDebugMode} debugMode - Debug mode.
|
|
575
|
-
*
|
|
576
|
-
* @returns {DetectedNewSensorsInformationReturns}
|
|
577
|
-
*
|
|
578
|
-
* @since 1.0.0
|
|
579
|
-
*/
|
|
580
|
-
export async function detectedNewSensorsInformation(sensors: DetectedNewSensorsInformationSensors, logger: DetectedNewSensorsInformationLogger, debugMode: DetectedNewSensorsInformationDebugMode): DetectedNewSensorsInformationReturns {
|
|
581
|
-
const knownDeviceTypes: DetectedNewSensorsInformationKnownDeviceTypes = [
|
|
582
|
-
'Door Sensor',
|
|
583
|
-
'Door/Window Sensor',
|
|
584
|
-
'Carbon Monoxide Detector',
|
|
585
|
-
'Fire (Smoke/Heat) Detector',
|
|
586
|
-
'Glass Break Detector',
|
|
587
|
-
'Motion Sensor',
|
|
588
|
-
'Motion Sensor (Notable Events Only)',
|
|
589
|
-
'Temperature Sensor',
|
|
590
|
-
'Water/Flood Sensor',
|
|
591
|
-
'Window Sensor',
|
|
592
|
-
];
|
|
593
|
-
const knownStatuses: DetectedNewSensorsInformationKnownStatuses = [
|
|
594
|
-
'Online',
|
|
595
|
-
'Status Unknown',
|
|
596
|
-
];
|
|
597
|
-
|
|
598
|
-
// Compare with data above.
|
|
599
|
-
const detectedNewInformation = sensors.filter((sensor) => (
|
|
600
|
-
!knownDeviceTypes.includes(sensor.deviceType)
|
|
601
|
-
|| !knownStatuses.includes(sensor.status)
|
|
602
|
-
));
|
|
603
|
-
|
|
604
|
-
if (detectedNewInformation.length > 0) {
|
|
605
|
-
const cleanedData = removePersonalIdentifiableInformation(detectedNewInformation);
|
|
606
|
-
|
|
607
|
-
if (logger !== null) {
|
|
608
|
-
logger.warn('Plugin has detected new sensors information. Notifying plugin author about this discovery ...');
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
// This is intentionally duplicated if using Homebridge debug mode.
|
|
612
|
-
if (debugMode) {
|
|
613
|
-
debugLog(logger, 'detect.ts / detectedNewSensorsInformation()', 'warn', 'Plugin has detected new sensors information. Notifying plugin author about this discovery');
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
// Show content being sent to author.
|
|
617
|
-
stackTracer('detect-content', cleanedData);
|
|
618
|
-
|
|
619
|
-
try {
|
|
620
|
-
await axios.post(
|
|
621
|
-
'https://9wv5o73w.ntfy.mrjackyliang.com',
|
|
622
|
-
JSON.stringify({
|
|
623
|
-
title: 'Detected new sensors information',
|
|
624
|
-
description: 'New sensors information detected. Please update the plugin as soon as possible.',
|
|
625
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
626
|
-
}),
|
|
627
|
-
{
|
|
628
|
-
family: 4,
|
|
629
|
-
headers: {
|
|
630
|
-
'Content-Type': 'application/json',
|
|
631
|
-
'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? '0.1.0'}`,
|
|
632
|
-
},
|
|
633
|
-
},
|
|
634
|
-
);
|
|
635
|
-
} catch (error) {
|
|
636
|
-
if (debugMode === true) {
|
|
637
|
-
debugLog(logger, 'detect.ts / detectedNewSensorsInformation()', 'error', 'Failed to notify plugin author about the new sensors information');
|
|
638
|
-
stackTracer('serialize-error', serializeError(error));
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
return true;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
return false;
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
/**
|
|
649
|
-
* Detected new sensors' status.
|
|
650
|
-
*
|
|
651
|
-
* @param {DetectedNewSensorsStatusSensors} sensors - Sensors.
|
|
652
|
-
* @param {DetectedNewSensorsStatusLogger} logger - Logger.
|
|
653
|
-
* @param {DetectedNewSensorsStatusDebugMode} debugMode - Debug mode.
|
|
654
|
-
*
|
|
655
|
-
* @returns {DetectedNewSensorsStatusReturns}
|
|
656
|
-
*
|
|
657
|
-
* @since 1.0.0
|
|
658
|
-
*/
|
|
659
|
-
export async function detectedNewSensorsStatus(sensors: DetectedNewSensorsStatusSensors, logger: DetectedNewSensorsStatusLogger, debugMode: DetectedNewSensorsStatusDebugMode): DetectedNewSensorsStatusReturns {
|
|
660
|
-
const knownIcons: DetectedNewSensorsStatusKnownIcons = [
|
|
661
|
-
'devStatAlarm',
|
|
662
|
-
'devStatLowBatt',
|
|
663
|
-
'devStatMotion',
|
|
664
|
-
'devStatOK',
|
|
665
|
-
'devStatOpen',
|
|
666
|
-
'devStatTamper',
|
|
667
|
-
'devStatUnknown',
|
|
668
|
-
];
|
|
669
|
-
const knownStatuses: DetectedNewSensorsStatusKnownStatuses = [
|
|
670
|
-
'ALARM, Okay',
|
|
671
|
-
'Closed',
|
|
672
|
-
'Motion',
|
|
673
|
-
'No Motion',
|
|
674
|
-
'Okay',
|
|
675
|
-
'Open',
|
|
676
|
-
'Tripped',
|
|
677
|
-
'Unknown',
|
|
678
|
-
];
|
|
679
|
-
|
|
680
|
-
// Compare with data above.
|
|
681
|
-
const detectedNewStatuses = sensors.filter((sensor) => (
|
|
682
|
-
!knownIcons.includes(sensor.icon)
|
|
683
|
-
|| !knownStatuses.includes(sensor.status)
|
|
684
|
-
));
|
|
685
|
-
|
|
686
|
-
if (detectedNewStatuses.length > 0) {
|
|
687
|
-
const cleanedData = removePersonalIdentifiableInformation(detectedNewStatuses);
|
|
688
|
-
|
|
689
|
-
if (logger !== null) {
|
|
690
|
-
logger.warn('Plugin has detected new sensors status. Notifying plugin author about this discovery ...');
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
// This is intentionally duplicated if using Homebridge debug mode.
|
|
694
|
-
if (debugMode) {
|
|
695
|
-
debugLog(logger, 'detect.ts / detectedNewSensorsStatus()', 'warn', 'Plugin has detected new sensors status. Notifying plugin author about this discovery');
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
// Show content being sent to author.
|
|
699
|
-
stackTracer('detect-content', cleanedData);
|
|
700
|
-
|
|
701
|
-
try {
|
|
702
|
-
await axios.post(
|
|
703
|
-
'https://9wv5o73w.ntfy.mrjackyliang.com',
|
|
704
|
-
JSON.stringify({
|
|
705
|
-
title: 'Detected new sensors status',
|
|
706
|
-
description: 'New sensors status detected. Please update the plugin as soon as possible.',
|
|
707
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
708
|
-
}),
|
|
709
|
-
{
|
|
710
|
-
family: 4,
|
|
711
|
-
headers: {
|
|
712
|
-
'Content-Type': 'application/json',
|
|
713
|
-
'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? '0.1.0'}`,
|
|
714
|
-
},
|
|
715
|
-
},
|
|
716
|
-
);
|
|
717
|
-
} catch (error) {
|
|
718
|
-
if (debugMode === true) {
|
|
719
|
-
debugLog(logger, 'detect.ts / detectedNewSensorsStatus()', 'error', 'Failed to notify plugin author about the new sensors status');
|
|
720
|
-
stackTracer('serialize-error', serializeError(error));
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
return true;
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
return false;
|
|
728
|
-
}
|