homebridge-adt-pulse 3.0.0-beta.9 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +198 -12
- package/README.md +168 -106
- package/build/config.schema.json +18 -13
- package/build/src/lib/accessory.js +441 -122
- package/build/src/lib/accessory.js.map +1 -1
- package/build/src/lib/api.js +177 -232
- package/build/src/lib/api.js.map +1 -1
- package/build/src/lib/detect.js +188 -240
- package/build/src/lib/detect.js.map +1 -1
- package/build/src/lib/items.js +337 -0
- package/build/src/lib/items.js.map +1 -0
- package/build/src/lib/platform.js +198 -38
- package/build/src/lib/platform.js.map +1 -1
- package/build/src/lib/regex.js +2 -2
- package/build/src/lib/regex.js.map +1 -1
- package/build/src/lib/schema.js +4 -3
- package/build/src/lib/schema.js.map +1 -1
- package/build/src/lib/utility.js +277 -38
- package/build/src/lib/utility.js.map +1 -1
- package/build/src/scripts/repl.js +14 -8
- package/build/src/scripts/repl.js.map +1 -1
- package/build/src/scripts/test-api.js +6 -6
- package/build/src/scripts/test-api.js.map +1 -1
- package/config.schema.json +18 -13
- package/package.json +25 -15
package/build/src/lib/detect.js
CHANGED
|
@@ -1,44 +1,14 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
import { env } from 'node:process';
|
|
4
2
|
import { serializeError } from 'serialize-error';
|
|
5
|
-
import {
|
|
3
|
+
import { doSubmitHandlerRelativeUrlItems, doSubmitHandlerUrlParamsArmItems, doSubmitHandlerUrlParamsArmStateItems, doSubmitHandlerUrlParamsHrefItems, gatewayInformationStatusItems, orbSecurityButtonButtonTextItems, orbSecurityButtonLoadingTextItems, orbSecurityButtonRelativeUrlItems, orbSecurityButtonUrlParamsArmItems, orbSecurityButtonUrlParamsArmStateItems, orbSecurityButtonUrlParamsHrefItems, panelInformationStatusItems, portalVersionItems, sensorActionItems, sensorInformationDeviceTypeItems, sensorInformationStatusItems, sensorStatusIconItems, sensorStatusStatusItems, } from './items.js';
|
|
4
|
+
import { debugLog, getDetectReportUrl, isPluginOutdated, removePersonalIdentifiableInformation, stackTracer, } from './utility.js';
|
|
6
5
|
export async function detectedNewDoSubmitHandlers(handlers, logger, debugMode) {
|
|
7
|
-
const
|
|
8
|
-
'16.0.0-131',
|
|
9
|
-
'17.0.0-69',
|
|
10
|
-
'18.0.0-78',
|
|
11
|
-
'19.0.0-89',
|
|
12
|
-
'20.0.0-221',
|
|
13
|
-
'20.0.0-244',
|
|
14
|
-
'21.0.0-344',
|
|
15
|
-
'21.0.0-353',
|
|
16
|
-
'21.0.0-354',
|
|
17
|
-
'22.0.0-233',
|
|
18
|
-
'23.0.0-99',
|
|
19
|
-
'24.0.0-117',
|
|
20
|
-
'25.0.0-21',
|
|
21
|
-
'26.0.0-32',
|
|
22
|
-
'27.0.0-140',
|
|
23
|
-
].map((version) => `/myhome/${version}/quickcontrol/serv/RunRRACommand`);
|
|
24
|
-
const knownUrlParamsArm = [
|
|
25
|
-
'away',
|
|
26
|
-
'night',
|
|
27
|
-
'stay',
|
|
28
|
-
];
|
|
29
|
-
const knownUrlParamsArmState = [
|
|
30
|
-
'forcearm',
|
|
31
|
-
];
|
|
32
|
-
const knownUrlParamsHref = [
|
|
33
|
-
'rest/adt/ui/client/security/setForceArm',
|
|
34
|
-
'rest/adt/ui/client/security/setCancelProtest',
|
|
35
|
-
];
|
|
36
|
-
const detectedNewHandlers = handlers.filter((handler) => (!knownRelativeUrls.includes(handler.relativeUrl)
|
|
6
|
+
const detectedNewHandlers = handlers.filter((handler) => (!doSubmitHandlerRelativeUrlItems.includes(handler.relativeUrl)
|
|
37
7
|
|| (handler.urlParams.arm !== null
|
|
38
|
-
&& !
|
|
8
|
+
&& !doSubmitHandlerUrlParamsArmItems.includes(handler.urlParams.arm))
|
|
39
9
|
|| (handler.urlParams.armState !== null
|
|
40
|
-
&& !
|
|
41
|
-
|| !
|
|
10
|
+
&& !doSubmitHandlerUrlParamsArmStateItems.includes(handler.urlParams.armState))
|
|
11
|
+
|| !doSubmitHandlerUrlParamsHrefItems.includes(handler.urlParams.href)));
|
|
42
12
|
if (detectedNewHandlers.length > 0) {
|
|
43
13
|
const cleanedData = removePersonalIdentifiableInformation(detectedNewHandlers);
|
|
44
14
|
try {
|
|
@@ -58,43 +28,38 @@ export async function detectedNewDoSubmitHandlers(handlers, logger, debugMode) {
|
|
|
58
28
|
debugLog(logger, 'detect.ts / detectedNewDoSubmitHandlers()', 'error', 'Failed to check if plugin is outdated');
|
|
59
29
|
stackTracer('serialize-error', serializeError(error));
|
|
60
30
|
}
|
|
31
|
+
return false;
|
|
61
32
|
}
|
|
62
33
|
if (logger !== null) {
|
|
63
34
|
logger.warn('Plugin has detected new do submit handlers. Notifying plugin author about this discovery ...');
|
|
35
|
+
logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
|
|
64
36
|
}
|
|
65
37
|
if (debugMode) {
|
|
66
38
|
debugLog(logger, 'detect.ts / detectedNewDoSubmitHandlers()', 'warn', 'Plugin has detected new do submit handlers. Notifying plugin author about this discovery');
|
|
67
39
|
}
|
|
68
40
|
stackTracer('detect-content', cleanedData);
|
|
69
41
|
try {
|
|
70
|
-
await axios.post(
|
|
71
|
-
title: 'Detected new do submit handlers',
|
|
72
|
-
description: 'New do submit handlers detected. Please update the plugin as soon as possible.',
|
|
73
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
74
|
-
}), {
|
|
42
|
+
await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
|
|
75
43
|
family: 4,
|
|
76
44
|
headers: {
|
|
77
|
-
'
|
|
78
|
-
'
|
|
45
|
+
'User-Agent': 'homebridge-adt-pulse',
|
|
46
|
+
'X-Title': 'Detected new do submit handlers',
|
|
79
47
|
},
|
|
80
48
|
});
|
|
49
|
+
return true;
|
|
81
50
|
}
|
|
82
51
|
catch (error) {
|
|
83
52
|
if (debugMode === true) {
|
|
84
53
|
debugLog(logger, 'detect.ts / detectedNewDoSubmitHandlers()', 'error', 'Failed to notify plugin author about the new do submit handlers');
|
|
85
54
|
stackTracer('serialize-error', serializeError(error));
|
|
86
55
|
}
|
|
56
|
+
return false;
|
|
87
57
|
}
|
|
88
|
-
return true;
|
|
89
58
|
}
|
|
90
59
|
return false;
|
|
91
60
|
}
|
|
92
61
|
export async function detectedNewGatewayInformation(device, logger, debugMode) {
|
|
93
|
-
const
|
|
94
|
-
'Online',
|
|
95
|
-
'Status Unknown',
|
|
96
|
-
];
|
|
97
|
-
const detectedNewStatus = (device.status !== null && !knownStatuses.includes(device.status));
|
|
62
|
+
const detectedNewStatus = (device.status !== null && !gatewayInformationStatusItems.includes(device.status));
|
|
98
63
|
if (detectedNewStatus) {
|
|
99
64
|
const cleanedData = removePersonalIdentifiableInformation(device);
|
|
100
65
|
try {
|
|
@@ -114,84 +79,48 @@ export async function detectedNewGatewayInformation(device, logger, debugMode) {
|
|
|
114
79
|
debugLog(logger, 'detect.ts / detectedNewGatewayInformation()', 'error', 'Failed to check if plugin is outdated');
|
|
115
80
|
stackTracer('serialize-error', serializeError(error));
|
|
116
81
|
}
|
|
82
|
+
return false;
|
|
117
83
|
}
|
|
118
84
|
if (logger !== null) {
|
|
119
85
|
logger.warn('Plugin has detected new gateway information. Notifying plugin author about this discovery ...');
|
|
86
|
+
logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
|
|
120
87
|
}
|
|
121
88
|
if (debugMode) {
|
|
122
89
|
debugLog(logger, 'detect.ts / detectedNewGatewayInformation()', 'warn', 'Plugin has detected new gateway information. Notifying plugin author about this discovery');
|
|
123
90
|
}
|
|
124
91
|
stackTracer('detect-content', cleanedData);
|
|
125
92
|
try {
|
|
126
|
-
await axios.post(
|
|
127
|
-
title: 'Detected new gateway information',
|
|
128
|
-
description: 'New gateway information detected. Please update the plugin as soon as possible.',
|
|
129
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
130
|
-
}), {
|
|
93
|
+
await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
|
|
131
94
|
family: 4,
|
|
132
95
|
headers: {
|
|
133
|
-
'
|
|
134
|
-
'
|
|
96
|
+
'User-Agent': 'homebridge-adt-pulse',
|
|
97
|
+
'X-Title': 'Detected new gateway information',
|
|
135
98
|
},
|
|
136
99
|
});
|
|
100
|
+
return true;
|
|
137
101
|
}
|
|
138
102
|
catch (error) {
|
|
139
103
|
if (debugMode === true) {
|
|
140
104
|
debugLog(logger, 'detect.ts / detectedNewGatewayInformation()', 'error', 'Failed to notify plugin author about the new gateway information');
|
|
141
105
|
stackTracer('serialize-error', serializeError(error));
|
|
142
106
|
}
|
|
107
|
+
return false;
|
|
143
108
|
}
|
|
144
|
-
return true;
|
|
145
109
|
}
|
|
146
110
|
return false;
|
|
147
111
|
}
|
|
148
112
|
export async function detectedNewOrbSecurityButtons(buttons, logger, debugMode) {
|
|
149
|
-
const knownButtonText = [
|
|
150
|
-
'Arm Away',
|
|
151
|
-
'Arm Night',
|
|
152
|
-
'Arm Stay',
|
|
153
|
-
'Clear Alarm',
|
|
154
|
-
'Disarm',
|
|
155
|
-
];
|
|
156
|
-
const knownLoadingText = [
|
|
157
|
-
'Arming Away',
|
|
158
|
-
'Arming Night',
|
|
159
|
-
'Arming Stay',
|
|
160
|
-
'Disarming',
|
|
161
|
-
];
|
|
162
|
-
const knownRelativeUrl = [
|
|
163
|
-
'quickcontrol/armDisarm.jsp',
|
|
164
|
-
];
|
|
165
|
-
const knownUrlParamsArm = [
|
|
166
|
-
'away',
|
|
167
|
-
'night',
|
|
168
|
-
'off',
|
|
169
|
-
'stay',
|
|
170
|
-
];
|
|
171
|
-
const knownUrlParamsArmState = [
|
|
172
|
-
'away',
|
|
173
|
-
'disarmed',
|
|
174
|
-
'disarmed_with_alarm',
|
|
175
|
-
'disarmed+with+alarm',
|
|
176
|
-
'night',
|
|
177
|
-
'night+stay',
|
|
178
|
-
'off',
|
|
179
|
-
'stay',
|
|
180
|
-
];
|
|
181
|
-
const knownUrlParamsHref = [
|
|
182
|
-
'rest/adt/ui/client/security/setArmState',
|
|
183
|
-
];
|
|
184
113
|
const detectedNewButtons = buttons.filter((button) => ((!button.buttonDisabled
|
|
185
114
|
&& ((button.buttonText !== null
|
|
186
|
-
&& !
|
|
187
|
-
|| !
|
|
188
|
-
|| !
|
|
189
|
-
|| !
|
|
190
|
-
|| !
|
|
191
|
-
|| !
|
|
115
|
+
&& !orbSecurityButtonButtonTextItems.includes(button.buttonText))
|
|
116
|
+
|| !orbSecurityButtonLoadingTextItems.includes(button.loadingText)
|
|
117
|
+
|| !orbSecurityButtonRelativeUrlItems.includes(button.relativeUrl)
|
|
118
|
+
|| !orbSecurityButtonUrlParamsArmItems.includes(button.urlParams.arm)
|
|
119
|
+
|| !orbSecurityButtonUrlParamsArmStateItems.includes(button.urlParams.armState)
|
|
120
|
+
|| !orbSecurityButtonUrlParamsHrefItems.includes(button.urlParams.href)))
|
|
192
121
|
|| (button.buttonDisabled
|
|
193
122
|
&& (button.buttonText !== null
|
|
194
|
-
&& !
|
|
123
|
+
&& !orbSecurityButtonLoadingTextItems.includes(button.buttonText)))));
|
|
195
124
|
if (detectedNewButtons.length > 0) {
|
|
196
125
|
const cleanedData = removePersonalIdentifiableInformation(detectedNewButtons);
|
|
197
126
|
try {
|
|
@@ -211,43 +140,38 @@ export async function detectedNewOrbSecurityButtons(buttons, logger, debugMode)
|
|
|
211
140
|
debugLog(logger, 'detect.ts / detectedNewOrbSecurityButtons()', 'error', 'Failed to check if plugin is outdated');
|
|
212
141
|
stackTracer('serialize-error', serializeError(error));
|
|
213
142
|
}
|
|
143
|
+
return false;
|
|
214
144
|
}
|
|
215
145
|
if (logger !== null) {
|
|
216
146
|
logger.warn('Plugin has detected new orb security buttons. Notifying plugin author about this discovery ...');
|
|
147
|
+
logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
|
|
217
148
|
}
|
|
218
149
|
if (debugMode) {
|
|
219
150
|
debugLog(logger, 'detect.ts / detectedNewOrbSecurityButtons()', 'warn', 'Plugin has detected new orb security buttons. Notifying plugin author about this discovery');
|
|
220
151
|
}
|
|
221
152
|
stackTracer('detect-content', cleanedData);
|
|
222
153
|
try {
|
|
223
|
-
await axios.post(
|
|
224
|
-
title: 'Detected new orb security buttons',
|
|
225
|
-
description: 'New orb security buttons detected. Please update the plugin as soon as possible.',
|
|
226
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
227
|
-
}), {
|
|
154
|
+
await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
|
|
228
155
|
family: 4,
|
|
229
156
|
headers: {
|
|
230
|
-
'
|
|
231
|
-
'
|
|
157
|
+
'User-Agent': 'homebridge-adt-pulse',
|
|
158
|
+
'X-Title': 'Detected new orb security buttons',
|
|
232
159
|
},
|
|
233
160
|
});
|
|
161
|
+
return true;
|
|
234
162
|
}
|
|
235
163
|
catch (error) {
|
|
236
164
|
if (debugMode === true) {
|
|
237
165
|
debugLog(logger, 'detect.ts / detectedNewOrbSecurityButtons()', 'error', 'Failed to notify plugin author about the new orb security buttons');
|
|
238
166
|
stackTracer('serialize-error', serializeError(error));
|
|
239
167
|
}
|
|
168
|
+
return false;
|
|
240
169
|
}
|
|
241
|
-
return true;
|
|
242
170
|
}
|
|
243
171
|
return false;
|
|
244
172
|
}
|
|
245
173
|
export async function detectedNewPanelInformation(device, logger, debugMode) {
|
|
246
|
-
const
|
|
247
|
-
'Online',
|
|
248
|
-
'Status Unknown',
|
|
249
|
-
];
|
|
250
|
-
const detectedNewStatus = (device.status !== null && !knownStatuses.includes(device.status));
|
|
174
|
+
const detectedNewStatus = (device.status !== null && !panelInformationStatusItems.includes(device.status));
|
|
251
175
|
if (detectedNewStatus) {
|
|
252
176
|
const cleanedData = removePersonalIdentifiableInformation(device);
|
|
253
177
|
try {
|
|
@@ -267,64 +191,39 @@ export async function detectedNewPanelInformation(device, logger, debugMode) {
|
|
|
267
191
|
debugLog(logger, 'detect.ts / detectedNewPanelInformation()', 'error', 'Failed to check if plugin is outdated');
|
|
268
192
|
stackTracer('serialize-error', serializeError(error));
|
|
269
193
|
}
|
|
194
|
+
return false;
|
|
270
195
|
}
|
|
271
196
|
if (logger !== null) {
|
|
272
197
|
logger.warn('Plugin has detected new panel information. Notifying plugin author about this discovery ...');
|
|
198
|
+
logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
|
|
273
199
|
}
|
|
274
200
|
if (debugMode) {
|
|
275
201
|
debugLog(logger, 'detect.ts / detectedNewPanelInformation()', 'warn', 'Plugin has detected new panel information. Notifying plugin author about this discovery');
|
|
276
202
|
}
|
|
277
203
|
stackTracer('detect-content', cleanedData);
|
|
278
204
|
try {
|
|
279
|
-
await axios.post(
|
|
280
|
-
title: 'Detected new panel information',
|
|
281
|
-
description: 'New panel information detected. Please update the plugin as soon as possible.',
|
|
282
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
283
|
-
}), {
|
|
205
|
+
await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
|
|
284
206
|
family: 4,
|
|
285
207
|
headers: {
|
|
286
|
-
'
|
|
287
|
-
'
|
|
208
|
+
'User-Agent': 'homebridge-adt-pulse',
|
|
209
|
+
'X-Title': 'Detected new panel information',
|
|
288
210
|
},
|
|
289
211
|
});
|
|
212
|
+
return true;
|
|
290
213
|
}
|
|
291
214
|
catch (error) {
|
|
292
215
|
if (debugMode === true) {
|
|
293
216
|
debugLog(logger, 'detect.ts / detectedNewPanelInformation()', 'error', 'Failed to notify plugin author about the new panel information');
|
|
294
217
|
stackTracer('serialize-error', serializeError(error));
|
|
295
218
|
}
|
|
219
|
+
return false;
|
|
296
220
|
}
|
|
297
|
-
return true;
|
|
298
221
|
}
|
|
299
222
|
return false;
|
|
300
223
|
}
|
|
301
224
|
export async function detectedNewPanelStatus(summary, logger, debugMode) {
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
'Armed Night',
|
|
305
|
-
'Armed Stay',
|
|
306
|
-
'Disarmed',
|
|
307
|
-
'Status Unavailable',
|
|
308
|
-
];
|
|
309
|
-
const knownStatuses = [
|
|
310
|
-
'1 Sensor Open',
|
|
311
|
-
..._.range(256).map((_value, index) => `${index + 1} Sensors Open`),
|
|
312
|
-
'All Quiet',
|
|
313
|
-
'BURGLARY ALARM',
|
|
314
|
-
'Carbon Monoxide Alarm',
|
|
315
|
-
'FIRE ALARM',
|
|
316
|
-
'Motion',
|
|
317
|
-
'Sensor Bypassed',
|
|
318
|
-
'Sensor Problem',
|
|
319
|
-
'Sensors Bypassed',
|
|
320
|
-
'Sensors Tripped',
|
|
321
|
-
'Sensor Tripped',
|
|
322
|
-
'Uncleared Alarm',
|
|
323
|
-
'WATER ALARM',
|
|
324
|
-
];
|
|
325
|
-
const detectedNewState = (summary.state !== null && !knownStates.includes(summary.state));
|
|
326
|
-
const detectedNewStatus = (summary.status !== null && !knownStatuses.includes(summary.status));
|
|
327
|
-
if (detectedNewState || detectedNewStatus) {
|
|
225
|
+
const detectedUnknownPieces = summary.rawData.unknownPieces.length > 0;
|
|
226
|
+
if (detectedUnknownPieces) {
|
|
328
227
|
const cleanedData = removePersonalIdentifiableInformation(summary);
|
|
329
228
|
try {
|
|
330
229
|
const outdated = await isPluginOutdated();
|
|
@@ -343,56 +242,38 @@ export async function detectedNewPanelStatus(summary, logger, debugMode) {
|
|
|
343
242
|
debugLog(logger, 'detect.ts / detectedNewPanelStatus()', 'error', 'Failed to check if plugin is outdated');
|
|
344
243
|
stackTracer('serialize-error', serializeError(error));
|
|
345
244
|
}
|
|
245
|
+
return false;
|
|
346
246
|
}
|
|
347
247
|
if (logger !== null) {
|
|
348
248
|
logger.warn('Plugin has detected a new panel state and/or status. Notifying plugin author about this discovery ...');
|
|
249
|
+
logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
|
|
349
250
|
}
|
|
350
251
|
if (debugMode) {
|
|
351
252
|
debugLog(logger, 'detect.ts / detectedNewPanelStatus()', 'warn', 'Plugin has detected a new panel state and/or status. Notifying plugin author about this discovery');
|
|
352
253
|
}
|
|
353
254
|
stackTracer('detect-content', cleanedData);
|
|
354
255
|
try {
|
|
355
|
-
await axios.post(
|
|
356
|
-
title: 'Detected a new panel state and/or status',
|
|
357
|
-
description: 'A new panel state and/or status detected. Please update the plugin as soon as possible.',
|
|
358
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
359
|
-
}), {
|
|
256
|
+
await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
|
|
360
257
|
family: 4,
|
|
361
258
|
headers: {
|
|
362
|
-
'
|
|
363
|
-
'
|
|
259
|
+
'User-Agent': 'homebridge-adt-pulse',
|
|
260
|
+
'X-Title': 'Detected a new panel state and/or status',
|
|
364
261
|
},
|
|
365
262
|
});
|
|
263
|
+
return true;
|
|
366
264
|
}
|
|
367
265
|
catch (error) {
|
|
368
266
|
if (debugMode === true) {
|
|
369
267
|
debugLog(logger, 'detect.ts / detectedNewPanelStatus()', 'error', 'Failed to notify plugin author about the new panel state and/or status');
|
|
370
268
|
stackTracer('serialize-error', serializeError(error));
|
|
371
269
|
}
|
|
270
|
+
return false;
|
|
372
271
|
}
|
|
373
|
-
return true;
|
|
374
272
|
}
|
|
375
273
|
return false;
|
|
376
274
|
}
|
|
377
275
|
export async function detectedNewPortalVersion(version, logger, debugMode) {
|
|
378
|
-
const
|
|
379
|
-
'16.0.0-131',
|
|
380
|
-
'17.0.0-69',
|
|
381
|
-
'18.0.0-78',
|
|
382
|
-
'19.0.0-89',
|
|
383
|
-
'20.0.0-221',
|
|
384
|
-
'20.0.0-244',
|
|
385
|
-
'21.0.0-344',
|
|
386
|
-
'21.0.0-353',
|
|
387
|
-
'21.0.0-354',
|
|
388
|
-
'22.0.0-233',
|
|
389
|
-
'23.0.0-99',
|
|
390
|
-
'24.0.0-117',
|
|
391
|
-
'25.0.0-21',
|
|
392
|
-
'26.0.0-32',
|
|
393
|
-
'27.0.0-140',
|
|
394
|
-
];
|
|
395
|
-
const detectedNewVersion = (version.version !== null && !knownVersions.includes(version.version));
|
|
276
|
+
const detectedNewVersion = (version.version !== null && !portalVersionItems.includes(version.version));
|
|
396
277
|
if (detectedNewVersion) {
|
|
397
278
|
const cleanedData = removePersonalIdentifiableInformation(version);
|
|
398
279
|
try {
|
|
@@ -412,59 +293,39 @@ export async function detectedNewPortalVersion(version, logger, debugMode) {
|
|
|
412
293
|
debugLog(logger, 'detect.ts / detectedNewPortalVersion()', 'error', 'Failed to check if plugin is outdated');
|
|
413
294
|
stackTracer('serialize-error', serializeError(error));
|
|
414
295
|
}
|
|
296
|
+
return false;
|
|
415
297
|
}
|
|
416
298
|
if (logger !== null) {
|
|
417
299
|
logger.warn('Plugin has detected a new portal version. Notifying plugin author about this discovery ...');
|
|
300
|
+
logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
|
|
418
301
|
}
|
|
419
302
|
if (debugMode) {
|
|
420
303
|
debugLog(logger, 'detect.ts / detectedNewPortalVersion()', 'warn', 'Plugin has detected a new portal version. Notifying plugin author about this discovery');
|
|
421
304
|
}
|
|
422
305
|
stackTracer('detect-content', cleanedData);
|
|
423
306
|
try {
|
|
424
|
-
await axios.post(
|
|
425
|
-
title: 'Detected a new portal version',
|
|
426
|
-
description: 'A new portal version detected. Please update the plugin as soon as possible.',
|
|
427
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
428
|
-
}), {
|
|
307
|
+
await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
|
|
429
308
|
family: 4,
|
|
430
309
|
headers: {
|
|
431
|
-
'
|
|
432
|
-
'
|
|
310
|
+
'User-Agent': 'homebridge-adt-pulse',
|
|
311
|
+
'X-Title': 'Detected a new portal version',
|
|
433
312
|
},
|
|
434
313
|
});
|
|
314
|
+
return true;
|
|
435
315
|
}
|
|
436
316
|
catch (error) {
|
|
437
317
|
if (debugMode === true) {
|
|
438
318
|
debugLog(logger, 'detect.ts / detectedNewPortalVersion()', 'error', 'Failed to notify plugin author about the new portal version');
|
|
439
319
|
stackTracer('serialize-error', serializeError(error));
|
|
440
320
|
}
|
|
321
|
+
return false;
|
|
441
322
|
}
|
|
442
|
-
return true;
|
|
443
323
|
}
|
|
444
324
|
return false;
|
|
445
325
|
}
|
|
446
326
|
export async function detectedNewSensorsInformation(sensors, logger, debugMode) {
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
'Carbon Monoxide Detector',
|
|
450
|
-
'Door/Window Sensor',
|
|
451
|
-
'Door Sensor',
|
|
452
|
-
'Fire (Smoke/Heat) Detector',
|
|
453
|
-
'Glass Break Detector',
|
|
454
|
-
'Keypad/Touchpad',
|
|
455
|
-
'Motion Sensor',
|
|
456
|
-
'Motion Sensor (Notable Events Only)',
|
|
457
|
-
'Silent Panic Button/Pendant',
|
|
458
|
-
'Temperature Sensor',
|
|
459
|
-
'Water/Flood Sensor',
|
|
460
|
-
'Window Sensor',
|
|
461
|
-
];
|
|
462
|
-
const knownStatuses = [
|
|
463
|
-
'Online',
|
|
464
|
-
'Status Unknown',
|
|
465
|
-
];
|
|
466
|
-
const detectedNewInformation = sensors.filter((sensor) => (!knownDeviceTypes.includes(sensor.deviceType)
|
|
467
|
-
|| !knownStatuses.includes(sensor.status)));
|
|
327
|
+
const detectedNewInformation = sensors.filter((sensor) => (!sensorInformationDeviceTypeItems.includes(sensor.deviceType)
|
|
328
|
+
|| !sensorInformationStatusItems.includes(sensor.status)));
|
|
468
329
|
if (detectedNewInformation.length > 0) {
|
|
469
330
|
const cleanedData = removePersonalIdentifiableInformation(detectedNewInformation);
|
|
470
331
|
try {
|
|
@@ -484,61 +345,38 @@ export async function detectedNewSensorsInformation(sensors, logger, debugMode)
|
|
|
484
345
|
debugLog(logger, 'detect.ts / detectedNewSensorsInformation()', 'error', 'Failed to check if plugin is outdated');
|
|
485
346
|
stackTracer('serialize-error', serializeError(error));
|
|
486
347
|
}
|
|
348
|
+
return false;
|
|
487
349
|
}
|
|
488
350
|
if (logger !== null) {
|
|
489
351
|
logger.warn('Plugin has detected new sensors information. Notifying plugin author about this discovery ...');
|
|
352
|
+
logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
|
|
490
353
|
}
|
|
491
354
|
if (debugMode) {
|
|
492
355
|
debugLog(logger, 'detect.ts / detectedNewSensorsInformation()', 'warn', 'Plugin has detected new sensors information. Notifying plugin author about this discovery');
|
|
493
356
|
}
|
|
494
357
|
stackTracer('detect-content', cleanedData);
|
|
495
358
|
try {
|
|
496
|
-
await axios.post(
|
|
497
|
-
title: 'Detected new sensors information',
|
|
498
|
-
description: 'New sensors information detected. Please update the plugin as soon as possible.',
|
|
499
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
500
|
-
}), {
|
|
359
|
+
await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
|
|
501
360
|
family: 4,
|
|
502
361
|
headers: {
|
|
503
|
-
'
|
|
504
|
-
'
|
|
362
|
+
'User-Agent': 'homebridge-adt-pulse',
|
|
363
|
+
'X-Title': 'Detected new sensors information',
|
|
505
364
|
},
|
|
506
365
|
});
|
|
366
|
+
return true;
|
|
507
367
|
}
|
|
508
368
|
catch (error) {
|
|
509
369
|
if (debugMode === true) {
|
|
510
370
|
debugLog(logger, 'detect.ts / detectedNewSensorsInformation()', 'error', 'Failed to notify plugin author about the new sensors information');
|
|
511
371
|
stackTracer('serialize-error', serializeError(error));
|
|
512
372
|
}
|
|
373
|
+
return false;
|
|
513
374
|
}
|
|
514
|
-
return true;
|
|
515
375
|
}
|
|
516
376
|
return false;
|
|
517
377
|
}
|
|
518
378
|
export async function detectedNewSensorsStatus(sensors, logger, debugMode) {
|
|
519
|
-
const
|
|
520
|
-
'devStatAlarm',
|
|
521
|
-
'devStatLowBatt',
|
|
522
|
-
'devStatMotion',
|
|
523
|
-
'devStatOK',
|
|
524
|
-
'devStatOpen',
|
|
525
|
-
'devStatTamper',
|
|
526
|
-
'devStatUnknown',
|
|
527
|
-
];
|
|
528
|
-
const knownStatuses = [
|
|
529
|
-
'ALARM, Okay',
|
|
530
|
-
'ALARM, Open',
|
|
531
|
-
'Bypassed, Open',
|
|
532
|
-
'Closed',
|
|
533
|
-
'Motion',
|
|
534
|
-
'No Motion',
|
|
535
|
-
'Okay',
|
|
536
|
-
'Open',
|
|
537
|
-
'Tripped',
|
|
538
|
-
'Unknown',
|
|
539
|
-
];
|
|
540
|
-
const detectedNewStatuses = sensors.filter((sensor) => (!knownIcons.includes(sensor.icon)
|
|
541
|
-
|| !knownStatuses.includes(sensor.status)));
|
|
379
|
+
const detectedNewStatuses = sensors.filter((sensor) => !sensorStatusIconItems.includes(sensor.icon) || sensor.statuses.some((sensorStatus) => !sensorStatusStatusItems.includes(sensorStatus)));
|
|
542
380
|
if (detectedNewStatuses.length > 0) {
|
|
543
381
|
const cleanedData = removePersonalIdentifiableInformation(detectedNewStatuses);
|
|
544
382
|
try {
|
|
@@ -558,34 +396,144 @@ export async function detectedNewSensorsStatus(sensors, logger, debugMode) {
|
|
|
558
396
|
debugLog(logger, 'detect.ts / detectedNewSensorsStatus()', 'error', 'Failed to check if plugin is outdated');
|
|
559
397
|
stackTracer('serialize-error', serializeError(error));
|
|
560
398
|
}
|
|
399
|
+
return false;
|
|
561
400
|
}
|
|
562
401
|
if (logger !== null) {
|
|
563
402
|
logger.warn('Plugin has detected new sensors status. Notifying plugin author about this discovery ...');
|
|
403
|
+
logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
|
|
564
404
|
}
|
|
565
405
|
if (debugMode) {
|
|
566
406
|
debugLog(logger, 'detect.ts / detectedNewSensorsStatus()', 'warn', 'Plugin has detected new sensors status. Notifying plugin author about this discovery');
|
|
567
407
|
}
|
|
568
408
|
stackTracer('detect-content', cleanedData);
|
|
569
409
|
try {
|
|
570
|
-
await axios.post(
|
|
571
|
-
title: 'Detected new sensors status',
|
|
572
|
-
description: 'New sensors status detected. Please update the plugin as soon as possible.',
|
|
573
|
-
content: JSON.stringify(cleanedData, null, 2),
|
|
574
|
-
}), {
|
|
410
|
+
await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
|
|
575
411
|
family: 4,
|
|
576
412
|
headers: {
|
|
577
|
-
'
|
|
578
|
-
'
|
|
413
|
+
'User-Agent': 'homebridge-adt-pulse',
|
|
414
|
+
'X-Title': 'Detected new sensors status',
|
|
579
415
|
},
|
|
580
416
|
});
|
|
417
|
+
return true;
|
|
581
418
|
}
|
|
582
419
|
catch (error) {
|
|
583
420
|
if (debugMode === true) {
|
|
584
421
|
debugLog(logger, 'detect.ts / detectedNewSensorsStatus()', 'error', 'Failed to notify plugin author about the new sensors status');
|
|
585
422
|
stackTracer('serialize-error', serializeError(error));
|
|
586
423
|
}
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return false;
|
|
428
|
+
}
|
|
429
|
+
export async function detectedSensorCountMismatch(data, logger, debugMode) {
|
|
430
|
+
const detectedCountMismatch = data.sensorsInfo.length !== data.sensorsStatus.length;
|
|
431
|
+
if (detectedCountMismatch) {
|
|
432
|
+
const cleanedData = removePersonalIdentifiableInformation(data);
|
|
433
|
+
try {
|
|
434
|
+
const outdated = await isPluginOutdated();
|
|
435
|
+
if (outdated) {
|
|
436
|
+
if (logger !== null) {
|
|
437
|
+
logger.warn('Plugin has detected a sensor count mismatch. You are running an older plugin version, please update soon.');
|
|
438
|
+
}
|
|
439
|
+
if (debugMode) {
|
|
440
|
+
debugLog(logger, 'detect.ts / detectedSensorCountMismatch()', 'warn', 'Plugin has detected a sensor count mismatch. You are running an older plugin version, please update soon');
|
|
441
|
+
}
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
if (debugMode === true) {
|
|
447
|
+
debugLog(logger, 'detect.ts / detectedSensorCountMismatch()', 'error', 'Failed to check if plugin is outdated');
|
|
448
|
+
stackTracer('serialize-error', serializeError(error));
|
|
449
|
+
}
|
|
450
|
+
return false;
|
|
451
|
+
}
|
|
452
|
+
if (logger !== null) {
|
|
453
|
+
logger.warn('Plugin has detected a sensor count mismatch. Notifying plugin author about this discovery ...');
|
|
454
|
+
logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
|
|
455
|
+
}
|
|
456
|
+
if (debugMode) {
|
|
457
|
+
debugLog(logger, 'detect.ts / detectedSensorCountMismatch()', 'warn', 'Plugin has detected a sensor count mismatch. Notifying plugin author about this discovery');
|
|
458
|
+
}
|
|
459
|
+
stackTracer('detect-content', cleanedData);
|
|
460
|
+
try {
|
|
461
|
+
await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
|
|
462
|
+
family: 4,
|
|
463
|
+
headers: {
|
|
464
|
+
'User-Agent': 'homebridge-adt-pulse',
|
|
465
|
+
'X-Title': 'Detected a sensor count mismatch',
|
|
466
|
+
},
|
|
467
|
+
});
|
|
468
|
+
return true;
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
if (debugMode === true) {
|
|
472
|
+
debugLog(logger, 'detect.ts / detectedSensorCountMismatch()', 'error', 'Failed to notify plugin author about the sensor count mismatch');
|
|
473
|
+
stackTracer('serialize-error', serializeError(error));
|
|
474
|
+
}
|
|
475
|
+
return false;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
export async function detectedUnknownSensorsAction(sensors, logger, debugMode) {
|
|
481
|
+
const detectedNewActions = sensors.filter((sensor) => {
|
|
482
|
+
const sensorStatusStatuses = sensor.status.statuses;
|
|
483
|
+
const sensorType = sensor.type;
|
|
484
|
+
const stringifiedStatuses = sensorStatusStatuses.join(', ');
|
|
485
|
+
const currentType = sensorActionItems.find((sensorActionItem) => sensorActionItem.type === sensorType);
|
|
486
|
+
if (currentType === undefined) {
|
|
487
|
+
return false;
|
|
488
|
+
}
|
|
489
|
+
return !currentType.statuses.includes(stringifiedStatuses);
|
|
490
|
+
});
|
|
491
|
+
if (detectedNewActions.length > 0) {
|
|
492
|
+
const cleanedData = removePersonalIdentifiableInformation(detectedNewActions);
|
|
493
|
+
try {
|
|
494
|
+
const outdated = await isPluginOutdated();
|
|
495
|
+
if (outdated) {
|
|
496
|
+
if (logger !== null) {
|
|
497
|
+
logger.warn('Plugin has detected unknown sensors action. You are running an older plugin version, please update soon.');
|
|
498
|
+
}
|
|
499
|
+
if (debugMode) {
|
|
500
|
+
debugLog(logger, 'detect.ts / detectedUnknownSensorsAction()', 'warn', 'Plugin has detected unknown sensors action. You are running an older plugin version, please update soon');
|
|
501
|
+
}
|
|
502
|
+
return false;
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
catch (error) {
|
|
506
|
+
if (debugMode === true) {
|
|
507
|
+
debugLog(logger, 'detect.ts / detectedUnknownSensorsAction()', 'error', 'Failed to check if plugin is outdated');
|
|
508
|
+
stackTracer('serialize-error', serializeError(error));
|
|
509
|
+
}
|
|
510
|
+
return false;
|
|
511
|
+
}
|
|
512
|
+
if (logger !== null) {
|
|
513
|
+
logger.warn('Plugin has detected unknown sensors action. Notifying plugin author about this discovery ...');
|
|
514
|
+
logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
|
|
515
|
+
}
|
|
516
|
+
if (debugMode) {
|
|
517
|
+
debugLog(logger, 'detect.ts / detectedUnknownSensorsAction()', 'warn', 'Plugin has detected unknown sensors action. Notifying plugin author about this discovery');
|
|
518
|
+
}
|
|
519
|
+
stackTracer('detect-content', cleanedData);
|
|
520
|
+
try {
|
|
521
|
+
await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
|
|
522
|
+
family: 4,
|
|
523
|
+
headers: {
|
|
524
|
+
'User-Agent': 'homebridge-adt-pulse',
|
|
525
|
+
'X-Title': 'Detected unknown sensors action',
|
|
526
|
+
},
|
|
527
|
+
});
|
|
528
|
+
return true;
|
|
529
|
+
}
|
|
530
|
+
catch (error) {
|
|
531
|
+
if (debugMode === true) {
|
|
532
|
+
debugLog(logger, 'detect.ts / detectedUnknownSensorsAction()', 'error', 'Failed to notify plugin author about the unknown sensors action');
|
|
533
|
+
stackTracer('serialize-error', serializeError(error));
|
|
534
|
+
}
|
|
535
|
+
return false;
|
|
587
536
|
}
|
|
588
|
-
return true;
|
|
589
537
|
}
|
|
590
538
|
return false;
|
|
591
539
|
}
|