homebridge-adt-pulse 3.0.0-beta.9 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,44 +1,64 @@
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 { debugLog, isPluginOutdated, removePersonalIdentifiableInformation, stackTracer, } from './utility.js';
6
- export async function detectedNewDoSubmitHandlers(handlers, logger, debugMode) {
7
- const knownRelativeUrls = [
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)
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';
5
+ export async function detectApiDebugParser(data, logger, debugMode) {
6
+ const cleanedData = removePersonalIdentifiableInformation(data);
7
+ try {
8
+ const outdated = await isPluginOutdated();
9
+ if (outdated) {
10
+ if (logger !== null) {
11
+ logger.warn(`Plugin has detected a parser anomaly for "${data.parserName}" due to ${data.parserReason}. You are running an older plugin version, please update soon.`);
12
+ }
13
+ if (debugMode) {
14
+ debugLog(logger, 'detect.ts / detectApiDebugParser()', 'warn', `Plugin has detected a parser anomaly for "${data.parserName}" due to ${data.parserReason}. 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 / detectApiDebugParser()', '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 a parser anomaly for "${data.parserName}" due to ${data.parserReason}. Notifying plugin author about this discovery ...`);
28
+ }
29
+ if (debugMode) {
30
+ debugLog(logger, 'detect.ts / detectApiDebugParser()', 'warn', `Plugin has detected a parser anomaly for "${data.parserName}" due to ${data.parserReason}. Notifying plugin author about this discovery`);
31
+ }
32
+ stackTracer('detect-content', cleanedData);
33
+ if (logger !== null) {
34
+ logger.warn('For transparency, the section of code you see above will be sent to the author directly. Rest assured, your privacy is prioritized.');
35
+ logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
36
+ }
37
+ try {
38
+ await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
39
+ family: 4,
40
+ headers: {
41
+ 'User-Agent': 'homebridge-adt-pulse',
42
+ 'X-Title': `Detected a parser anomaly for "${data.parserName}" due to ${data.parserReason}`,
43
+ },
44
+ });
45
+ return true;
46
+ }
47
+ catch (error) {
48
+ if (debugMode === true) {
49
+ debugLog(logger, 'detect.ts / detectApiDebugParser()', 'error', `Failed to notify plugin author about the parser anomaly for "${data.parserName}" due to ${data.parserReason}`);
50
+ stackTracer('serialize-error', serializeError(error));
51
+ }
52
+ return false;
53
+ }
54
+ }
55
+ export async function detectApiDoSubmitHandlers(handlers, logger, debugMode) {
56
+ const detectedNewHandlers = handlers.filter((handler) => (!doSubmitHandlerRelativeUrlItems.includes(handler.relativeUrl)
37
57
  || (handler.urlParams.arm !== null
38
- && !knownUrlParamsArm.includes(handler.urlParams.arm))
58
+ && !doSubmitHandlerUrlParamsArmItems.includes(handler.urlParams.arm))
39
59
  || (handler.urlParams.armState !== null
40
- && !knownUrlParamsArmState.includes(handler.urlParams.armState))
41
- || !knownUrlParamsHref.includes(handler.urlParams.href)));
60
+ && !doSubmitHandlerUrlParamsArmStateItems.includes(handler.urlParams.armState))
61
+ || !doSubmitHandlerUrlParamsHrefItems.includes(handler.urlParams.href)));
42
62
  if (detectedNewHandlers.length > 0) {
43
63
  const cleanedData = removePersonalIdentifiableInformation(detectedNewHandlers);
44
64
  try {
@@ -48,53 +68,51 @@ export async function detectedNewDoSubmitHandlers(handlers, logger, debugMode) {
48
68
  logger.warn('Plugin has detected new do submit handlers. You are running an older plugin version, please update soon.');
49
69
  }
50
70
  if (debugMode) {
51
- debugLog(logger, 'detect.ts / detectedNewDoSubmitHandlers()', 'warn', 'Plugin has detected new do submit handlers. You are running an older plugin version, please update soon');
71
+ debugLog(logger, 'detect.ts / detectApiDoSubmitHandlers()', 'warn', 'Plugin has detected new do submit handlers. You are running an older plugin version, please update soon');
52
72
  }
53
73
  return false;
54
74
  }
55
75
  }
56
76
  catch (error) {
57
77
  if (debugMode === true) {
58
- debugLog(logger, 'detect.ts / detectedNewDoSubmitHandlers()', 'error', 'Failed to check if plugin is outdated');
78
+ debugLog(logger, 'detect.ts / detectApiDoSubmitHandlers()', 'error', 'Failed to check if plugin is outdated');
59
79
  stackTracer('serialize-error', serializeError(error));
60
80
  }
81
+ return false;
61
82
  }
62
83
  if (logger !== null) {
63
84
  logger.warn('Plugin has detected new do submit handlers. Notifying plugin author about this discovery ...');
64
85
  }
65
86
  if (debugMode) {
66
- debugLog(logger, 'detect.ts / detectedNewDoSubmitHandlers()', 'warn', 'Plugin has detected new do submit handlers. Notifying plugin author about this discovery');
87
+ debugLog(logger, 'detect.ts / detectApiDoSubmitHandlers()', 'warn', 'Plugin has detected new do submit handlers. Notifying plugin author about this discovery');
67
88
  }
68
89
  stackTracer('detect-content', cleanedData);
90
+ if (logger !== null) {
91
+ logger.warn('For transparency, the section of code you see above will be sent to the author directly. Rest assured, your privacy is prioritized.');
92
+ logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
93
+ }
69
94
  try {
70
- await axios.post('https://9wv5o73w.ntfy.mrjackyliang.com', JSON.stringify({
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
- }), {
95
+ await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
75
96
  family: 4,
76
97
  headers: {
77
- 'Content-Type': 'application/json',
78
- 'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? 'unknown'}`,
98
+ 'User-Agent': 'homebridge-adt-pulse',
99
+ 'X-Title': 'Detected new do submit handlers',
79
100
  },
80
101
  });
102
+ return true;
81
103
  }
82
104
  catch (error) {
83
105
  if (debugMode === true) {
84
- debugLog(logger, 'detect.ts / detectedNewDoSubmitHandlers()', 'error', 'Failed to notify plugin author about the new do submit handlers');
106
+ debugLog(logger, 'detect.ts / detectApiDoSubmitHandlers()', 'error', 'Failed to notify plugin author about the new do submit handlers');
85
107
  stackTracer('serialize-error', serializeError(error));
86
108
  }
109
+ return false;
87
110
  }
88
- return true;
89
111
  }
90
112
  return false;
91
113
  }
92
- export async function detectedNewGatewayInformation(device, logger, debugMode) {
93
- const knownStatuses = [
94
- 'Online',
95
- 'Status Unknown',
96
- ];
97
- const detectedNewStatus = (device.status !== null && !knownStatuses.includes(device.status));
114
+ export async function detectApiGatewayInformation(device, logger, debugMode) {
115
+ const detectedNewStatus = (device.status !== null && !gatewayInformationStatusItems.includes(device.status));
98
116
  if (detectedNewStatus) {
99
117
  const cleanedData = removePersonalIdentifiableInformation(device);
100
118
  try {
@@ -104,94 +122,61 @@ export async function detectedNewGatewayInformation(device, logger, debugMode) {
104
122
  logger.warn('Plugin has detected new gateway information. You are running an older plugin version, please update soon.');
105
123
  }
106
124
  if (debugMode) {
107
- debugLog(logger, 'detect.ts / detectedNewGatewayInformation()', 'warn', 'Plugin has detected new gateway information. You are running an older plugin version, please update soon');
125
+ debugLog(logger, 'detect.ts / detectApiGatewayInformation()', 'warn', 'Plugin has detected new gateway information. You are running an older plugin version, please update soon');
108
126
  }
109
127
  return false;
110
128
  }
111
129
  }
112
130
  catch (error) {
113
131
  if (debugMode === true) {
114
- debugLog(logger, 'detect.ts / detectedNewGatewayInformation()', 'error', 'Failed to check if plugin is outdated');
132
+ debugLog(logger, 'detect.ts / detectApiGatewayInformation()', 'error', 'Failed to check if plugin is outdated');
115
133
  stackTracer('serialize-error', serializeError(error));
116
134
  }
135
+ return false;
117
136
  }
118
137
  if (logger !== null) {
119
138
  logger.warn('Plugin has detected new gateway information. Notifying plugin author about this discovery ...');
120
139
  }
121
140
  if (debugMode) {
122
- debugLog(logger, 'detect.ts / detectedNewGatewayInformation()', 'warn', 'Plugin has detected new gateway information. Notifying plugin author about this discovery');
141
+ debugLog(logger, 'detect.ts / detectApiGatewayInformation()', 'warn', 'Plugin has detected new gateway information. Notifying plugin author about this discovery');
123
142
  }
124
143
  stackTracer('detect-content', cleanedData);
144
+ if (logger !== null) {
145
+ logger.warn('For transparency, the section of code you see above will be sent to the author directly. Rest assured, your privacy is prioritized.');
146
+ logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
147
+ }
125
148
  try {
126
- await axios.post('https://9wv5o73w.ntfy.mrjackyliang.com', JSON.stringify({
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
- }), {
149
+ await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
131
150
  family: 4,
132
151
  headers: {
133
- 'Content-Type': 'application/json',
134
- 'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? 'unknown'}`,
152
+ 'User-Agent': 'homebridge-adt-pulse',
153
+ 'X-Title': 'Detected new gateway information',
135
154
  },
136
155
  });
156
+ return true;
137
157
  }
138
158
  catch (error) {
139
159
  if (debugMode === true) {
140
- debugLog(logger, 'detect.ts / detectedNewGatewayInformation()', 'error', 'Failed to notify plugin author about the new gateway information');
160
+ debugLog(logger, 'detect.ts / detectApiGatewayInformation()', 'error', 'Failed to notify plugin author about the new gateway information');
141
161
  stackTracer('serialize-error', serializeError(error));
142
162
  }
163
+ return false;
143
164
  }
144
- return true;
145
165
  }
146
166
  return false;
147
167
  }
148
- 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
- ];
168
+ export async function detectApiOrbSecurityButtons(buttons, logger, debugMode) {
184
169
  const detectedNewButtons = buttons.filter((button) => ((!button.buttonDisabled
185
170
  && ((button.buttonText !== null
186
- && !knownButtonText.includes(button.buttonText))
187
- || !knownLoadingText.includes(button.loadingText)
188
- || !knownRelativeUrl.includes(button.relativeUrl)
189
- || !knownUrlParamsArm.includes(button.urlParams.arm)
190
- || !knownUrlParamsArmState.includes(button.urlParams.armState)
191
- || !knownUrlParamsHref.includes(button.urlParams.href)))
171
+ && !orbSecurityButtonButtonTextItems.includes(button.buttonText))
172
+ || !orbSecurityButtonLoadingTextItems.includes(button.loadingText)
173
+ || !orbSecurityButtonRelativeUrlItems.includes(button.relativeUrl)
174
+ || !orbSecurityButtonUrlParamsArmItems.includes(button.urlParams.arm)
175
+ || !orbSecurityButtonUrlParamsArmStateItems.includes(button.urlParams.armState)
176
+ || !orbSecurityButtonUrlParamsHrefItems.includes(button.urlParams.href)))
192
177
  || (button.buttonDisabled
193
178
  && (button.buttonText !== null
194
- && !knownLoadingText.includes(button.buttonText)))));
179
+ && !orbSecurityButtonLoadingTextItems.includes(button.buttonText)))));
195
180
  if (detectedNewButtons.length > 0) {
196
181
  const cleanedData = removePersonalIdentifiableInformation(detectedNewButtons);
197
182
  try {
@@ -201,53 +186,51 @@ export async function detectedNewOrbSecurityButtons(buttons, logger, debugMode)
201
186
  logger.warn('Plugin has detected new orb security buttons. You are running an older plugin version, please update soon.');
202
187
  }
203
188
  if (debugMode) {
204
- debugLog(logger, 'detect.ts / detectedNewOrbSecurityButtons()', 'warn', 'Plugin has detected new orb security buttons. You are running an older plugin version, please update soon');
189
+ debugLog(logger, 'detect.ts / detectApiOrbSecurityButtons()', 'warn', 'Plugin has detected new orb security buttons. You are running an older plugin version, please update soon');
205
190
  }
206
191
  return false;
207
192
  }
208
193
  }
209
194
  catch (error) {
210
195
  if (debugMode === true) {
211
- debugLog(logger, 'detect.ts / detectedNewOrbSecurityButtons()', 'error', 'Failed to check if plugin is outdated');
196
+ debugLog(logger, 'detect.ts / detectApiOrbSecurityButtons()', 'error', 'Failed to check if plugin is outdated');
212
197
  stackTracer('serialize-error', serializeError(error));
213
198
  }
199
+ return false;
214
200
  }
215
201
  if (logger !== null) {
216
202
  logger.warn('Plugin has detected new orb security buttons. Notifying plugin author about this discovery ...');
217
203
  }
218
204
  if (debugMode) {
219
- debugLog(logger, 'detect.ts / detectedNewOrbSecurityButtons()', 'warn', 'Plugin has detected new orb security buttons. Notifying plugin author about this discovery');
205
+ debugLog(logger, 'detect.ts / detectApiOrbSecurityButtons()', 'warn', 'Plugin has detected new orb security buttons. Notifying plugin author about this discovery');
220
206
  }
221
207
  stackTracer('detect-content', cleanedData);
208
+ if (logger !== null) {
209
+ logger.warn('For transparency, the section of code you see above will be sent to the author directly. Rest assured, your privacy is prioritized.');
210
+ logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
211
+ }
222
212
  try {
223
- await axios.post('https://9wv5o73w.ntfy.mrjackyliang.com', JSON.stringify({
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
- }), {
213
+ await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
228
214
  family: 4,
229
215
  headers: {
230
- 'Content-Type': 'application/json',
231
- 'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? 'unknown'}`,
216
+ 'User-Agent': 'homebridge-adt-pulse',
217
+ 'X-Title': 'Detected new orb security buttons',
232
218
  },
233
219
  });
220
+ return true;
234
221
  }
235
222
  catch (error) {
236
223
  if (debugMode === true) {
237
- debugLog(logger, 'detect.ts / detectedNewOrbSecurityButtons()', 'error', 'Failed to notify plugin author about the new orb security buttons');
224
+ debugLog(logger, 'detect.ts / detectApiOrbSecurityButtons()', 'error', 'Failed to notify plugin author about the new orb security buttons');
238
225
  stackTracer('serialize-error', serializeError(error));
239
226
  }
227
+ return false;
240
228
  }
241
- return true;
242
229
  }
243
230
  return false;
244
231
  }
245
- export async function detectedNewPanelInformation(device, logger, debugMode) {
246
- const knownStatuses = [
247
- 'Online',
248
- 'Status Unknown',
249
- ];
250
- const detectedNewStatus = (device.status !== null && !knownStatuses.includes(device.status));
232
+ export async function detectApiPanelInformation(device, logger, debugMode) {
233
+ const detectedNewStatus = (device.status !== null && !panelInformationStatusItems.includes(device.status));
251
234
  if (detectedNewStatus) {
252
235
  const cleanedData = removePersonalIdentifiableInformation(device);
253
236
  try {
@@ -257,74 +240,52 @@ export async function detectedNewPanelInformation(device, logger, debugMode) {
257
240
  logger.warn('Plugin has detected new panel information. You are running an older plugin version, please update soon.');
258
241
  }
259
242
  if (debugMode) {
260
- debugLog(logger, 'detect.ts / detectedNewPanelInformation()', 'warn', 'Plugin has detected new panel information. You are running an older plugin version, please update soon');
243
+ debugLog(logger, 'detect.ts / detectApiPanelInformation()', 'warn', 'Plugin has detected new panel information. You are running an older plugin version, please update soon');
261
244
  }
262
245
  return false;
263
246
  }
264
247
  }
265
248
  catch (error) {
266
249
  if (debugMode === true) {
267
- debugLog(logger, 'detect.ts / detectedNewPanelInformation()', 'error', 'Failed to check if plugin is outdated');
250
+ debugLog(logger, 'detect.ts / detectApiPanelInformation()', 'error', 'Failed to check if plugin is outdated');
268
251
  stackTracer('serialize-error', serializeError(error));
269
252
  }
253
+ return false;
270
254
  }
271
255
  if (logger !== null) {
272
256
  logger.warn('Plugin has detected new panel information. Notifying plugin author about this discovery ...');
273
257
  }
274
258
  if (debugMode) {
275
- debugLog(logger, 'detect.ts / detectedNewPanelInformation()', 'warn', 'Plugin has detected new panel information. Notifying plugin author about this discovery');
259
+ debugLog(logger, 'detect.ts / detectApiPanelInformation()', 'warn', 'Plugin has detected new panel information. Notifying plugin author about this discovery');
276
260
  }
277
261
  stackTracer('detect-content', cleanedData);
262
+ if (logger !== null) {
263
+ logger.warn('For transparency, the section of code you see above will be sent to the author directly. Rest assured, your privacy is prioritized.');
264
+ logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
265
+ }
278
266
  try {
279
- await axios.post('https://9wv5o73w.ntfy.mrjackyliang.com', JSON.stringify({
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
- }), {
267
+ await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
284
268
  family: 4,
285
269
  headers: {
286
- 'Content-Type': 'application/json',
287
- 'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? 'unknown'}`,
270
+ 'User-Agent': 'homebridge-adt-pulse',
271
+ 'X-Title': 'Detected new panel information',
288
272
  },
289
273
  });
274
+ return true;
290
275
  }
291
276
  catch (error) {
292
277
  if (debugMode === true) {
293
- debugLog(logger, 'detect.ts / detectedNewPanelInformation()', 'error', 'Failed to notify plugin author about the new panel information');
278
+ debugLog(logger, 'detect.ts / detectApiPanelInformation()', 'error', 'Failed to notify plugin author about the new panel information');
294
279
  stackTracer('serialize-error', serializeError(error));
295
280
  }
281
+ return false;
296
282
  }
297
- return true;
298
283
  }
299
284
  return false;
300
285
  }
301
- export async function detectedNewPanelStatus(summary, logger, debugMode) {
302
- const knownStates = [
303
- 'Armed Away',
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) {
286
+ export async function detectApiPanelStatus(summary, logger, debugMode) {
287
+ const detectedUnknownPieces = summary.rawData.unknownPieces.length > 0;
288
+ if (detectedUnknownPieces) {
328
289
  const cleanedData = removePersonalIdentifiableInformation(summary);
329
290
  try {
330
291
  const outdated = await isPluginOutdated();
@@ -333,66 +294,51 @@ export async function detectedNewPanelStatus(summary, logger, debugMode) {
333
294
  logger.warn('Plugin has detected a new panel state and/or status. You are running an older plugin version, please update soon.');
334
295
  }
335
296
  if (debugMode) {
336
- debugLog(logger, 'detect.ts / detectedNewPanelStatus()', 'warn', 'Plugin has detected a new panel state and/or status. You are running an older plugin version, please update soon');
297
+ debugLog(logger, 'detect.ts / detectApiPanelStatus()', 'warn', 'Plugin has detected a new panel state and/or status. You are running an older plugin version, please update soon');
337
298
  }
338
299
  return false;
339
300
  }
340
301
  }
341
302
  catch (error) {
342
303
  if (debugMode === true) {
343
- debugLog(logger, 'detect.ts / detectedNewPanelStatus()', 'error', 'Failed to check if plugin is outdated');
304
+ debugLog(logger, 'detect.ts / detectApiPanelStatus()', 'error', 'Failed to check if plugin is outdated');
344
305
  stackTracer('serialize-error', serializeError(error));
345
306
  }
307
+ return false;
346
308
  }
347
309
  if (logger !== null) {
348
310
  logger.warn('Plugin has detected a new panel state and/or status. Notifying plugin author about this discovery ...');
349
311
  }
350
312
  if (debugMode) {
351
- debugLog(logger, 'detect.ts / detectedNewPanelStatus()', 'warn', 'Plugin has detected a new panel state and/or status. Notifying plugin author about this discovery');
313
+ debugLog(logger, 'detect.ts / detectApiPanelStatus()', 'warn', 'Plugin has detected a new panel state and/or status. Notifying plugin author about this discovery');
352
314
  }
353
315
  stackTracer('detect-content', cleanedData);
316
+ if (logger !== null) {
317
+ logger.warn('For transparency, the section of code you see above will be sent to the author directly. Rest assured, your privacy is prioritized.');
318
+ logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
319
+ }
354
320
  try {
355
- await axios.post('https://9wv5o73w.ntfy.mrjackyliang.com', JSON.stringify({
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
- }), {
321
+ await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
360
322
  family: 4,
361
323
  headers: {
362
- 'Content-Type': 'application/json',
363
- 'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? 'unknown'}`,
324
+ 'User-Agent': 'homebridge-adt-pulse',
325
+ 'X-Title': 'Detected a new panel state and/or status',
364
326
  },
365
327
  });
328
+ return true;
366
329
  }
367
330
  catch (error) {
368
331
  if (debugMode === true) {
369
- debugLog(logger, 'detect.ts / detectedNewPanelStatus()', 'error', 'Failed to notify plugin author about the new panel state and/or status');
332
+ debugLog(logger, 'detect.ts / detectApiPanelStatus()', 'error', 'Failed to notify plugin author about the new panel state and/or status');
370
333
  stackTracer('serialize-error', serializeError(error));
371
334
  }
335
+ return false;
372
336
  }
373
- return true;
374
337
  }
375
338
  return false;
376
339
  }
377
- export async function detectedNewPortalVersion(version, logger, debugMode) {
378
- const knownVersions = [
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));
340
+ export async function detectApiPortalVersion(version, logger, debugMode) {
341
+ const detectedNewVersion = (version.version !== null && !portalVersionItems.includes(version.version));
396
342
  if (detectedNewVersion) {
397
343
  const cleanedData = removePersonalIdentifiableInformation(version);
398
344
  try {
@@ -402,69 +348,52 @@ export async function detectedNewPortalVersion(version, logger, debugMode) {
402
348
  logger.warn('Plugin has detected a new portal version. You are running an older plugin version, please update soon.');
403
349
  }
404
350
  if (debugMode) {
405
- debugLog(logger, 'detect.ts / detectedNewPortalVersion()', 'warn', 'Plugin has detected a new portal version. You are running an older plugin version, please update soon');
351
+ debugLog(logger, 'detect.ts / detectApiPortalVersion()', 'warn', 'Plugin has detected a new portal version. You are running an older plugin version, please update soon');
406
352
  }
407
353
  return false;
408
354
  }
409
355
  }
410
356
  catch (error) {
411
357
  if (debugMode === true) {
412
- debugLog(logger, 'detect.ts / detectedNewPortalVersion()', 'error', 'Failed to check if plugin is outdated');
358
+ debugLog(logger, 'detect.ts / detectApiPortalVersion()', 'error', 'Failed to check if plugin is outdated');
413
359
  stackTracer('serialize-error', serializeError(error));
414
360
  }
361
+ return false;
415
362
  }
416
363
  if (logger !== null) {
417
364
  logger.warn('Plugin has detected a new portal version. Notifying plugin author about this discovery ...');
418
365
  }
419
366
  if (debugMode) {
420
- debugLog(logger, 'detect.ts / detectedNewPortalVersion()', 'warn', 'Plugin has detected a new portal version. Notifying plugin author about this discovery');
367
+ debugLog(logger, 'detect.ts / detectApiPortalVersion()', 'warn', 'Plugin has detected a new portal version. Notifying plugin author about this discovery');
421
368
  }
422
369
  stackTracer('detect-content', cleanedData);
370
+ if (logger !== null) {
371
+ logger.warn('For transparency, the section of code you see above will be sent to the author directly. Rest assured, your privacy is prioritized.');
372
+ logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
373
+ }
423
374
  try {
424
- await axios.post('https://9wv5o73w.ntfy.mrjackyliang.com', JSON.stringify({
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
- }), {
375
+ await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
429
376
  family: 4,
430
377
  headers: {
431
- 'Content-Type': 'application/json',
432
- 'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? 'unknown'}`,
378
+ 'User-Agent': 'homebridge-adt-pulse',
379
+ 'X-Title': 'Detected a new portal version',
433
380
  },
434
381
  });
382
+ return true;
435
383
  }
436
384
  catch (error) {
437
385
  if (debugMode === true) {
438
- debugLog(logger, 'detect.ts / detectedNewPortalVersion()', 'error', 'Failed to notify plugin author about the new portal version');
386
+ debugLog(logger, 'detect.ts / detectApiPortalVersion()', 'error', 'Failed to notify plugin author about the new portal version');
439
387
  stackTracer('serialize-error', serializeError(error));
440
388
  }
389
+ return false;
441
390
  }
442
- return true;
443
391
  }
444
392
  return false;
445
393
  }
446
- export async function detectedNewSensorsInformation(sensors, logger, debugMode) {
447
- const knownDeviceTypes = [
448
- 'Audible Panic Button/Pendant',
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)));
394
+ export async function detectApiSensorsInformation(sensors, logger, debugMode) {
395
+ const detectedNewInformation = sensors.filter((sensor) => (!sensorInformationDeviceTypeItems.includes(sensor.deviceType)
396
+ || !sensorInformationStatusItems.includes(sensor.status)));
468
397
  if (detectedNewInformation.length > 0) {
469
398
  const cleanedData = removePersonalIdentifiableInformation(detectedNewInformation);
470
399
  try {
@@ -474,71 +403,51 @@ export async function detectedNewSensorsInformation(sensors, logger, debugMode)
474
403
  logger.warn('Plugin has detected new sensors information. You are running an older plugin version, please update soon.');
475
404
  }
476
405
  if (debugMode) {
477
- debugLog(logger, 'detect.ts / detectedNewSensorsInformation()', 'warn', 'Plugin has detected new sensors information. You are running an older plugin version, please update soon');
406
+ debugLog(logger, 'detect.ts / detectApiSensorsInformation()', 'warn', 'Plugin has detected new sensors information. You are running an older plugin version, please update soon');
478
407
  }
479
408
  return false;
480
409
  }
481
410
  }
482
411
  catch (error) {
483
412
  if (debugMode === true) {
484
- debugLog(logger, 'detect.ts / detectedNewSensorsInformation()', 'error', 'Failed to check if plugin is outdated');
413
+ debugLog(logger, 'detect.ts / detectApiSensorsInformation()', 'error', 'Failed to check if plugin is outdated');
485
414
  stackTracer('serialize-error', serializeError(error));
486
415
  }
416
+ return false;
487
417
  }
488
418
  if (logger !== null) {
489
419
  logger.warn('Plugin has detected new sensors information. Notifying plugin author about this discovery ...');
490
420
  }
491
421
  if (debugMode) {
492
- debugLog(logger, 'detect.ts / detectedNewSensorsInformation()', 'warn', 'Plugin has detected new sensors information. Notifying plugin author about this discovery');
422
+ debugLog(logger, 'detect.ts / detectApiSensorsInformation()', 'warn', 'Plugin has detected new sensors information. Notifying plugin author about this discovery');
493
423
  }
494
424
  stackTracer('detect-content', cleanedData);
425
+ if (logger !== null) {
426
+ logger.warn('For transparency, the section of code you see above will be sent to the author directly. Rest assured, your privacy is prioritized.');
427
+ logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
428
+ }
495
429
  try {
496
- await axios.post('https://9wv5o73w.ntfy.mrjackyliang.com', JSON.stringify({
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
- }), {
430
+ await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
501
431
  family: 4,
502
432
  headers: {
503
- 'Content-Type': 'application/json',
504
- 'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? 'unknown'}`,
433
+ 'User-Agent': 'homebridge-adt-pulse',
434
+ 'X-Title': 'Detected new sensors information',
505
435
  },
506
436
  });
437
+ return true;
507
438
  }
508
439
  catch (error) {
509
440
  if (debugMode === true) {
510
- debugLog(logger, 'detect.ts / detectedNewSensorsInformation()', 'error', 'Failed to notify plugin author about the new sensors information');
441
+ debugLog(logger, 'detect.ts / detectApiSensorsInformation()', 'error', 'Failed to notify plugin author about the new sensors information');
511
442
  stackTracer('serialize-error', serializeError(error));
512
443
  }
444
+ return false;
513
445
  }
514
- return true;
515
446
  }
516
447
  return false;
517
448
  }
518
- export async function detectedNewSensorsStatus(sensors, logger, debugMode) {
519
- const knownIcons = [
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)));
449
+ export async function detectApiSensorsStatus(sensors, logger, debugMode) {
450
+ const detectedNewStatuses = sensors.filter((sensor) => !sensorStatusIconItems.includes(sensor.icon) || sensor.statuses.some((sensorStatus) => !sensorStatusStatusItems.includes(sensorStatus)));
542
451
  if (detectedNewStatuses.length > 0) {
543
452
  const cleanedData = removePersonalIdentifiableInformation(detectedNewStatuses);
544
453
  try {
@@ -548,44 +457,163 @@ export async function detectedNewSensorsStatus(sensors, logger, debugMode) {
548
457
  logger.warn('Plugin has detected new sensors status. You are running an older plugin version, please update soon.');
549
458
  }
550
459
  if (debugMode) {
551
- debugLog(logger, 'detect.ts / detectedNewSensorsStatus()', 'warn', 'Plugin has detected new sensors status. You are running an older plugin version, please update soon');
460
+ debugLog(logger, 'detect.ts / detectApiSensorsStatus()', 'warn', 'Plugin has detected new sensors status. You are running an older plugin version, please update soon');
552
461
  }
553
462
  return false;
554
463
  }
555
464
  }
556
465
  catch (error) {
557
466
  if (debugMode === true) {
558
- debugLog(logger, 'detect.ts / detectedNewSensorsStatus()', 'error', 'Failed to check if plugin is outdated');
467
+ debugLog(logger, 'detect.ts / detectApiSensorsStatus()', 'error', 'Failed to check if plugin is outdated');
559
468
  stackTracer('serialize-error', serializeError(error));
560
469
  }
470
+ return false;
561
471
  }
562
472
  if (logger !== null) {
563
473
  logger.warn('Plugin has detected new sensors status. Notifying plugin author about this discovery ...');
564
474
  }
565
475
  if (debugMode) {
566
- debugLog(logger, 'detect.ts / detectedNewSensorsStatus()', 'warn', 'Plugin has detected new sensors status. Notifying plugin author about this discovery');
476
+ debugLog(logger, 'detect.ts / detectApiSensorsStatus()', 'warn', 'Plugin has detected new sensors status. Notifying plugin author about this discovery');
567
477
  }
568
478
  stackTracer('detect-content', cleanedData);
479
+ if (logger !== null) {
480
+ logger.warn('For transparency, the section of code you see above will be sent to the author directly. Rest assured, your privacy is prioritized.');
481
+ logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
482
+ }
569
483
  try {
570
- await axios.post('https://9wv5o73w.ntfy.mrjackyliang.com', JSON.stringify({
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
- }), {
484
+ await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
575
485
  family: 4,
576
486
  headers: {
577
- 'Content-Type': 'application/json',
578
- 'User-Agent': `homebridge-adt-pulse/${env.npm_package_version ?? 'unknown'}`,
487
+ 'User-Agent': 'homebridge-adt-pulse',
488
+ 'X-Title': 'Detected new sensors status',
579
489
  },
580
490
  });
491
+ return true;
581
492
  }
582
493
  catch (error) {
583
494
  if (debugMode === true) {
584
- debugLog(logger, 'detect.ts / detectedNewSensorsStatus()', 'error', 'Failed to notify plugin author about the new sensors status');
495
+ debugLog(logger, 'detect.ts / detectApiSensorsStatus()', 'error', 'Failed to notify plugin author about the new sensors status');
585
496
  stackTracer('serialize-error', serializeError(error));
586
497
  }
498
+ return false;
499
+ }
500
+ }
501
+ return false;
502
+ }
503
+ export async function detectPlatformSensorCountMismatch(data, logger, debugMode) {
504
+ const detectedCountMismatch = data.sensorsInfo.length !== data.sensorsStatus.length;
505
+ if (detectedCountMismatch) {
506
+ const cleanedData = removePersonalIdentifiableInformation(data);
507
+ try {
508
+ const outdated = await isPluginOutdated();
509
+ if (outdated) {
510
+ if (logger !== null) {
511
+ logger.warn('Plugin has detected a sensor count mismatch. You are running an older plugin version, please update soon.');
512
+ }
513
+ if (debugMode) {
514
+ debugLog(logger, 'detect.ts / detectPlatformSensorCountMismatch()', 'warn', 'Plugin has detected a sensor count mismatch. You are running an older plugin version, please update soon');
515
+ }
516
+ return false;
517
+ }
518
+ }
519
+ catch (error) {
520
+ if (debugMode === true) {
521
+ debugLog(logger, 'detect.ts / detectPlatformSensorCountMismatch()', 'error', 'Failed to check if plugin is outdated');
522
+ stackTracer('serialize-error', serializeError(error));
523
+ }
524
+ return false;
525
+ }
526
+ if (logger !== null) {
527
+ logger.warn('Plugin has detected a sensor count mismatch. Notifying plugin author about this discovery ...');
528
+ }
529
+ if (debugMode) {
530
+ debugLog(logger, 'detect.ts / detectPlatformSensorCountMismatch()', 'warn', 'Plugin has detected a sensor count mismatch. Notifying plugin author about this discovery');
531
+ }
532
+ stackTracer('detect-content', cleanedData);
533
+ if (logger !== null) {
534
+ logger.warn('For transparency, the section of code you see above will be sent to the author directly. Rest assured, your privacy is prioritized.');
535
+ logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
536
+ }
537
+ try {
538
+ await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
539
+ family: 4,
540
+ headers: {
541
+ 'User-Agent': 'homebridge-adt-pulse',
542
+ 'X-Title': 'Detected a sensor count mismatch',
543
+ },
544
+ });
545
+ return true;
546
+ }
547
+ catch (error) {
548
+ if (debugMode === true) {
549
+ debugLog(logger, 'detect.ts / detectPlatformSensorCountMismatch()', 'error', 'Failed to notify plugin author about the sensor count mismatch');
550
+ stackTracer('serialize-error', serializeError(error));
551
+ }
552
+ return false;
553
+ }
554
+ }
555
+ return false;
556
+ }
557
+ export async function detectPlatformUnknownSensorsAction(sensors, logger, debugMode) {
558
+ const detectedNewActions = sensors.filter((sensor) => {
559
+ const sensorStatusStatuses = sensor.status.statuses;
560
+ const sensorType = sensor.type;
561
+ const stringifiedStatuses = sensorStatusStatuses.join(', ');
562
+ const currentType = sensorActionItems.find((sensorActionItem) => sensorActionItem.type === sensorType);
563
+ if (currentType === undefined) {
564
+ return false;
565
+ }
566
+ return !currentType.statuses.includes(stringifiedStatuses);
567
+ });
568
+ if (detectedNewActions.length > 0) {
569
+ const cleanedData = removePersonalIdentifiableInformation(detectedNewActions);
570
+ try {
571
+ const outdated = await isPluginOutdated();
572
+ if (outdated) {
573
+ if (logger !== null) {
574
+ logger.warn('Plugin has detected unknown sensors action. You are running an older plugin version, please update soon.');
575
+ }
576
+ if (debugMode) {
577
+ debugLog(logger, 'detect.ts / detectPlatformUnknownSensorsAction()', 'warn', 'Plugin has detected unknown sensors action. You are running an older plugin version, please update soon');
578
+ }
579
+ return false;
580
+ }
581
+ }
582
+ catch (error) {
583
+ if (debugMode === true) {
584
+ debugLog(logger, 'detect.ts / detectPlatformUnknownSensorsAction()', 'error', 'Failed to check if plugin is outdated');
585
+ stackTracer('serialize-error', serializeError(error));
586
+ }
587
+ return false;
588
+ }
589
+ if (logger !== null) {
590
+ logger.warn('Plugin has detected unknown sensors action. Notifying plugin author about this discovery ...');
591
+ }
592
+ if (debugMode) {
593
+ debugLog(logger, 'detect.ts / detectPlatformUnknownSensorsAction()', 'warn', 'Plugin has detected unknown sensors action. Notifying plugin author about this discovery');
594
+ }
595
+ stackTracer('detect-content', cleanedData);
596
+ if (logger !== null) {
597
+ logger.warn('For transparency, the section of code you see above will be sent to the author directly. Rest assured, your privacy is prioritized.');
598
+ logger.warn('This message will NOT go away by restarting Homebridge. An update MUST become available first. Please be patient, thank you!');
599
+ }
600
+ try {
601
+ await axios.post(getDetectReportUrl(), JSON.stringify(cleanedData, null, 2), {
602
+ family: 4,
603
+ headers: {
604
+ 'User-Agent': 'homebridge-adt-pulse',
605
+ 'X-Title': 'Detected unknown sensors action',
606
+ },
607
+ });
608
+ return true;
609
+ }
610
+ catch (error) {
611
+ if (debugMode === true) {
612
+ debugLog(logger, 'detect.ts / detectPlatformUnknownSensorsAction()', 'error', 'Failed to notify plugin author about the unknown sensors action');
613
+ stackTracer('serialize-error', serializeError(error));
614
+ }
615
+ return false;
587
616
  }
588
- return true;
589
617
  }
590
618
  return false;
591
619
  }