homebridge-ttlock-accesscode 3.0.0-beta.4 → 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.
@@ -10,6 +10,7 @@
10
10
  discoveryPollingInterval: 12,
11
11
  offlineInterval: 7,
12
12
  waitTimeUpdate: 100,
13
+ reduceDeviceLogging: false,
13
14
  };
14
15
  const ACCOUNT_FIELDS = ['clientId', 'clientSecret', 'username', 'password'];
15
16
  // The range each number field is saved in
@@ -20,6 +21,8 @@
20
21
  ['offlineInterval', { minimum: 1 }],
21
22
  ['waitTimeUpdate', { minimum: 0, maximum: 60000 }],
22
23
  ]);
24
+ // Fields saved as true or false, from a checkbox
25
+ const BOOLEAN_FIELDS = new Set(['reduceDeviceLogging']);
23
26
 
24
27
  const app = document.getElementById('app');
25
28
  const hb = window.homebridge;
@@ -129,6 +132,7 @@
129
132
  discoveryPollingInterval: DEFAULTS.discoveryPollingInterval,
130
133
  offlineInterval: DEFAULTS.offlineInterval,
131
134
  waitTimeUpdate: DEFAULTS.waitTimeUpdate,
135
+ reduceDeviceLogging: DEFAULTS.reduceDeviceLogging,
132
136
  };
133
137
  blocks.push(platformConfig);
134
138
  }
@@ -140,6 +144,7 @@
140
144
  platformConfig.discoveryPollingInterval = platformConfig.discoveryPollingInterval ?? DEFAULTS.discoveryPollingInterval;
141
145
  platformConfig.offlineInterval = platformConfig.offlineInterval ?? DEFAULTS.offlineInterval;
142
146
  platformConfig.waitTimeUpdate = platformConfig.waitTimeUpdate ?? DEFAULTS.waitTimeUpdate;
147
+ platformConfig.reduceDeviceLogging = platformConfig.reduceDeviceLogging === true;
143
148
 
144
149
  state.pluginConfig = blocks;
145
150
  state.platformConfig = platformConfig;
@@ -174,6 +179,26 @@
174
179
  `;
175
180
  }
176
181
 
182
+ function checkboxHtml(field, label, options = {}) {
183
+ const checked = state.platformConfig?.[field] === true ? 'checked' : '';
184
+ const note = options.note ? `<div class="field-note">${escapeHtml(options.note)}</div>` : '';
185
+ return `
186
+ <div class="${options.wide ? 'wide' : ''}">
187
+ <div class="form-check">
188
+ <input
189
+ id="platform-${field}"
190
+ class="form-check-input"
191
+ data-platform-field="${field}"
192
+ type="checkbox"
193
+ ${checked}
194
+ />
195
+ <label class="form-check-label" for="platform-${field}">${escapeHtml(label)}</label>
196
+ </div>
197
+ ${note}
198
+ </div>
199
+ `;
200
+ }
201
+
177
202
  function render() {
178
203
  app.innerHTML = `
179
204
  <div class="ui-shell">
@@ -287,6 +312,10 @@
287
312
  max: 60000,
288
313
  note: 'How long periodic device discovery waits before it starts, so discoveries requested together run once. ' +
289
314
  'Lock polls and commands do not wait for it.',
315
+ })}
316
+ ${checkboxHtml('reduceDeviceLogging', 'Reduce Device Logging', {
317
+ note: 'Log lock changes (Set and Updating) and Adding HomeKit device as debug messages instead of info. ' +
318
+ 'They show again when Debug Mode in Homebridge is enabled.',
290
319
  })}
291
320
  </div>
292
321
  </div>
@@ -349,6 +378,7 @@
349
378
  discoveryPollingInterval: parsePlatformNumber('discoveryPollingInterval', block.discoveryPollingInterval),
350
379
  offlineInterval: parsePlatformNumber('offlineInterval', block.offlineInterval),
351
380
  waitTimeUpdate: parsePlatformNumber('waitTimeUpdate', block.waitTimeUpdate),
381
+ reduceDeviceLogging: block.reduceDeviceLogging === true,
352
382
  // Drops the removed IKEA DIRIGERA door settings: the Homebridge UI merges this block into the saved one,
353
383
  // so a key is only removed when it is sent as undefined
354
384
  externalDoors: undefined,
@@ -362,7 +392,11 @@
362
392
  return false;
363
393
  }
364
394
  const isNumber = NUMBER_FIELDS.has(field);
365
- state.platformConfig[field] = committed && isNumber ? parsePlatformNumber(field, target.value) : target.value;
395
+ if (BOOLEAN_FIELDS.has(field)) {
396
+ state.platformConfig[field] = target.checked === true;
397
+ } else {
398
+ state.platformConfig[field] = committed && isNumber ? parsePlatformNumber(field, target.value) : target.value;
399
+ }
366
400
  if (ACCOUNT_FIELDS.includes(field)) {
367
401
  markAccountCredentialsChanged();
368
402
  }
@@ -415,8 +449,12 @@
415
449
  openModal('Testing TTLock Credentials', loadingHtml('Authenticating with TTLock...'), '');
416
450
  try {
417
451
  await flushUpdate();
452
+ // Only the credentials this test sent count as verified, not ones edited while it ran
453
+ const fingerprint = accountFingerprint();
418
454
  const locks = await hb.request('/ttlock-locks', accountPayload());
419
- state.credentialTestFingerprint = accountFingerprint();
455
+ if (fingerprint === accountFingerprint()) {
456
+ state.credentialTestFingerprint = fingerprint;
457
+ }
420
458
  notify('success', `TTLock credentials were accepted. ${locks.length} lock(s) found.`, 'Credentials Verified');
421
459
  closeModal();
422
460
  render();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Homebridge TTLock Access Code",
3
3
  "name": "homebridge-ttlock-accesscode",
4
- "version": "3.0.0-beta.4",
4
+ "version": "3.0.0",
5
5
  "description": "Plugin that uses TTLock Cloud API to communicate with TTLock Devices connected to the G2 Gateway.",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -50,14 +50,14 @@
50
50
  ],
51
51
  "devDependencies": {
52
52
  "@eslint/js": "^10.0.1",
53
- "@stylistic/eslint-plugin": "^5.10.0",
54
- "@types/node": "^26.6.6",
55
- "eslint": "^10.14.0",
56
- "homebridge": "^2.5.0",
53
+ "@stylistic/eslint-plugin": "^6.0.1",
54
+ "@types/node": "^26.6.11",
55
+ "eslint": "^10.16.0",
56
+ "homebridge": "^2.5.1",
57
57
  "nodemon": "^3.1.14",
58
- "rimraf": "^6.1.3",
58
+ "rimraf": "^6.1.4",
59
59
  "typescript": "^6.0.3",
60
- "typescript-eslint": "^8.72.1"
60
+ "typescript-eslint": "^8.74.0"
61
61
  },
62
62
  "homepage": "https://github.com/ZeliardM/homebridge-ttlock-accesscode#readme",
63
63
  "funding": [
@@ -71,8 +71,11 @@
71
71
  }
72
72
  ],
73
73
  "dependencies": {
74
- "@homebridge/plugin-ui-utils": "^2.2.7",
75
- "axios": "^1.21.0",
74
+ "@homebridge/plugin-ui-utils": "^2.3.1",
75
+ "axios": "^1.22.0",
76
76
  "ber-tlv": "^0.9.2"
77
+ },
78
+ "overrides": {
79
+ "minimatch": "11.0.9"
77
80
  }
78
81
  }