homebridge-ttlock-accesscode 2.4.0-beta.0 → 3.0.0-beta.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.
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 +436 -69
  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 +44 -16
  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
@@ -57,20 +57,15 @@
57
57
 
58
58
  .section-heading p,
59
59
  .advanced-panel p,
60
- .inline-note,
61
60
  .field-note {
62
61
  color: var(--tt-muted);
63
62
  margin: 0;
64
63
  }
65
64
 
66
- .panel,
67
- .item-card {
65
+ .panel {
68
66
  background: var(--tt-panel);
69
67
  border: 1px solid var(--tt-border);
70
68
  border-radius: 6px;
71
- }
72
-
73
- .panel {
74
69
  padding: 18px;
75
70
  }
76
71
 
@@ -100,7 +95,7 @@
100
95
  }
101
96
 
102
97
  .polling-grid {
103
- grid-template-columns: repeat(5, minmax(0, 1fr));
98
+ grid-template-columns: repeat(4, minmax(0, 1fr));
104
99
  }
105
100
 
106
101
  .field-grid .wide {
@@ -117,11 +112,6 @@
117
112
  color: var(--tt-danger);
118
113
  }
119
114
 
120
- .form-control[readonly] {
121
- background: #f3f6fa;
122
- color: #344054;
123
- }
124
-
125
115
  .secret-value {
126
116
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace;
127
117
  font-size: 12px;
@@ -174,97 +164,6 @@
174
164
  color: #475467;
175
165
  }
176
166
 
177
- .hub-list,
178
- .door-list {
179
- display: grid;
180
- gap: 10px;
181
- }
182
-
183
- .item-card {
184
- padding: 12px;
185
- }
186
-
187
- .item-header {
188
- align-items: flex-start;
189
- display: grid;
190
- gap: 12px;
191
- grid-template-columns: minmax(0, 1fr) auto;
192
- margin-bottom: 12px;
193
- }
194
-
195
- .item-title {
196
- font-weight: 700;
197
- margin: 0 0 2px;
198
- min-width: 0;
199
- overflow-wrap: anywhere;
200
- }
201
-
202
- .item-title-row {
203
- align-items: center;
204
- display: flex;
205
- flex-wrap: wrap;
206
- gap: 8px;
207
- }
208
-
209
- .empty-state {
210
- border: 1px dashed var(--tt-border-strong);
211
- border-radius: 6px;
212
- color: var(--tt-muted);
213
- padding: 12px;
214
- }
215
-
216
- .subsection {
217
- border-top: 1px solid var(--tt-border);
218
- display: grid;
219
- gap: 12px;
220
- padding-top: 16px;
221
- }
222
-
223
- .subsection:first-of-type {
224
- border-top: 0;
225
- padding-top: 0;
226
- }
227
-
228
- .subsection + .subsection {
229
- margin-top: 18px;
230
- }
231
-
232
- .subsection-header {
233
- align-items: flex-start;
234
- display: grid;
235
- gap: 12px;
236
- grid-template-columns: minmax(0, 1fr) auto;
237
- }
238
-
239
- .subsection-header h4 {
240
- font-size: 15px;
241
- font-weight: 700;
242
- line-height: 1.25;
243
- margin: 0 0 2px;
244
- }
245
-
246
- .hub-actions,
247
- .door-command-row {
248
- align-items: center;
249
- display: flex;
250
- flex-wrap: wrap;
251
- gap: 8px;
252
- }
253
-
254
- .setup-card {
255
- background: #ffffff;
256
- }
257
-
258
- .hub-grid {
259
- grid-template-columns: 1fr;
260
- }
261
-
262
- .door-fields {
263
- display: grid;
264
- gap: 12px;
265
- grid-template-columns: 1fr;
266
- }
267
-
268
167
  .advanced-panel {
269
168
  padding: 0;
270
169
  }
@@ -345,42 +244,6 @@
345
244
  padding: 18px;
346
245
  }
347
246
 
348
- .choice-grid {
349
- display: grid;
350
- gap: 10px;
351
- }
352
-
353
- .choice-button {
354
- background: #ffffff;
355
- border: 1px solid var(--tt-border);
356
- border-radius: 6px;
357
- padding: 12px;
358
- text-align: left;
359
- transition:
360
- border-color 0.14s ease,
361
- box-shadow 0.14s ease;
362
- width: 100%;
363
- }
364
-
365
- .choice-button:hover,
366
- .choice-button:focus {
367
- border-color: var(--tt-primary);
368
- box-shadow: 0 0 0 3px rgb(37 99 235 / 0.12);
369
- }
370
-
371
- .choice-title {
372
- color: var(--tt-text);
373
- display: block;
374
- font-weight: 700;
375
- margin-bottom: 3px;
376
- }
377
-
378
- .choice-meta {
379
- color: var(--tt-muted);
380
- display: block;
381
- font-size: 12px;
382
- }
383
-
384
247
  .spinner-inline {
385
248
  align-items: center;
386
249
  display: inline-flex;
@@ -393,24 +256,17 @@
393
256
  }
394
257
 
395
258
  .topbar,
396
- .section-heading,
397
- .item-header,
398
- .subsection-header,
399
- .door-fields {
259
+ .section-heading {
400
260
  align-items: stretch;
401
261
  display: grid;
402
262
  grid-template-columns: 1fr;
403
263
  }
404
264
 
405
265
  .field-grid,
406
- .polling-grid,
407
- .hub-grid {
266
+ .polling-grid {
408
267
  grid-template-columns: 1fr;
409
268
  }
410
269
 
411
- .subsection-header .btn,
412
- .hub-actions .btn,
413
- .door-command-row .btn,
414
270
  .button-row .btn {
415
271
  width: 100%;
416
272
  }
@@ -35,12 +35,20 @@ function requestError(message, status = 400) {
35
35
  return new RequestError(message, { status });
36
36
  }
37
37
 
38
- function getRequiredString(payload, field, label) {
39
- const value = String(payload?.[field] ?? '').trim();
40
- if (!value) {
38
+ // plugin-ui-utils writes any error that is not a RequestError to the log with console.error, and a raw
39
+ // error can carry the request with the client secret, password hash or access token. Pass on the message only.
40
+ function toRequestError(error) {
41
+ return error instanceof RequestError ? error : requestError(error instanceof Error ? error.message : String(error), 500);
42
+ }
43
+
44
+ // trim: false for the client secret and password, which are used exactly as typed (spaces at either end can be
45
+ // part of them); a value of only spaces still counts as missing
46
+ function getRequiredString(payload, field, label, { trim = true } = {}) {
47
+ const value = String(payload?.[field] ?? '');
48
+ if (!value.trim()) {
41
49
  throw requestError(`${label} is required.`);
42
50
  }
43
- return value;
51
+ return trim ? value.trim() : value;
44
52
  }
45
53
 
46
54
  async function importBuiltModule(modulePath) {
@@ -54,68 +62,41 @@ async function importBuiltModule(modulePath) {
54
62
 
55
63
  async function createTTLockApi(payload) {
56
64
  const clientId = getRequiredString(payload, 'clientId', 'TTLock Client ID');
57
- const clientSecret = getRequiredString(payload, 'clientSecret', 'TTLock Client Secret');
65
+ const clientSecret = getRequiredString(payload, 'clientSecret', 'TTLock Client Secret', { trim: false });
58
66
  const username = getRequiredString(payload, 'username', 'TTLock username');
59
- const password = getRequiredString(payload, 'password', 'TTLock password');
67
+ const password = getRequiredString(payload, 'password', 'TTLock password', { trim: false });
60
68
  const { TTLockApi } = await importBuiltModule(['api', 'ttlockApi.js']);
61
69
  const api = new TTLockApi(new StreamLogger(), clientId, clientSecret);
62
70
  await api.authenticate(username, password);
63
71
  return api;
64
72
  }
65
73
 
66
- async function createDirigeraClient(payload) {
67
- const gatewayIP = getRequiredString(payload, 'gatewayIP', 'DIRIGERA gateway IP');
68
- const { createDirigeraClient } = await import('dirigera');
69
-
70
- return createDirigeraClient({
71
- gatewayIP,
72
- accessToken: payload?.accessToken,
73
- });
74
- }
75
-
76
74
  class TTLockAccessCodeUiServer extends HomebridgePluginUiServer {
77
75
  constructor() {
78
76
  super();
79
77
 
80
78
  this.onRequest('/ttlock-test-auth', this.testTTLockAuth.bind(this));
81
79
  this.onRequest('/ttlock-locks', this.listTTLockLocks.bind(this));
82
- this.onRequest('/dirigera-authenticate', this.authenticateDirigera.bind(this));
83
- this.onRequest('/dirigera-open-close-sensors', this.listDirigeraOpenCloseSensors.bind(this));
84
80
 
85
81
  this.ready();
86
82
  }
87
83
 
88
84
  async testTTLockAuth(payload) {
89
- await createTTLockApi(payload);
90
- return { ok: true };
85
+ try {
86
+ await createTTLockApi(payload);
87
+ return { ok: true };
88
+ } catch (error) {
89
+ throw toRequestError(error);
90
+ }
91
91
  }
92
92
 
93
93
  async listTTLockLocks(payload) {
94
- const api = await createTTLockApi(payload);
95
- return api.listLocksForSetup();
96
- }
97
-
98
- async authenticateDirigera(payload) {
99
- const client = await createDirigeraClient(payload);
100
- const accessToken = await client.authenticate({ verbose: false });
101
- return { accessToken };
102
- }
103
-
104
- async listDirigeraOpenCloseSensors(payload) {
105
- const accessToken = getRequiredString(payload, 'accessToken', 'DIRIGERA access token');
106
- const client = await createDirigeraClient({ ...payload, accessToken });
107
- const sensors = await client.openCloseSensors.list();
108
-
109
- return sensors.map((sensor) => ({
110
- batteryPercentage: sensor.attributes?.batteryPercentage,
111
- id: sensor.id,
112
- isOpen: sensor.attributes?.isOpen,
113
- isReachable: Boolean(sensor.isReachable),
114
- manufacturer: sensor.attributes?.manufacturer || '',
115
- model: sensor.attributes?.model || '',
116
- name: sensor.attributes?.customName || sensor.attributes?.model || sensor.id,
117
- roomName: sensor.room?.name || '',
118
- }));
94
+ try {
95
+ const api = await createTTLockApi(payload);
96
+ return await api.listLocksForSetup();
97
+ } catch (error) {
98
+ throw toRequestError(error);
99
+ }
119
100
  }
120
101
  }
121
102
 
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": "2.4.0-beta.0",
4
+ "version": "3.0.0-beta.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",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "engines": {
16
16
  "homebridge": "^1.11.2 || ^2.0.0",
17
- "node": "^22 || ^24"
17
+ "node": "^22 || ^24 || ^26"
18
18
  },
19
19
  "publishConfig": {
20
20
  "access": "public"
@@ -22,7 +22,7 @@
22
22
  "main": "dist/index.js",
23
23
  "scripts": {
24
24
  "build": "rimraf -I ./dist && tsc",
25
- "lint": "eslint src/**/*.ts homebridge-ui/**/*.js --max-warnings=0",
25
+ "lint": "eslint \"src/**/*.ts\" \"homebridge-ui/**/*.js\" --max-warnings=0",
26
26
  "prepublishOnly": "npm run lint && npm run build",
27
27
  "test": "echo \"No test specified\" && exit 0",
28
28
  "watch": "npm run build && npm link && nodemon"
@@ -34,6 +34,7 @@
34
34
  "homebridge-plugin",
35
35
  "homebridge-ttlock",
36
36
  "homebridge-ttlock-accesscode",
37
+ "homekit",
37
38
  "smarthome",
38
39
  "smart home",
39
40
  "smart lock",
@@ -50,14 +51,13 @@
50
51
  "devDependencies": {
51
52
  "@eslint/js": "^10.0.1",
52
53
  "@stylistic/eslint-plugin": "^5.10.0",
53
- "@types/node": "^25.9.1",
54
- "eslint": "^10.4.0",
55
- "homebridge": "^2.0.2",
54
+ "@types/node": "^26.6.5",
55
+ "eslint": "^10.13.0",
56
+ "homebridge": "^2.4.0",
56
57
  "nodemon": "^3.1.14",
57
58
  "rimraf": "^6.1.3",
58
- "ts-node": "^10.9.2",
59
59
  "typescript": "^6.0.3",
60
- "typescript-eslint": "^8.59.4"
60
+ "typescript-eslint": "^8.72.0"
61
61
  },
62
62
  "homepage": "https://github.com/ZeliardM/homebridge-ttlock-accesscode#readme",
63
63
  "funding": [
@@ -71,12 +71,8 @@
71
71
  }
72
72
  ],
73
73
  "dependencies": {
74
- "@homebridge/plugin-ui-utils": "^2.2.3",
75
- "axios": "^1.16.1",
76
- "ber-tlv": "^0.9.2",
77
- "dirigera": "^1.8.0"
78
- },
79
- "overrides": {
80
- "node-persist": "^4.0.4"
74
+ "@homebridge/plugin-ui-utils": "^2.2.6",
75
+ "axios": "^1.21.0",
76
+ "ber-tlv": "^0.9.2"
81
77
  }
82
78
  }
@@ -1,34 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- import type { Logger } from 'homebridge';
3
- import type { ManualDoorHubConfig } from '../config.js';
4
- export interface DirigeraDoorSensorUpdate {
5
- sensorId: string;
6
- isOpen: boolean;
7
- batteryPercentage?: number | undefined;
8
- isReachable?: boolean | undefined;
9
- source: 'initial' | 'event' | 'poll';
10
- }
11
- export interface DirigeraDoorSensorUnavailable {
12
- sensorId: string;
13
- error: string;
14
- source: 'initial' | 'event' | 'poll';
15
- }
16
- export default class DirigeraApi extends EventEmitter {
17
- private readonly config;
18
- private readonly pollingIntervalMs;
19
- private readonly candidateSensorIds;
20
- private readonly log;
21
- private client?;
22
- private pollingInterval;
23
- private sensorIds;
24
- constructor(config: ManualDoorHubConfig, pollingIntervalMs: number, candidateSensorIds: Set<string>, log: Logger);
25
- start(): Promise<Set<string>>;
26
- stop(): void;
27
- private resolveConfiguredSensors;
28
- private startListeningForUpdates;
29
- private startPolling;
30
- private pollSensors;
31
- private emitUpdate;
32
- private emitUnavailable;
33
- private isObject;
34
- }
@@ -1,127 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- export default class DirigeraApi extends EventEmitter {
3
- config;
4
- pollingIntervalMs;
5
- candidateSensorIds;
6
- log;
7
- client;
8
- pollingInterval;
9
- sensorIds = new Set();
10
- constructor(config, pollingIntervalMs, candidateSensorIds, log) {
11
- super();
12
- this.config = config;
13
- this.pollingIntervalMs = pollingIntervalMs;
14
- this.candidateSensorIds = candidateSensorIds;
15
- this.log = log;
16
- }
17
- async start() {
18
- const { createDirigeraClient } = await import('dirigera');
19
- this.client = await createDirigeraClient({
20
- gatewayIP: this.config.ip,
21
- accessToken: this.config.accessToken,
22
- });
23
- this.sensorIds = await this.resolveConfiguredSensors();
24
- if (this.sensorIds.size === 0) {
25
- this.log.info(`DIRIGERA connected at ${this.config.ip}; no configured manual door sensors were found on this hub`);
26
- return new Set();
27
- }
28
- this.log.info(`DIRIGERA connected at ${this.config.ip} for ${this.sensorIds.size} manual door sensor(s)`);
29
- await this.pollSensors('initial');
30
- this.startListeningForUpdates();
31
- this.startPolling();
32
- return new Set(this.sensorIds);
33
- }
34
- stop() {
35
- if (this.pollingInterval) {
36
- clearInterval(this.pollingInterval);
37
- this.pollingInterval = undefined;
38
- }
39
- try {
40
- this.client?.stopListeningForUpdates?.();
41
- }
42
- catch (error) {
43
- this.log.debug('Failed to stop DIRIGERA listener:', error);
44
- }
45
- }
46
- async resolveConfiguredSensors() {
47
- if (!this.client) {
48
- return new Set();
49
- }
50
- const sensors = await this.client.openCloseSensors.list();
51
- const hubSensorIds = new Set(sensors.map(sensor => sensor.id));
52
- return new Set(Array.from(this.candidateSensorIds).filter(sensorId => hubSensorIds.has(sensorId)));
53
- }
54
- startListeningForUpdates() {
55
- this.client?.startListeningForUpdates((event) => {
56
- if (!this.isObject(event)) {
57
- return;
58
- }
59
- if (event.type !== 'deviceStateChanged' || !this.isObject(event.data)) {
60
- return;
61
- }
62
- const sensorId = typeof event.data.id === 'string' ? event.data.id : undefined;
63
- if (!sensorId || !this.sensorIds.has(sensorId)) {
64
- return;
65
- }
66
- const isReachable = typeof event.data.isReachable === 'boolean' ? event.data.isReachable : undefined;
67
- const attributes = this.isObject(event.data.attributes) ? event.data.attributes : undefined;
68
- if (isReachable === false && typeof attributes?.isOpen !== 'boolean') {
69
- this.emitUnavailable(sensorId, 'DIRIGERA sensor is not reachable', 'event');
70
- return;
71
- }
72
- if (typeof attributes?.isOpen !== 'boolean') {
73
- return;
74
- }
75
- this.emitUpdate({
76
- sensorId,
77
- isOpen: attributes.isOpen,
78
- batteryPercentage: typeof attributes.batteryPercentage === 'number' ? attributes.batteryPercentage : undefined,
79
- isReachable,
80
- source: 'event',
81
- });
82
- });
83
- }
84
- startPolling() {
85
- this.pollingInterval = setInterval(() => void this.pollSensors('poll'), this.pollingIntervalMs);
86
- this.pollingInterval.unref?.();
87
- }
88
- async pollSensors(source) {
89
- if (!this.client) {
90
- return;
91
- }
92
- for (const sensorId of this.sensorIds) {
93
- try {
94
- const sensor = await this.client.openCloseSensors.get({ id: sensorId });
95
- const isReachable = sensor.isReachable !== false;
96
- if (!isReachable) {
97
- this.emitUnavailable(sensorId, 'DIRIGERA sensor is not reachable', source);
98
- continue;
99
- }
100
- if (typeof sensor.attributes?.isOpen !== 'boolean') {
101
- this.emitUnavailable(sensorId, 'DIRIGERA sensor did not report an open/closed state', source);
102
- continue;
103
- }
104
- this.emitUpdate({
105
- sensorId,
106
- isOpen: sensor.attributes.isOpen,
107
- batteryPercentage: sensor.attributes.batteryPercentage,
108
- isReachable,
109
- source,
110
- });
111
- }
112
- catch (error) {
113
- this.emitUnavailable(sensorId, error instanceof Error ? error.message : String(error), source);
114
- }
115
- }
116
- }
117
- emitUpdate(update) {
118
- this.emit('sensorUpdate', update);
119
- }
120
- emitUnavailable(sensorId, error, source) {
121
- this.emit('sensorUnavailable', { sensorId, error, source });
122
- }
123
- isObject(value) {
124
- return typeof value === 'object' && value !== null;
125
- }
126
- }
127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AAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC;YACjG,CAAC;QACH,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,MAAgC;QACjD,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;IAEO,eAAe,CAAC,QAAgB,EAAE,KAAa,EAAE,MAAoC;QAC3F,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAA0C,CAAC,CAAC;IACtG,CAAC;IAEO,QAAQ,CAAC,KAAc;QAC7B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;IACrD,CAAC;CACF"}
@@ -1,50 +0,0 @@
1
- import type { Logger, PlatformAccessory } from 'homebridge';
2
- import type { ManualDoorConfig } from '../config.js';
3
- import type TTLockAccessCodePlatform from '../platform.js';
4
- import type { DirigeraDoorSensorUpdate } from '../api/dirigeraApi.js';
5
- import type { ManualDoorAccessoryContext } from '../platform.js';
6
- export type DoorGuardState = {
7
- canOperate: boolean;
8
- reason?: string;
9
- };
10
- export default class HomeKitDeviceDoor {
11
- private readonly platform;
12
- readonly config: ManualDoorConfig;
13
- readonly log: Logger;
14
- readonly homebridgeAccessory: PlatformAccessory<ManualDoorAccessoryContext>;
15
- private readonly batteryService;
16
- private readonly doorService;
17
- private available;
18
- private batteryLevel;
19
- private contactOpen?;
20
- private hasReportedState;
21
- private lastUnavailableReason;
22
- constructor(platform: TTLockAccessCodePlatform, config: ManualDoorConfig);
23
- get id(): string;
24
- get name(): string;
25
- get linkedLockId(): string;
26
- get sensorId(): string;
27
- get manufacturer(): string;
28
- get model(): string;
29
- get serialNumber(): string;
30
- get firmwareRevision(): string;
31
- get uuid(): string;
32
- applySensorUpdate(update: DirigeraDoorSensorUpdate): void;
33
- markUnavailable(reason: string): void;
34
- getLockGuardState(): DoorGuardState;
35
- private initializeAccessory;
36
- private setupDoorService;
37
- private setupBatteryService;
38
- private addService;
39
- private updateAccessoryInformation;
40
- private getCurrentPosition;
41
- private getTargetPosition;
42
- private setTargetPosition;
43
- private getStatusFault;
44
- private getBatteryLevel;
45
- private getStatusLowBattery;
46
- private syncCharacteristics;
47
- private normalizeBatteryLevel;
48
- private getUnavailableError;
49
- private identify;
50
- }