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