homebridge-ttlock-accesscode 2.4.0-beta.0 → 3.0.0-beta.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.
Files changed (42) hide show
  1. package/README.md +15 -37
  2. package/config.schema.json +13 -113
  3. package/dist/api/ttlockApi.d.ts +66 -12
  4. package/dist/api/ttlockApi.js +581 -121
  5. package/dist/api/ttlockApi.js.map +1 -1
  6. package/dist/api/usageTracker.d.ts +23 -9
  7. package/dist/api/usageTracker.js +340 -134
  8. package/dist/api/usageTracker.js.map +1 -1
  9. package/dist/config.d.ts +1 -33
  10. package/dist/config.js +28 -132
  11. package/dist/config.js.map +1 -1
  12. package/dist/devices/baseDevice.d.ts +26 -12
  13. package/dist/devices/baseDevice.js +326 -107
  14. package/dist/devices/baseDevice.js.map +1 -1
  15. package/dist/devices/descriptorHelpers.js +9 -4
  16. package/dist/devices/descriptorHelpers.js.map +1 -1
  17. package/dist/devices/deviceManager.d.ts +8 -14
  18. package/dist/devices/deviceManager.js +49 -149
  19. package/dist/devices/deviceManager.js.map +1 -1
  20. package/dist/devices/deviceTypes.d.ts +12 -1
  21. package/dist/devices/homekitLock.d.ts +9 -1
  22. package/dist/devices/homekitLock.js +327 -66
  23. package/dist/devices/homekitLock.js.map +1 -1
  24. package/dist/platform.d.ts +39 -14
  25. package/dist/platform.js +437 -70
  26. package/dist/platform.js.map +1 -1
  27. package/dist/taskQueue.d.ts +1 -1
  28. package/dist/taskQueue.js +7 -5
  29. package/dist/taskQueue.js.map +1 -1
  30. package/dist/utils.d.ts +5 -2
  31. package/dist/utils.js +49 -19
  32. package/dist/utils.js.map +1 -1
  33. package/homebridge-ui/public/app.js +54 -966
  34. package/homebridge-ui/public/styles.css +4 -148
  35. package/homebridge-ui/server.js +26 -45
  36. package/package.json +11 -15
  37. package/dist/api/dirigeraApi.d.ts +0 -34
  38. package/dist/api/dirigeraApi.js +0 -127
  39. package/dist/api/dirigeraApi.js.map +0 -1
  40. package/dist/devices/homekitDoor.d.ts +0 -50
  41. package/dist/devices/homekitDoor.js +0 -268
  42. package/dist/devices/homekitDoor.js.map +0 -1
@@ -1,7 +1,12 @@
1
1
  import pkg from 'ber-tlv';
2
2
  import HomeKitDevice from './baseDevice.js';
3
+ import { LOCK_COMMAND_TIME_LIMIT_MS } from './deviceManager.js';
4
+ import { TTLockApiError, TTLockApiErrorCategory } from '../api/ttlockApi.js';
3
5
  import { buildAccessCodeDescriptors, buildBatteryDescriptors, buildLockDescriptors, } from './descriptorHelpers.js';
4
6
  const { TlvFactory } = pkg;
7
+ // TTLock keyboardPwdType values of the codes HomeKit is shown; codes added from HomeKit are permanent
8
+ const PERMANENT_PASSCODE_TYPE = 2;
9
+ const PERIOD_PASSCODE_TYPE = 3;
5
10
  class AccessCodeProtocolError extends Error {
6
11
  }
7
12
  export default class HomeKitDeviceLock extends HomeKitDevice {
@@ -13,6 +18,11 @@ export default class HomeKitDeviceLock extends HomeKitDevice {
13
18
  this.ttlockDevice = ttlockDevice;
14
19
  this.hasPasscode = !!ttlockDevice.feature_info.passcode;
15
20
  this.setupServices();
21
+ // Now, from the list discovery just read, rather than when HomeKit first asks: a later discovery may read the
22
+ // list in another order, and the first identifiers come from the order
23
+ if (this.hasPasscode && Array.isArray(ttlockDevice.sys_info.passcodes)) {
24
+ this.syncPasscodeIdentifiers(ttlockDevice.sys_info.passcodes, ttlockDevice.sys_info.passcode_list_length);
25
+ }
16
26
  }
17
27
  async initialize() {
18
28
  await this.startPolling();
@@ -28,13 +38,22 @@ export default class HomeKitDeviceLock extends HomeKitDevice {
28
38
  const C = this.platform.Characteristic;
29
39
  if (service.UUID === this.platform.Service.LockMechanism.UUID) {
30
40
  return buildLockDescriptors(C, async (value, context) => {
31
- const blockReason = this.deviceManager?.getLockCommandBlockReason(context.device.device_id);
32
- if (blockReason) {
33
- const action = Number(value) === C.LockTargetState.SECURED ? 'lock' : 'unlock';
34
- this.log.warn(`Ignoring ${action} command for ${context.alias}: ${blockReason}`);
35
- return false;
41
+ const action = Number(value) === C.LockTargetState.SECURED ? 'lock' : 'unlock';
42
+ try {
43
+ await this.deviceManager.controlDevice(context.device.device_id, 'state', value);
44
+ }
45
+ catch (error) {
46
+ // It waited too long (behind a poll or another request) to be sure the lock would not move late
47
+ if (error instanceof TTLockApiError && error.category === TTLockApiErrorCategory.DeadlineExpired) {
48
+ this.log.warn(`Did not send ${action} to ${context.alias}: it could no longer finish within ` +
49
+ `${LOCK_COMMAND_TIME_LIMIT_MS / 1000}s of the request`);
50
+ return false;
51
+ }
52
+ throw error;
36
53
  }
37
- await this.deviceManager.controlDevice(context.device.device_id, 'state', value);
54
+ // TTLock carried the command out through the gateway, so the lock answers again even if its last polls
55
+ // did not; HomeKit stops showing No Response without waiting for the next poll
56
+ this.markDeviceReachable();
38
57
  return true;
39
58
  });
40
59
  }
@@ -75,28 +94,129 @@ export default class HomeKitDeviceLock extends HomeKitDevice {
75
94
  }
76
95
  }
77
96
  async ensurePasscodesLoaded(device) {
78
- if (Array.isArray(device.passcodes)) {
79
- return device.passcodes;
97
+ if (!Array.isArray(device.passcodes)) {
98
+ return await this.refreshPasscodes(device);
80
99
  }
81
- device.passcodes = await this.deviceManager.managePasscodes(device.device_id, 'get');
100
+ // Discovery may have put a newer list in place
101
+ this.syncPasscodeIdentifiers(device.passcodes, device.passcode_list_length);
82
102
  return device.passcodes;
83
103
  }
84
104
  async refreshPasscodes(device) {
85
- device.passcodes = await this.deviceManager.managePasscodes(device.device_id, 'get');
86
- return device.passcodes;
105
+ const { passcodes, listLength } = await this.deviceManager.managePasscodes(device.device_id, 'get');
106
+ device.passcode_list_length = listLength;
107
+ this.setCachedPasscodes(device, passcodes);
108
+ return passcodes;
109
+ }
110
+ setCachedPasscodes(device, passcodes) {
111
+ device.passcodes = passcodes;
112
+ this.syncPasscodeIdentifiers(passcodes, device.passcode_list_length);
113
+ }
114
+ // HomeKit keeps the identifier it was given for each access code and later reads and removes codes by it, so an
115
+ // identifier stays with its code and is never given to another one, even after that code is gone. Saved with the
116
+ // accessory, by TTLock passcode id. listLength: how many entries TTLock's list had, counting the ones left out.
117
+ syncPasscodeIdentifiers(passcodes, listLength) {
118
+ const context = this.homebridgeAccessory.context;
119
+ let identifiers = context.passcodeIdentifiers;
120
+ let changed = false;
121
+ // Identifiers the Home app may still hold for entries that are now left out
122
+ let reserved = 0;
123
+ if (!identifiers) {
124
+ // Earlier versions used the position in TTLock's list, counting the entries that are now left out; starting
125
+ // from it keeps the identifiers the Home app has. A code with no position (one just added) gets a new number
126
+ // below, so no two codes share one. New codes start after the whole list, so they do not get the identifier
127
+ // of an entry left out at its end either, even when every entry is left out.
128
+ const seeded = {};
129
+ for (const passcode of passcodes) {
130
+ if (passcode.list_position !== undefined) {
131
+ seeded[passcode.passcode_id] ??= passcode.list_position;
132
+ }
133
+ }
134
+ reserved = listLength ?? 0;
135
+ identifiers = seeded;
136
+ changed = true;
137
+ }
138
+ let next = Math.max(context.nextPasscodeIdentifier ?? 0, reserved, ...Object.values(identifiers).map(identifier => identifier + 1));
139
+ const listed = new Set(passcodes.map(passcode => passcode.passcode_id));
140
+ for (const passcodeId of Object.keys(identifiers)) {
141
+ if (!listed.has(passcodeId)) {
142
+ delete identifiers[passcodeId];
143
+ changed = true;
144
+ }
145
+ }
146
+ for (const passcode of passcodes) {
147
+ if (identifiers[passcode.passcode_id] === undefined) {
148
+ identifiers[passcode.passcode_id] = next++;
149
+ changed = true;
150
+ }
151
+ }
152
+ if (changed || context.nextPasscodeIdentifier !== next) {
153
+ context.passcodeIdentifiers = identifiers;
154
+ context.nextPasscodeIdentifier = next;
155
+ this.platform.api.updatePlatformAccessories([this.homebridgeAccessory]);
156
+ }
87
157
  }
158
+ // Whether a failed add or delete may still have changed the lock's codes (it got no answer, or no readable one), or
159
+ // may have failed because the cached list is out of date (TTLock turned down a code it already has, or one already
160
+ // deleted). Not when TTLock never got it, or turned it away before acting on it.
161
+ passcodesMayHaveChanged(error) {
162
+ if (!(error instanceof TTLockApiError)) {
163
+ return true;
164
+ }
165
+ if (error.networkFailure === 'notSent' || error.networkFailure === 'tls' || error.gatewayTransient) {
166
+ return false;
167
+ }
168
+ switch (error.category) {
169
+ case TTLockApiErrorCategory.AuthExpired:
170
+ case TTLockApiErrorCategory.AuthInvalid:
171
+ case TTLockApiErrorCategory.BudgetExhausted:
172
+ case TTLockApiErrorCategory.DeadlineExpired:
173
+ case TTLockApiErrorCategory.GatewayOffline:
174
+ case TTLockApiErrorCategory.RateLimited:
175
+ return false;
176
+ default:
177
+ return true;
178
+ }
179
+ }
180
+ // After a failed add or delete, read the list again: it says whether the change took effect, and keeps the cache
181
+ // from answering HomeKit with codes that are no longer right. Undefined when the codes cannot have changed, or the
182
+ // list could not be read; the cache is then dropped, so the next request reads the list.
183
+ async recheckPasscodes(device, error) {
184
+ if (!this.passcodesMayHaveChanged(error)) {
185
+ return undefined;
186
+ }
187
+ this.log.debug(`Reading the access codes on ${this.name} again to see whether the change took effect`);
188
+ try {
189
+ return await this.refreshPasscodes(device);
190
+ }
191
+ catch (refreshError) {
192
+ delete device.passcodes;
193
+ this.log.debug(`Could not read the access codes on ${this.name} again: ` +
194
+ `${refreshError instanceof Error ? refreshError.message : String(refreshError)}`);
195
+ return undefined;
196
+ }
197
+ }
198
+ // Every list is synced before its codes are sent to HomeKit, so every code has an identifier
88
199
  getPasscodeIdentifier(passcode) {
89
- return BigInt(passcode.index);
200
+ const identifier = this.homebridgeAccessory.context.passcodeIdentifiers?.[passcode.passcode_id];
201
+ if (identifier === undefined) {
202
+ throw new Error(`Passcode id ${passcode.passcode_id} has no HomeKit identifier`);
203
+ }
204
+ return identifier;
90
205
  }
206
+ // HAP TLV integers are little-endian, in as few bytes as the value needs
91
207
  encodePasscodeIdentifier(identifier) {
92
- let hex = identifier.toString(16);
93
- if (hex.length % 2 !== 0) {
94
- hex = `0${hex}`;
95
- }
96
- return hex;
208
+ const bytes = [];
209
+ let value = identifier;
210
+ do {
211
+ bytes.push(value % 256);
212
+ value = Math.floor(value / 256);
213
+ } while (value > 0);
214
+ return Buffer.from(bytes).toString('hex');
97
215
  }
216
+ // Only by the saved identifier, never by position: a code HomeKit knows that is no longer listed is not found
98
217
  findPasscodeByIdentifier(passcodes, identifier) {
99
- return passcodes.find(passcode => this.getPasscodeIdentifier(passcode) === identifier);
218
+ const identifiers = this.homebridgeAccessory.context.passcodeIdentifiers ?? {};
219
+ return passcodes.find(passcode => identifiers[passcode.passcode_id] === identifier);
100
220
  }
101
221
  buildPasscodeResponseRecord(passcode) {
102
222
  const identifierValue = this.encodePasscodeIdentifier(this.getPasscodeIdentifier(passcode));
@@ -106,105 +226,249 @@ export default class HomeKitDeviceLock extends HomeKitDevice {
106
226
  const status = TlvFactory.serialize(TlvFactory.primitiveTlv('04', '00')).toString('hex');
107
227
  return TlvFactory.serialize(TlvFactory.primitiveTlv('03', identifier + accessCode + flags + status)).toString('hex');
108
228
  }
229
+ // ber-tlv's parse error is not an Error and carries the items it read before it failed, which can hold an access
230
+ // code, so it is never passed on. Its text is left out as well: when a request is out of step, it can name bytes of
231
+ // a code as a tag or a length.
232
+ parseTlv(input, what) {
233
+ try {
234
+ return TlvFactory.parse(input);
235
+ }
236
+ catch {
237
+ throw new AccessCodeProtocolError(`${what} could not be read as TLV`);
238
+ }
239
+ }
240
+ // The operation is the first item: tag 01 with a one-byte value. Any other first item is turned down without
241
+ // its bytes, which can hold an access code when the request is out of order.
109
242
  parseOperationType(decodedTlv) {
110
243
  const operation = decodedTlv[0];
111
244
  if (!operation) {
112
245
  throw new AccessCodeProtocolError('Empty AccessCodeControlPoint request');
113
246
  }
114
- return Number(operation.value.toString('hex'));
247
+ // ber-tlv gives a constructed item a null value
248
+ const value = operation.value;
249
+ if (operation.tag !== '01' || !Buffer.isBuffer(value) || value.length !== 1) {
250
+ throw new AccessCodeProtocolError('The request does not start with a one-byte operation');
251
+ }
252
+ return value.readUInt8(0);
115
253
  }
254
+ // The identifier is the first inner item: tag 01, little-endian. Any other first item is turned down without its
255
+ // bytes, which can hold an access code when the request is out of order.
116
256
  parseIdentifierRequest(element, requestType) {
117
- const request = TlvFactory.parse(element.value);
257
+ const request = this.parseTlv(element.value, `${requestType} request`);
118
258
  const identifierRecord = request[0];
119
259
  if (!identifierRecord) {
120
- throw new AccessCodeProtocolError(`${requestType} request is missing its passcode index`);
260
+ throw new AccessCodeProtocolError(`${requestType} request is missing its passcode identifier`);
121
261
  }
122
- const identifier = identifierRecord.value.toString('hex');
123
- if (!identifier) {
124
- throw new AccessCodeProtocolError(`${requestType} request contained an empty passcode index`);
262
+ // ber-tlv gives a constructed item a null value
263
+ const bytes = identifierRecord.value;
264
+ if (identifierRecord.tag !== '01' || !Buffer.isBuffer(bytes)) {
265
+ throw new AccessCodeProtocolError(`${requestType} request does not hold a passcode identifier where one belongs`);
125
266
  }
126
- return BigInt(`0x${identifier}`);
267
+ if (bytes.length === 0) {
268
+ throw new AccessCodeProtocolError(`${requestType} request contained an empty passcode identifier`);
269
+ }
270
+ // Little-endian; zero high bytes do not change the value
271
+ let length = bytes.length;
272
+ while (length > 1 && bytes[length - 1] === 0) {
273
+ length--;
274
+ }
275
+ if (length > 6) {
276
+ throw new AccessCodeProtocolError(`${requestType} request contained a passcode identifier that is too large`);
277
+ }
278
+ return bytes.readUIntLE(0, length);
279
+ }
280
+ // Whether HomeKit was ever given this identifier. Only those are named in the log: any other number can be the bytes
281
+ // of an access code that a request put where an identifier belongs.
282
+ wasGivenOut(identifier) {
283
+ return identifier < (this.homebridgeAccessory.context.nextPasscodeIdentifier ?? 0);
127
284
  }
128
285
  parsePasscodeRequest(element) {
129
- const request = TlvFactory.parse(element.value);
286
+ const request = this.parseTlv(element.value, 'Add request');
130
287
  const passcodeRecord = request[0];
131
288
  if (!passcodeRecord) {
132
289
  throw new AccessCodeProtocolError('Add request is missing the passcode payload');
133
290
  }
134
291
  return passcodeRecord.value.toString();
135
292
  }
293
+ // A HomeKit access code opens the lock whenever it is entered, so HomeKit is shown only codes that do: permanent
294
+ // codes, and period codes within their period. One-time, cyclic and erase codes, and period codes that have not
295
+ // started or have ended, stay on the lock but are not shown. A code TTLock gives no type for is shown, as before.
296
+ usablePasscodes(passcodes) {
297
+ const now = Date.now();
298
+ return passcodes.filter(passcode => {
299
+ switch (passcode.type) {
300
+ case undefined:
301
+ case PERMANENT_PASSCODE_TYPE:
302
+ return true;
303
+ case PERIOD_PASSCODE_TYPE:
304
+ return (!passcode.start_date || passcode.start_date <= now) &&
305
+ (!passcode.end_date || passcode.end_date > now);
306
+ default:
307
+ return false;
308
+ }
309
+ });
310
+ }
136
311
  async buildListResponse(device) {
137
312
  const passcodes = await this.ensurePasscodesLoaded(device);
138
- const records = passcodes.map(passcode => {
139
- this.log.debug(`Passcode ${passcode.passcode} found on ${this.name}`);
313
+ const usable = this.usablePasscodes(passcodes);
314
+ if (usable.length < passcodes.length) {
315
+ this.log.debug(`Not showing ${passcodes.length - usable.length} access code(s) on ${this.name} that are not permanent or not ` +
316
+ 'valid now');
317
+ }
318
+ const records = usable.map(passcode => {
319
+ this.log.debug(`Passcode id ${passcode.passcode_id} found on ${this.name}`);
140
320
  return this.buildPasscodeResponseRecord(passcode);
141
321
  });
142
322
  return `010101${records.join('0000')}`;
143
323
  }
144
324
  async buildReadResponse(device, decodedTlv) {
145
- const passcodes = await this.ensurePasscodesLoaded(device);
325
+ const passcodes = this.usablePasscodes(await this.ensurePasscodesLoaded(device));
146
326
  const records = decodedTlv.slice(1).map((element) => {
147
327
  const passcodeIdentifier = this.parseIdentifierRequest(element, 'Read');
148
328
  const passcode = this.findPasscodeByIdentifier(passcodes, passcodeIdentifier);
149
329
  if (!passcode) {
150
- throw new AccessCodeProtocolError(`Passcode identifier ${passcodeIdentifier.toString()} was not found for read`);
330
+ throw new AccessCodeProtocolError(this.wasGivenOut(passcodeIdentifier)
331
+ ? `Passcode identifier ${passcodeIdentifier} was not found for read`
332
+ : 'Read request names a passcode identifier that was never given out');
151
333
  }
152
- this.log.debug(`Reading passcode ${passcode.passcode} on ${this.name}`);
334
+ this.log.debug(`Reading passcode id ${passcode.passcode_id} on ${this.name}`);
153
335
  return this.buildPasscodeResponseRecord(passcode);
154
336
  });
155
337
  return `010102${records.join('0000')}`;
156
338
  }
157
339
  async buildAddResponse(device, decodedTlv) {
340
+ // Every code is read before any is added, so a request that cannot be read adds nothing
341
+ const newPassCodes = decodedTlv.slice(1).map(element => this.parsePasscodeRequest(element));
158
342
  const records = [];
159
- for (const element of decodedTlv.slice(1)) {
160
- const newPassCode = this.parsePasscodeRequest(element);
161
- const cachedPasscodes = await this.ensurePasscodesLoaded(device);
343
+ for (const newPassCode of newPassCodes) {
344
+ // Only a usable code counts: one with the same digits that has ended does not open the lock. TTLock decides
345
+ // whether it takes the new code anyway.
346
+ const cachedPasscodes = this.usablePasscodes(await this.ensurePasscodesLoaded(device));
162
347
  let passcode = cachedPasscodes.find(existing => existing.passcode === newPassCode);
163
- if (!passcode) {
164
- this.log.info(`Adding new passcode ${newPassCode} to ${this.name}`);
165
- const newPasscode = await this.deviceManager
166
- .managePasscodes(device.device_id, 'add', newPassCode);
167
- const refreshedPasscodes = await this.refreshPasscodes(device);
168
- passcode = refreshedPasscodes.find(existing => existing.passcode_id === newPasscode.keyboardPwdId.toString()
169
- || existing.passcode === newPassCode);
348
+ if (passcode) {
349
+ this.log.debug(`The passcode to add already exists on ${this.name} as passcode id ${passcode.passcode_id}`);
170
350
  }
171
351
  else {
172
- this.log.debug(`Passcode ${newPassCode} already exists on ${this.name}`);
173
- }
174
- if (!passcode) {
175
- throw new AccessCodeProtocolError(`Passcode ${newPassCode} was not available after add`);
352
+ passcode = await this.addPasscode(device, newPassCode);
176
353
  }
177
354
  records.push(this.buildPasscodeResponseRecord(passcode));
178
355
  }
179
356
  return `010103${records.join('0000')}`;
180
357
  }
181
- async buildDeleteResponse(device, decodedTlv) {
182
- if (decodedTlv.length < 2) {
183
- throw new AccessCodeProtocolError('Delete request is missing the target passcode index');
358
+ // An add that may have reached TTLock is not sent again, because TTLock may have applied it; the list says whether
359
+ // it did
360
+ async addPasscode(device, newPassCode) {
361
+ this.log.info(`Adding a new passcode to ${this.name}`);
362
+ let passcodeId;
363
+ try {
364
+ const added = await this.deviceManager
365
+ .managePasscodes(device.device_id, 'add', newPassCode);
366
+ if (typeof added.keyboardPwdId !== 'number' && typeof added.keyboardPwdId !== 'string') {
367
+ throw new TTLockApiError('TTLock did not say which passcode id it added', TTLockApiErrorCategory.InvalidResponse, false, 'keyboardPwd/add');
368
+ }
369
+ passcodeId = String(added.keyboardPwdId);
184
370
  }
185
- const deleteRequest = decodedTlv[1];
186
- if (!deleteRequest) {
187
- throw new AccessCodeProtocolError('Delete request is missing the target passcode index');
371
+ catch (error) {
372
+ const sameCode = (await this.recheckPasscodes(device, error))?.filter(existing => existing.passcode === newPassCode);
373
+ const passcode = sameCode && this.usablePasscodes(sameCode)[0];
374
+ if (!passcode) {
375
+ // HomeKit is not shown that code, so nothing there tells why TTLock may have turned the new one down
376
+ const hidden = sameCode?.[0];
377
+ if (hidden) {
378
+ this.log.warn(`The passcode to add is already on ${this.name} as passcode id ${hidden.passcode_id}, which is not permanent ` +
379
+ 'or not valid now; remove it in the TTLock app to add the code from HomeKit');
380
+ }
381
+ throw error;
382
+ }
383
+ this.log.info(`The passcode is on ${this.name} as passcode id ${passcode.passcode_id}, although TTLock did not confirm the add`);
384
+ return passcode;
188
385
  }
386
+ // TTLock's answer says what was added. Reading the list again would cost a call and time HomeKit is waiting, and
387
+ // if that read failed, an add that was done would be answered as failed.
388
+ const passcode = {
389
+ passcode_id: passcodeId,
390
+ lock_id: device.device_id,
391
+ passcode: newPassCode,
392
+ type: PERMANENT_PASSCODE_TYPE,
393
+ };
394
+ this.setCachedPasscodes(device, [...(device.passcodes ?? []), passcode]);
395
+ return passcode;
396
+ }
397
+ async buildDeleteResponse(device, decodedTlv) {
398
+ const deleteRequests = decodedTlv.slice(1);
399
+ if (deleteRequests.length === 0) {
400
+ throw new AccessCodeProtocolError('Delete request is missing the target passcode identifier');
401
+ }
402
+ // Every identifier is read and looked up before anything is deleted, so a request that cannot be read deletes
403
+ // nothing
404
+ const identifiers = deleteRequests.map(element => this.parseIdentifierRequest(element, 'Delete'));
405
+ // Any code TTLock lists: HomeKit may have been shown it before it ended, and may still remove it
189
406
  const passcodes = await this.ensurePasscodesLoaded(device);
190
- const deletePasscodeIdentifier = this.parseIdentifierRequest(deleteRequest, 'Delete');
191
- const passcode = this.findPasscodeByIdentifier(passcodes, deletePasscodeIdentifier);
192
- if (!passcode) {
193
- throw new AccessCodeProtocolError(`Passcode identifier ${deletePasscodeIdentifier.toString()} was not found for delete`);
407
+ const targets = new Map();
408
+ for (const identifier of identifiers) {
409
+ const passcode = this.findPasscodeByIdentifier(passcodes, identifier);
410
+ if (!passcode) {
411
+ // Already gone: deleted in the TTLock app, or by an earlier Remove that failed on a later code. The others
412
+ // are still deleted, so a Remove sent again after a failure deletes the codes that are left.
413
+ this.log.debug(this.wasGivenOut(identifier)
414
+ ? `Passcode identifier ${identifier} is no longer on ${this.name}; nothing to delete for it`
415
+ : `A Delete request on ${this.name} names a passcode identifier that was never given out; nothing to delete for it`);
416
+ continue;
417
+ }
418
+ // Built first: once the code is deleted, its identifier is let go
419
+ targets.set(passcode.passcode_id, { passcode, record: this.buildPasscodeResponseRecord(passcode) });
194
420
  }
195
- this.log.info(`Deleting passcode ${passcode.passcode} on ${this.name}`);
196
- await this.deviceManager.managePasscodes(device.device_id, 'delete', passcode.passcode_id);
197
- await this.refreshPasscodes(device);
198
- return `010105${this.buildPasscodeResponseRecord(passcode)}`;
421
+ if (targets.size === 0) {
422
+ const named = identifiers.filter(identifier => this.wasGivenOut(identifier));
423
+ const neverGivenOut = identifiers.length - named.length;
424
+ if (identifiers.length === 1) {
425
+ throw new AccessCodeProtocolError(named.length === 1
426
+ ? `Passcode identifier ${named[0]} was not found for delete`
427
+ : 'Delete request names a passcode identifier that was never given out');
428
+ }
429
+ if (named.length === 0) {
430
+ throw new AccessCodeProtocolError(`None of the ${neverGivenOut} passcode identifiers in the Delete request were ever given out`);
431
+ }
432
+ const others = neverGivenOut === 0 ? '' : neverGivenOut === 1
433
+ ? ', and another was never given out'
434
+ : `, and ${neverGivenOut} more were never given out`;
435
+ throw new AccessCodeProtocolError(`None of the passcode identifiers ${named.join(', ')} were found for delete${others}`);
436
+ }
437
+ const records = [];
438
+ for (const { passcode, record } of targets.values()) {
439
+ this.log.info(`Deleting passcode id ${passcode.passcode_id} on ${this.name}`);
440
+ await this.deletePasscode(device, passcode);
441
+ records.push(record);
442
+ }
443
+ return `010105${records.join('0000')}`;
444
+ }
445
+ // Like an add, a delete that may have reached TTLock is not sent again; the list says whether it took effect
446
+ async deletePasscode(device, passcode) {
447
+ try {
448
+ await this.deviceManager.managePasscodes(device.device_id, 'delete', passcode.passcode_id);
449
+ }
450
+ catch (error) {
451
+ const passcodes = await this.recheckPasscodes(device, error);
452
+ if (!passcodes || passcodes.some(existing => existing.passcode_id === passcode.passcode_id)) {
453
+ throw error;
454
+ }
455
+ this.log.info(`Passcode id ${passcode.passcode_id} is no longer on ${this.name}, although TTLock did not confirm the delete`);
456
+ return;
457
+ }
458
+ // TTLock confirmed it; as after an add, the list is not read again
459
+ const remaining = (device.passcodes ?? []).filter(existing => existing.passcode_id !== passcode.passcode_id);
460
+ this.setCachedPasscodes(device, remaining);
199
461
  }
200
462
  async setAccessCodeControlPoint(device, value) {
201
463
  this.setLockBusy(true);
202
464
  try {
203
- const decodedTlv = TlvFactory.parse(Buffer.from(String(value), 'base64').toString('hex'));
204
- this.log.debug(`Decoded TLV for AccessCodeControlPoint on ${this.name}:`, decodedTlv);
465
+ const decodedTlv = this.parseTlv(Buffer.from(String(value), 'base64'), 'The request');
466
+ // The records carry the access codes, so log only how many there are
467
+ this.log.debug(`Decoded AccessCodeControlPoint request on ${this.name}: ${decodedTlv.length} TLV record(s)`);
205
468
  let requestType = '';
206
469
  let responseTlv = '';
207
- switch (this.parseOperationType(decodedTlv)) {
470
+ const operation = this.parseOperationType(decodedTlv);
471
+ switch (operation) {
208
472
  case 1: {
209
473
  requestType = 'List';
210
474
  responseTlv = await this.buildListResponse(device);
@@ -226,7 +490,7 @@ export default class HomeKitDeviceLock extends HomeKitDevice {
226
490
  break;
227
491
  }
228
492
  default:
229
- throw new AccessCodeProtocolError(`Unsupported AccessCodeControlPoint operation: ${this.parseOperationType(decodedTlv)}`);
493
+ throw new AccessCodeProtocolError(`Unsupported AccessCodeControlPoint operation: ${operation}`);
230
494
  }
231
495
  this.log.info(`Access Code Control ${requestType} Request completed for ${this.name}`);
232
496
  return Buffer.from(responseTlv, 'hex').toString('base64');
@@ -245,9 +509,6 @@ export default class HomeKitDeviceLock extends HomeKitDevice {
245
509
  getConfigurationState() {
246
510
  return this.lockBusy ? 0 : 1;
247
511
  }
248
- async updateAllServicesAndCharacteristics(forceUpdate) {
249
- await super.updateAllServicesAndCharacteristics(forceUpdate);
250
- }
251
512
  identify() {
252
513
  this.log.info('identify');
253
514
  }
@@ -1 +1 @@
1
- {"version":3,"file":"homekitLock.js","sourceRoot":"","sources":["../../src/devices/homekitLock.ts"],"names":[],"mappings":"AAGA,OAAO,GAAG,MAAM,SAAS,CAAC;AAE1B,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAIhC,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;AAE3B,MAAM,uBAAwB,SAAQ,KAAK;CAAG;AAE9C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,aAAa;IAMjD;IALD,WAAW,CAAU;IACrB,QAAQ,GAAG,KAAK,CAAC;IAEzB,YACE,QAAkC,EAC3B,YAAkB;QAEzB,KAAK,CAAC,QAAQ,EAAE,YAAY,gCAAwB,WAAW,CAAC,CAAC;QAF1D,iBAAY,GAAZ,YAAY,CAAM;QAGzB,IAAI,CAAC,WAAW,GAAG,CAAC,C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