@homebridge-plugins/homebridge-august 3.2.2 → 3.3.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 (46) hide show
  1. package/.github/copilot-instructions.md +200 -0
  2. package/.github/npm-version-script-esm.js +97 -0
  3. package/CHANGELOG.md +44 -9
  4. package/dist/Platform.Base.d.ts +288 -0
  5. package/dist/Platform.Base.d.ts.map +1 -0
  6. package/dist/Platform.Base.js +797 -0
  7. package/dist/Platform.Base.js.map +1 -0
  8. package/dist/Platform.HAP.d.ts +27 -0
  9. package/dist/Platform.HAP.d.ts.map +1 -0
  10. package/dist/Platform.HAP.js +68 -0
  11. package/dist/Platform.HAP.js.map +1 -0
  12. package/dist/connectivity-manager.d.ts +3 -3
  13. package/dist/connectivity-manager.d.ts.map +1 -1
  14. package/dist/connectivity-manager.js +57 -14
  15. package/dist/connectivity-manager.js.map +1 -1
  16. package/dist/devices/device.d.ts +5 -16
  17. package/dist/devices/device.d.ts.map +1 -1
  18. package/dist/devices/device.js +18 -75
  19. package/dist/devices/device.js.map +1 -1
  20. package/dist/devices/lock.d.ts +3 -3
  21. package/dist/devices/lock.d.ts.map +1 -1
  22. package/dist/devices/lock.js +41 -41
  23. package/dist/devices/lock.js.map +1 -1
  24. package/dist/index.js +4 -4
  25. package/dist/index.js.map +1 -1
  26. package/dist/package.json +10 -8
  27. package/dist/platform.matter.d.ts +18 -20
  28. package/dist/platform.matter.d.ts.map +1 -1
  29. package/dist/platform.matter.js +74 -80
  30. package/dist/platform.matter.js.map +1 -1
  31. package/docs/variables/default.html +1 -1
  32. package/package.json +10 -8
  33. package/test/device.test.ts +384 -0
  34. package/test/{platform.test.ts → platform.hap.test.ts} +23 -23
  35. package/test/platform.polling.test.ts +5 -5
  36. package/.copilot/instructions.md +0 -261
  37. package/.github/scripts/compute-version-override.cjs +0 -51
  38. package/.github/scripts/normalize-changelog-header.cjs +0 -86
  39. package/.github/scripts/npm-version-script-esm-auto.js +0 -201
  40. package/.github/scripts/resolve-version-bump-esm.js +0 -118
  41. package/dist/platform.d.ts +0 -146
  42. package/dist/platform.d.ts.map +0 -1
  43. package/dist/platform.js +0 -755
  44. package/dist/platform.js.map +0 -1
  45. package/test/connectivity-manager.test.ts +0 -590
  46. package/test/platform.matter.test.ts +0 -660
@@ -0,0 +1,200 @@
1
+ # Copilot Instructions for Homebridge August Plugin
2
+
3
+ ## Repository Overview
4
+
5
+ This repository is a Homebridge dynamic platform plugin for August and Yale locks.
6
+
7
+ - Runtime uses TypeScript + ES modules.
8
+ - The plugin supports a dual runtime path:
9
+ - HAP path via AugustPlatform.
10
+ - Matter path via AugustMatterPlatform when Homebridge Matter is available and enabled.
11
+
12
+ ## Current Architecture
13
+
14
+ - Plugin type: dynamic platform plugin.
15
+ - Entry point: src/index.ts.
16
+ - HAP platform class: src/Platform.HAP.ts (AugustPlatform).
17
+ - Matter platform class: src/Platform.Matter.ts (AugustMatterPlatform).
18
+ - Shared device logic: src/devices/device.ts and src/devices/lock.ts.
19
+ - Connectivity state machine: src/connectivity-manager.ts.
20
+ - Config/types/constants: src/settings.ts.
21
+ - UI backend/static assets: src/homebridge-ui/.
22
+
23
+ The entry point in src/index.ts registers a proxy constructor that selects Matter or HAP at runtime based on:
24
+ - api.isMatterAvailable()
25
+ - api.isMatterEnabled()
26
+ - config.options.disableMatter
27
+
28
+ ## Toolchain and Runtime
29
+
30
+ Use the values from package.json and tsconfig.json as source of truth.
31
+
32
+ - Node support: ^22 || ^24
33
+ - Homebridge support: ^2.0.0
34
+ - TypeScript target: ES2022
35
+ - Module: ES2022
36
+ - Module resolution: bundler
37
+ - Strict mode: enabled (noImplicitAny is false)
38
+
39
+ ## Commands
40
+
41
+ ### Build and Packaging
42
+
43
+ ```bash
44
+ npm run clean
45
+ npm run build
46
+ npm run prepublishOnly
47
+ ```
48
+
49
+ ### Lint
50
+
51
+ ```bash
52
+ npm run lint
53
+ npm run lint:fix
54
+ ```
55
+
56
+ ### Test
57
+
58
+ ```bash
59
+ npm test
60
+ npm run test:watch
61
+ npm run test-coverage
62
+ ```
63
+
64
+ ### Docs
65
+
66
+ ```bash
67
+ npm run docs
68
+ npm run docs:lint
69
+ ```
70
+
71
+ ### Development
72
+
73
+ ```bash
74
+ npm run watch
75
+ npm run plugin-ui
76
+ ```
77
+
78
+ ## Branch and Release Workflow
79
+
80
+ This repo follows a beta-first workflow.
81
+
82
+ - Do not target main directly.
83
+ - Target a beta branch named beta-X.Y.Z.
84
+ - Use issue labels to determine bump type:
85
+ - patch
86
+ - minor
87
+ - major
88
+
89
+ If no matching beta branch exists, create one from the next expected version.
90
+
91
+ ## Coding Expectations
92
+
93
+ 1. Keep imports as ES module paths ending in .js.
94
+ 2. Preserve Homebridge plugin constants:
95
+ - PLATFORM_NAME = August
96
+ - PLUGIN_NAME = homebridge-august
97
+ 3. Maintain backward compatibility unless issue scope is explicitly breaking.
98
+ 4. Keep runtime and schema aligned:
99
+ - Update src/settings.ts and config.schema.json together for option changes.
100
+ 5. Add or update Vitest coverage for behavior changes.
101
+ 6. Never commit generated output from dist/.
102
+
103
+ ## Homebridge and August/Yale Patterns
104
+
105
+ - Use Homebridge DynamicPlatformPlugin patterns for lifecycle methods.
106
+ - Use PlatformAccessory caching and proper unregister/update behavior.
107
+ - Handle August auth and refresh flows defensively.
108
+ - Respect polling and push/update intervals from options.
109
+ - Prefer robust error classification and graceful retries over broad catch-and-ignore.
110
+
111
+ ## Matter and HomeKit Integration
112
+
113
+ ### Matter Implementation
114
+
115
+ The plugin uses a dual-mode runtime that selects HAP or Matter at startup.
116
+
117
+ - HAP mode (HomeKit Accessory Protocol): implemented by AugustPlatform in src/Platform.HAP.ts.
118
+ - Matter mode: implemented by AugustMatterPlatform in src/Platform.Matter.ts.
119
+
120
+ In src/index.ts, the platform proxy chooses AugustMatterPlatform only when Matter is available and enabled, and the user has not disabled Matter via config.options.disableMatter. Otherwise it falls back to AugustPlatform.
121
+
122
+ ### Matter Device Type Mapping
123
+
124
+ Matter registrations use api.matter.deviceTypes.* and api.matter.types.* from Homebridge's Matter API.
125
+
126
+ | August Device | HAP Service | Matter DeviceType | Matter Clusters |
127
+ |---|---|---|---|
128
+ | August/Yale lock | LockMechanism (plus optional ContactSensor in HAP mode) | DoorLock | doorLock |
129
+
130
+ Notes:
131
+ - AugustMatterPlatform currently maps lock accessories to Matter DoorLock.
132
+ - Lock state updates are written through the doorLock cluster (for example lockState) and mirrored from August API polling/push updates.
133
+
134
+ ### Authoritative Matter References
135
+
136
+ 1. https://matter-js.github.io/docs/index.html
137
+ 2. https://github.com/homebridge-plugins/homebridge-matter
138
+
139
+ For cluster, attribute, deviceType, and conversion details, use the homebridge-matter wiki:
140
+ - Introduction: https://github.com/homebridge-plugins/homebridge-matter/wiki/Introduction
141
+ - Core Concepts: https://github.com/homebridge-plugins/homebridge-matter/wiki/Core-Concepts
142
+ - Getting Started: https://github.com/homebridge-plugins/homebridge-matter/wiki/Getting-Started
143
+ - State Management: https://github.com/homebridge-plugins/homebridge-matter/wiki/State-Management
144
+ - Monitoring External Changes: https://github.com/homebridge-plugins/homebridge-matter/wiki/Monitoring-External-Changes
145
+ - Best Practices: https://github.com/homebridge-plugins/homebridge-matter/wiki/Best-Practices
146
+ - Advanced Patterns: https://github.com/homebridge-plugins/homebridge-matter/wiki/Advanced-Patterns
147
+ - API Reference: https://github.com/homebridge-plugins/homebridge-matter/wiki/API-Reference
148
+ - Matter Types: https://github.com/homebridge-plugins/homebridge-matter/wiki/Matter-Types
149
+ - Value Conversions: https://github.com/homebridge-plugins/homebridge-matter/wiki/Value-Conversions
150
+
151
+ Device reference pages:
152
+ - Sensors (Section 7): https://github.com/homebridge-plugins/homebridge-matter/wiki/Section-7-Sensors
153
+ - Closure (Section 8): https://github.com/homebridge-plugins/homebridge-matter/wiki/Section-8-Closure
154
+
155
+ ## Testing Guidelines
156
+
157
+ - Test files live under test/ with .test.ts suffix.
158
+ - Mock external dependencies:
159
+ - august-yale
160
+ - file system
161
+ - Homebridge API surfaces
162
+ - Cover:
163
+ - startup and discovery
164
+ - polling loops
165
+ - push/pull state sync
166
+ - Matter fallback behavior
167
+ - error paths and retries
168
+
169
+ ## Files to Avoid Editing Directly
170
+
171
+ - dist/
172
+ - node_modules/
173
+ - docs/ generated output unless intentionally regenerating docs
174
+
175
+ ## Changelog Requirements
176
+
177
+ When adding a release entry to CHANGELOG.md:
178
+
179
+ 1. Header format:
180
+
181
+ ```md
182
+ ## [X.Y.Z](https://github.com/homebridge-plugins/homebridge-august/releases/tag/vX.Y.Z) (YYYY-MM-DD)
183
+ ```
184
+
185
+ 2. Add sections as needed (for example Bug Fixes, Features, Documentation).
186
+
187
+ 3. Include a trailing full changelog comparison line:
188
+
189
+ ```md
190
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-august/compare/vX.Y.(Z-1)...vX.Y.Z
191
+ ```
192
+
193
+ 4. Ensure commit links point to this repository:
194
+ - https://github.com/homebridge-plugins/homebridge-august/commit/<sha>
195
+
196
+ ## Security and Privacy
197
+
198
+ - Never log secrets (passwords, tokens, validation codes).
199
+ - Avoid exposing sensitive values in thrown errors.
200
+ - Validate user-supplied config inputs before use.
@@ -0,0 +1,97 @@
1
+ #!/bin/env node
2
+
3
+ /**
4
+ * This scripts queries the npm registry to pull out the latest version for a given tag.
5
+ */
6
+
7
+ import assert from 'node:assert'
8
+ import child_process from 'node:child_process'
9
+ import fs from 'node:fs'
10
+ import process from 'node:process'
11
+
12
+ const BRANCH_VERSION_PATTERN = /^([A-Z]+)-(\d+\.\d+\.\d+)$/i
13
+
14
+ // Load the contents of the package.json file
15
+ const packageJSON = JSON.parse(fs.readFileSync('package.json', 'utf8'))
16
+
17
+ const refArgument = process.argv[2]
18
+ const tagArgument = process.argv[3] || 'latest'
19
+
20
+ if (!refArgument) {
21
+ console.error('ref argument is missing')
22
+ console.error('Usage: npm-version-script-esm.js <ref> [tag]')
23
+ process.exit(1)
24
+ }
25
+
26
+ /**
27
+ * Queries the NPM registry for the latest version for the provided base version and tag.
28
+ * If the tag is latest, then the base version is returned if it exists. For other tags, the latest
29
+ * version found for that base version and tag is returned.
30
+ * @param baseVersion The base version to query for, e.g. 2.0.0
31
+ * @param tag The tag to query for, e.g. beta or latest
32
+ * @returns {string} Returns the version, or '' if not found
33
+ */
34
+ function getTagVersionFromNpm(baseVersion, tag) {
35
+ try {
36
+ return JSON.parse(child_process.execSync(`npm info ${packageJSON.name} versions --json`).toString('utf8').trim())
37
+ .filter(v => tag === 'latest' ? v === baseVersion : v.startsWith(`${baseVersion}-${tag}.`)) // find all published versions for this base version and tag
38
+ .reduce((_, current) => current, '') // choose the last as they're sorted in ascending order, or '' if there are none
39
+ } catch (e) {
40
+ console.error(`Failed to query the npm registry for the latest version for tag: ${tag}`, e)
41
+ // throw e;
42
+ return ''
43
+ }
44
+ }
45
+
46
+ function desiredTargetVersion(ref) {
47
+ // ref is a GitHub action ref string
48
+ if (ref.startsWith('refs/pull/')) {
49
+ throw new Error('The version script was executed inside a PR!')
50
+ }
51
+
52
+ assert(ref.startsWith('refs/heads/'))
53
+ const branchName = ref.slice('refs/heads/'.length)
54
+
55
+ const results = branchName.match(BRANCH_VERSION_PATTERN)
56
+ if (results !== null) {
57
+ if (results[1] !== tagArgument) {
58
+ console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`)
59
+ }
60
+
61
+ return results[2]
62
+ }
63
+
64
+ throw new Error(`Malformed branch name for ref: ${ref}. Can't derive the base version. Use a branch name like: beta-x.x.x or alpha-x.x.x`)
65
+ }
66
+
67
+ // derive the base version from the branch ref
68
+ const baseVersion = desiredTargetVersion(refArgument)
69
+
70
+ // query the npm registry for the latest version of the provided tag name
71
+ const latestReleasedVersion = getTagVersionFromNpm(baseVersion, tagArgument) // e.g. 0.7.0-beta.12
72
+
73
+ let publishTag
74
+
75
+ if (latestReleasedVersion) {
76
+ console.warn(`Latest published version for ${baseVersion} with tag ${tagArgument} is ${latestReleasedVersion}`)
77
+ publishTag = latestReleasedVersion // set this released beta or alpha to be incremented
78
+ } else {
79
+ console.warn(`No published versions for ${baseVersion} with tag ${tagArgument}`)
80
+ publishTag = baseVersion // start off with a new beta or alpha version
81
+ }
82
+
83
+ if (packageJSON.version !== publishTag) {
84
+ // report the change for CI
85
+ console.warn(`Changing version in package.json from ${packageJSON.version} to ${publishTag}`)
86
+
87
+ // save the package.json
88
+ packageJSON.version = publishTag
89
+ fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2))
90
+
91
+ // perform the same change to the package-lock.json
92
+ const packageLockJSON = JSON.parse(fs.readFileSync('package-lock.json', 'utf8'))
93
+ packageLockJSON.version = publishTag
94
+ fs.writeFileSync('package-lock.json', JSON.stringify(packageLockJSON, null, 2))
95
+ } else {
96
+ console.warn(`Leaving version in package.json at ${packageJSON.version}`)
97
+ }
package/CHANGELOG.md CHANGED
@@ -1,30 +1,57 @@
1
- ## [3.2.1](https://github.com/homebridge-plugins/homebridge-august/compare/v3.2.0...v3.2.1) (2026-04-30)
1
+ ## [3.3.0](https://github.com/homebridge-plugins/homebridge-august/releases/tag/v3.3.0) (2026-05-09)
2
2
 
3
3
 
4
+ ### Features
5
+
6
+ - Major refactor: Introduced a new shared Base Platform architecture for HAP (HomeKit) and Matter platforms, improving reliability and maintainability.
7
+ - Improved lock/device management and connectivity handling for both HAP and Matter modes.
8
+
9
+ ### Other Changes
10
+
11
+ - Internal codebase cleanup and test reorganization.
12
+ - Removed legacy scripts and reduced code duplication.
13
+
14
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-august/compare/v3.2.3...v3.3.0
15
+
16
+ ## [3.2.3](https://github.com/homebridge-plugins/homebridge-august/releases/tag/v3.2.3) (2026-05-04)
17
+
4
18
  ### Bug Fixes
5
19
 
6
- * **platform:** probe with a fresh client; add offline heartbeat ([682c68b](https://github.com/homebridge-plugins/homebridge-august/commit/682c68bcbd7d86fb9df350ab0ccac9a07d3e1e2b))
7
- * **platform:** use August.resetTransport() for connectivity recovery ([6ea4f34](https://github.com/homebridge-plugins/homebridge-august/commit/6ea4f34cb710cbff333e71d84b048bb61d34ea64))
20
+ * **platform:** align platform filename/import casing for ESM paths on case-sensitive systems ([974768a](https://github.com/homebridge-plugins/homebridge-august/commit/974768a6c2de6a5682b1d06e60f62bcbc7933841))
8
21
 
22
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-august/compare/v3.2.2...v3.2.3
23
+
24
+ ## [3.2.2](https://github.com/homebridge-plugins/homebridge-august/releases/tag/v3.2.2) (2026-05-03)
25
+
26
+ ### Bug Fixes
9
27
 
28
+ * bump package.json deps ([60b5cf2](https://github.com/homebridge-plugins/homebridge-august/commit/60b5cf2032b9f5da9089019b8ca22b1fcdfd9e05))
10
29
 
11
- # [3.2.0](https://github.com/homebridge-plugins/homebridge-august/compare/v3.1.4...v3.2.0) (2026-04-29)
30
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-august/compare/v3.2.1...v3.2.2
12
31
 
32
+ ## [3.2.1](https://github.com/homebridge-plugins/homebridge-august/releases/tag/v3.2.1) (2026-04-30)
13
33
 
14
34
  ### Bug Fixes
15
35
 
16
- * **platform:** use august-yale's typed exceptions for error classification ([93219ac](https://github.com/homebridge-plugins/homebridge-august/commit/93219accdf8571330b8f3fefa029d727ddf7a6c3))
36
+ * **platform:** probe with a fresh client; add offline heartbeat ([682c68b](https://github.com/homebridge-plugins/homebridge-august/commit/682c68bcbd7d86fb9df350ab0ccac9a07d3e1e2b))
37
+ * **platform:** use August.resetTransport() for connectivity recovery ([6ea4f34](https://github.com/homebridge-plugins/homebridge-august/commit/6ea4f34cb710cbff333e71d84b048bb61d34ea64))
17
38
 
39
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-august/compare/v3.2.0...v3.2.1
40
+
41
+ # [3.2.0](https://github.com/homebridge-plugins/homebridge-august/releases/tag/v3.2.0) (2026-04-29)
42
+
43
+ ### Bug Fixes
18
44
 
45
+ * **platform:** use august-yale's typed exceptions for error classification ([93219ac](https://github.com/homebridge-plugins/homebridge-august/commit/93219accdf8571330b8f3fefa029d727ddf7a6c3))
19
46
 
20
- ## [3.1.4](https://github.com/homebridge-plugins/homebridge-august/compare/v3.1.3...v3.1.4) (2026-04-27)
47
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-august/compare/v3.1.4...v3.2.0
21
48
 
49
+ ## [3.1.4](https://github.com/homebridge-plugins/homebridge-august/releases/tag/v3.1.4) (2026-04-27)
22
50
 
23
51
  ### Bug Fixes
24
52
 
25
53
  * **platform:** destroy August client on session refresh instead of end() ([a12f2b3](https://github.com/homebridge-plugins/homebridge-august/commit/a12f2b328263523eef3b2549383f00ce6dfbf0a1))
26
54
 
27
-
28
55
  ### Features
29
56
 
30
57
  * **lock:** wire PubNub reconnect signal into ConnectivityManager ([462b22c](https://github.com/homebridge-plugins/homebridge-august/commit/462b22c5b53e125d3ec31eceea538a74360f5760))
@@ -33,9 +60,17 @@
33
60
  * **platform:** route pushChanges through ConnectivityManager ([41080f4](https://github.com/homebridge-plugins/homebridge-august/commit/41080f490cd71b504e22f56a80ae6e1c8c9eb016))
34
61
  * **platform:** wire ConnectivityManager into AugustPlatform ([0ce28e3](https://github.com/homebridge-plugins/homebridge-august/commit/0ce28e359a68720ed278e17097f61262ea8705b4))
35
62
 
63
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-august/compare/v3.1.3...v3.1.4
64
+
65
+ ## [3.1.3](https://github.com/homebridge-plugins/homebridge-august/releases/tag/v3.1.3) (2026-04-18)
66
+
67
+ ### Bug Fixes
68
+
69
+ * update dependencies ([ed90943](https://github.com/homebridge-plugins/homebridge-august/commit/ed9094358ab9ec6f724df58c1d98d38cee7db751))
36
70
 
71
+ **Full Changelog**: https://github.com/homebridge-plugins/homebridge-august/compare/v3.1.2...v3.1.3
37
72
 
38
- ## [3.1.2](https://github.com/homebridge-plugins/homebridge-august/compare/v3.1.1...v3.1.2) (2026-04-18)
73
+ ## [3.1.2](https://github.com/homebridge-plugins/homebridge-august/releases/tag/v3.1.2) (2026-04-18)
39
74
 
40
75
  ### Bug Fixes
41
76
 
@@ -44,7 +79,7 @@
44
79
 
45
80
  **Full Changelog**: https://github.com/homebridge-plugins/homebridge-august/compare/v3.1.1...v3.1.2
46
81
 
47
- ## [3.1.1](https://github.com/homebridge-plugins/homebridge-august/compare/v3.1.0...v3.1.1) (2026-04-16)
82
+ ## [3.1.1](https://github.com/homebridge-plugins/homebridge-august/releases/tag/v3.1.1) (2026-04-16)
48
83
 
49
84
  ### Bug Fixes
50
85
 
@@ -0,0 +1,288 @@
1
+ import type { API, DynamicPlatformPlugin, Logging, PlatformAccessory } from 'homebridge';
2
+ import type { AugustPlatformConfig, credentials, device, devicesConfig, options } from './settings.js';
3
+ import { PluginLogger } from '@homebridge/plugin-logger';
4
+ import August from 'august-yale';
5
+ import { ConnectivityManager } from './connectivity-manager.js';
6
+ /**
7
+ * Base platform class for August/Yale Homebridge plugin.
8
+ * Contains all shared logic for config, credentials, device discovery, polling, etc.
9
+ * Protocol-specific logic (HAP/Matter) should be implemented in subclasses.
10
+ */
11
+ export declare class AugustPlatformBase implements DynamicPlatformPlugin {
12
+ /**
13
+ * Subscribes to PubNub push updates for a given lockId.
14
+ * Stores unsubscribe/teardown functions in the lockMechanisms map for unified cleanup.
15
+ * Calls the provided event handler on push events.
16
+ *
17
+ * @param {string} lockId - The lock ID to subscribe to.
18
+ * @param {(event: any, timestamp: Date) => Promise<void>} onEvent - Handler for push events.
19
+ * @param {(status: any) => void} [onStatus] - Optional handler for PubNub status events.
20
+ * @returns {Promise<void>}
21
+ */
22
+ subscribePubNub(lockId: string, onEvent: (event: any, timestamp: Date) => Promise<void>, onStatus?: (status: any) => void): Promise<void>;
23
+ /**
24
+ * Tears down the PubNub subscription for a given lockId (if present).
25
+ * Safe to call multiple times.
26
+ * @param {string} lockId
27
+ */
28
+ tearDownPubNubSubscription(lockId: string): void;
29
+ accessories: PlatformAccessory[];
30
+ readonly api: API;
31
+ readonly log: Logging;
32
+ config: AugustPlatformConfig;
33
+ platformConfig: AugustPlatformConfig;
34
+ platformLogging: options['logging'];
35
+ platformRefreshRate: options['refreshRate'];
36
+ platformPushRate: options['pushRate'];
37
+ platformUpdateRate: options['updateRate'];
38
+ registeringDevice: boolean;
39
+ debugMode: boolean;
40
+ version: string;
41
+ augustConfig?: August;
42
+ connectivity?: ConnectivityManager;
43
+ protected readonly lockMechanisms: Map<string, any>;
44
+ protected pollTimer?: NodeJS.Timeout;
45
+ protected normalizedCredentialsCache?: credentials;
46
+ logger: PluginLogger;
47
+ constructor(log: Logging, config: AugustPlatformConfig, api: API);
48
+ Lock(device: any): Promise<void>;
49
+ /**
50
+ * Tears down resources for a lock mechanism, including PubNub subscriptions and polling if present.
51
+ *
52
+ * Removes the lock mechanism from the internal map and calls tearDownPubNubSubscription if implemented.
53
+ * Used by both HAP and Matter platforms. Lock mechanisms must implement tearDownPubNubSubscription for proper cleanup.
54
+ *
55
+ * @param {string} lockId - The lock ID whose mechanism should be torn down.
56
+ * @returns {void}
57
+ */
58
+ protected tearDownLockMechanism(lockId: string): void;
59
+ /**
60
+ * Handles restoration of cached accessories from disk during Homebridge startup.
61
+ *
62
+ * Called by Homebridge for each accessory previously registered and persisted in the cache.
63
+ * Adds the accessory to the platform's accessories array for tracking and future management.
64
+ * Subclasses should override this method to set up event handlers and update characteristic values as needed.
65
+ *
66
+ * @param {PlatformAccessory} accessory - The accessory instance restored from cache.
67
+ * @returns {Promise<void>} Resolves when the accessory is processed and added to the cache.
68
+ */
69
+ configureAccessory(accessory: PlatformAccessory): Promise<void>;
70
+ /**
71
+ * Verifies that the plugin configuration contains all required credentials.
72
+ *
73
+ * Checks for the presence of credentials, August ID, and password. Throws descriptive errors
74
+ * if any required field is missing. Should be called during initialization to ensure the platform
75
+ * is properly configured before proceeding with authentication or device discovery.
76
+ *
77
+ * @returns {Promise<void>} Resolves if the configuration is valid.
78
+ * @throws {Error} If credentials, August ID, or password are missing.
79
+ */
80
+ verifyConfig(): Promise<void>;
81
+ /**
82
+ * Validates the August credentials and manages the Homebridge config state for authentication.
83
+ *
84
+ * - If the session is not validated and a validateCode is present, attempts to validate with the code,
85
+ * updates the config, and clears the validateCode on success.
86
+ * - If already validated or no validateCode is present, ensures installId is set and prompts the user
87
+ * to enter the verification code if needed.
88
+ * - Always updates the config file and clears the normalized credentials cache after changes.
89
+ * - Handles device discovery after successful validation.
90
+ *
91
+ * @returns {Promise<void>} Resolves when validation and config updates are complete.
92
+ * @throws {Error} If credentials are missing or validation fails unexpectedly.
93
+ */
94
+ validated(): Promise<void>;
95
+ /**
96
+ * Initializes and manages the August API credentials and connectivity manager.
97
+ *
98
+ * Ensures credentials are present, initializes the ConnectivityManager if needed,
99
+ * and keeps the public augustConfig field in sync with the manager's internal client.
100
+ * If already initialized, skips re-initialization. Handles automatic client rebuilds
101
+ * on authentication failures and network recovery.
102
+ *
103
+ * @returns {Promise<void>} Resolves when credentials and connectivity are initialized.
104
+ * @throws {Error} If credentials are missing.
105
+ */
106
+ augustCredentials(): Promise<void>;
107
+ /**
108
+ * Normalizes credentials for August API compatibility, handling country code variations.
109
+ *
110
+ * Maps regional country codes (e.g., CA, MX) to supported API endpoints (US) unless normalization is disabled in config.
111
+ * Logs normalization actions for debugging and API compatibility.
112
+ *
113
+ * @param {credentials} credentials - The credentials object to normalize.
114
+ * @returns {Promise<credentials>} Resolves with the normalized credentials object.
115
+ * @throws {Error} If credentials are null or undefined.
116
+ */
117
+ private normalizeCredentialsForApi;
118
+ /**
119
+ * Clears the cached normalized credentials.
120
+ *
121
+ * Should be called whenever credentials are updated or invalidated to ensure
122
+ * that subsequent API calls use fresh, normalized credentials.
123
+ * Logs the cache clear operation for debugging.
124
+ *
125
+ * @returns {void}
126
+ */
127
+ clearNormalizedCredentialsCache(): void;
128
+ /**
129
+ * Returns normalized credentials for use by device classes, with caching to avoid redundant normalization.
130
+ *
131
+ * If the credentials have not changed since the last call, returns the cached normalized credentials.
132
+ * Otherwise, normalizes the credentials, caches them, and returns the new value.
133
+ *
134
+ * @returns {Promise<credentials>} Resolves with the normalized credentials object for API use.
135
+ * @throws {Error} If credentials are missing or invalid.
136
+ */
137
+ getNormalizedCredentials(): Promise<credentials>;
138
+ /**
139
+ * Starts the platform-level polling cycle for device state updates.
140
+ *
141
+ * Iterates registered locks serially (not in parallel) and short-circuits on the first failure.
142
+ *
143
+ * **Why serial:**
144
+ * - One outstanding request at a time on a healthy network is cheap enough (most cycles complete in <1s for a handful of locks) and avoids racing the August API.
145
+ * - On a failing network, a parallel cycle would produce N timeouts ~simultaneously, which is exactly the log-spam pattern the ConnectivityManager exists to prevent. Serial means one timeout, classified once, and the rest of the cycle aborts.
146
+ *
147
+ * **Why short-circuit on first failure:**
148
+ * - If the first call fails with a network error, the manager has already entered 'degraded' state and scheduled a probe. The remaining N-1 calls would all hit the same dead network and produce identical errors. Aborting the cycle is the correct thing to do.
149
+ *
150
+ * **Why skip when offline:**
151
+ * - The manager's state machine is already managing recovery via scheduled probes. Polling on top of that just wastes API calls and risks rate limiting.
152
+ *
153
+ * Idempotent: If discovery re-runs (e.g. after re-auth), does not stack timers.
154
+ *
155
+ * @returns {void}
156
+ */
157
+ startPolling(): void;
158
+ /**
159
+ * Stops the platform polling cycle for device state updates.
160
+ *
161
+ * Clears the polling timer if active, halting periodic device refreshes.
162
+ * Typically called during plugin shutdown or when polling is no longer needed.
163
+ *
164
+ * @returns {void}
165
+ */
166
+ stopPolling(): void;
167
+ /**
168
+ * Loads and returns the plugin's configuration and the full Homebridge config from disk.
169
+ *
170
+ * Reads the Homebridge config file, finds this plugin's config section, and ensures credentials is an object.
171
+ * Throws if the platforms array or plugin config is missing.
172
+ *
173
+ * @returns {Promise<{ pluginConfig: any, currentConfig: any }>} Resolves with the plugin's config and the full config object.
174
+ * @throws {TypeError|Error} If the platforms array or plugin config is missing.
175
+ */
176
+ pluginConfig(): Promise<{
177
+ pluginConfig: any;
178
+ currentConfig: any;
179
+ }>;
180
+ /**
181
+ * Discovers and registers August/Yale lock devices for the platform.
182
+ *
183
+ * Fetches device details from the August API using normalized credentials, applies config-based filtering,
184
+ * unregisters excluded accessories, merges config overrides, and registers each device via the Lock method.
185
+ * Handles authentication errors and triggers re-authentication if needed.
186
+ *
187
+ * @returns {Promise<void>} Resolves when all devices have been discovered and registered.
188
+ * @throws {Error} If device discovery or authentication fails.
189
+ */
190
+ discoverDevices(): Promise<void>;
191
+ /**
192
+ * --- Additional shared methods for config, logging, etc. ---
193
+ */
194
+ /**
195
+ * Determines if a device should be registered based on its visibility and HomeKit enablement.
196
+ *
197
+ * This is a generic version; subclasses may override for protocol-specific logic.
198
+ * Sets the registeringDevice flag and logs the registration decision.
199
+ *
200
+ * @param {any} device - The device object to evaluate for registration.
201
+ * @returns {Promise<boolean>} Resolves to true if the device should be registered, false otherwise.
202
+ */
203
+ protected registerDevice(device: any): Promise<boolean>;
204
+ /**
205
+ * Unregisters a platform accessory from Homebridge and removes it from the cache.
206
+ *
207
+ * Calls the Homebridge API to unregister the accessory, tears down the lock mechanism,
208
+ * removes the accessory from the internal cache, and logs the removal.
209
+ *
210
+ * @param {PlatformAccessory} existingAccessory - The accessory to unregister.
211
+ * @param {any} device - The device object (used for lockId and logging).
212
+ * @returns {Promise<void>} Resolves when the accessory has been unregistered and removed from cache.
213
+ */
214
+ protected unregisterPlatformAccessories(existingAccessory: PlatformAccessory, device: any): Promise<void>;
215
+ /**
216
+ * Publishes an accessory as either an external accessory or a platform accessory based on device config.
217
+ *
218
+ * If the device config has `external` set, publishes the accessory as an external accessory and logs the mode.
219
+ * Otherwise, registers it as a platform accessory and logs the mode.
220
+ *
221
+ * @param {device & devicesConfig} device - The device configuration object.
222
+ * @param {PlatformAccessory} accessory - The accessory to publish or register.
223
+ * @returns {Promise<void>} Resolves when the accessory has been published or registered.
224
+ */
225
+ externalOrPlatform(device: device & devicesConfig, accessory: PlatformAccessory): Promise<void>;
226
+ /**
227
+ * Publishes an accessory as an external accessory to Homebridge.
228
+ *
229
+ * Calls the Homebridge API to publish the provided accessory as an external accessory.
230
+ * This is used for accessories that should be exposed independently from the main bridge.
231
+ *
232
+ * @param {PlatformAccessory} accessory - The accessory to publish externally.
233
+ * @returns {Promise<void>} Resolves when the accessory has been published.
234
+ */
235
+ externalAccessory(accessory: PlatformAccessory): Promise<void>;
236
+ /**
237
+ * Asynchronously determines and logs the platform logging mode based on config options and debug flags.
238
+ *
239
+ * Sets the platformLogging property to 'debug', 'standard', 'none', or 'debugMode' depending on config and CLI flags.
240
+ * Logs the selected logging mode for debugging purposes.
241
+ *
242
+ * @returns {Promise<void>} Resolves when the logging mode has been determined, set, and logged.
243
+ */
244
+ protected getPlatformLogSettings(): Promise<void>;
245
+ /**
246
+ * Asynchronously loads and logs platform polling, update, and push rate settings from the config options.
247
+ *
248
+ * Reads refreshRate, updateRate, and pushRate from the config options, assigns them to instance properties,
249
+ * and logs the values for debugging purposes.
250
+ *
251
+ * @returns {Promise<void>} Resolves when the rates have been loaded, assigned, and logged.
252
+ */
253
+ protected getPlatformRateSettings(): Promise<void>;
254
+ /**
255
+ * Asynchronously loads and logs platform configuration settings from the config options.
256
+ *
257
+ * Reads logging, refreshRate, updateRate, and pushRate from the config options,
258
+ * builds a platformConfig object, logs it if present, and assigns it to this.platformConfig.
259
+ *
260
+ * @returns {Promise<void>} Resolves when the config has been loaded, logged, and assigned.
261
+ */
262
+ protected getPlatformConfigSettings(): Promise<void>;
263
+ /**
264
+ * Asynchronously retrieves and logs the plugin version from package.json.
265
+ *
266
+ * Reads the version from the package.json file, logs it using logger.debug, and
267
+ * assigns it to the `version` property of the class instance.
268
+ *
269
+ * @returns {Promise<void>} Resolves when the version has been read, logged, and assigned.
270
+ */
271
+ protected getVersion(): Promise<void>;
272
+ /**
273
+ * Asynchronously validates and cleans a display name or characteristic value for HomeKit compatibility.
274
+ *
275
+ * If invalid characters are not allowed (default), this method:
276
+ * - Ensures the value contains only alphanumeric, space, and apostrophe characters.
277
+ * - Removes any invalid characters and trims invalid start/end characters.
278
+ * - Logs warnings and before/after values if modifications are made.
279
+ * If invalid characters are allowed by config, the value is returned unchanged.
280
+ *
281
+ * @param {string} displayName - The accessory's display name (for logging context).
282
+ * @param {string} name - The characteristic name (for logging context).
283
+ * @param {string} value - The value to validate and clean.
284
+ * @returns {Promise<string>} The cleaned (or original) value, suitable for HomeKit.
285
+ */
286
+ protected validateAndCleanDisplayName(displayName: string, name: string, value: string): Promise<string>;
287
+ }
288
+ //# sourceMappingURL=Platform.Base.d.ts.map