@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.
- package/.github/copilot-instructions.md +200 -0
- package/.github/npm-version-script-esm.js +97 -0
- package/CHANGELOG.md +44 -9
- package/dist/Platform.Base.d.ts +288 -0
- package/dist/Platform.Base.d.ts.map +1 -0
- package/dist/Platform.Base.js +797 -0
- package/dist/Platform.Base.js.map +1 -0
- package/dist/Platform.HAP.d.ts +27 -0
- package/dist/Platform.HAP.d.ts.map +1 -0
- package/dist/Platform.HAP.js +68 -0
- package/dist/Platform.HAP.js.map +1 -0
- package/dist/connectivity-manager.d.ts +3 -3
- package/dist/connectivity-manager.d.ts.map +1 -1
- package/dist/connectivity-manager.js +57 -14
- package/dist/connectivity-manager.js.map +1 -1
- package/dist/devices/device.d.ts +5 -16
- package/dist/devices/device.d.ts.map +1 -1
- package/dist/devices/device.js +18 -75
- package/dist/devices/device.js.map +1 -1
- package/dist/devices/lock.d.ts +3 -3
- package/dist/devices/lock.d.ts.map +1 -1
- package/dist/devices/lock.js +41 -41
- package/dist/devices/lock.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/package.json +10 -8
- package/dist/platform.matter.d.ts +18 -20
- package/dist/platform.matter.d.ts.map +1 -1
- package/dist/platform.matter.js +74 -80
- package/dist/platform.matter.js.map +1 -1
- package/docs/variables/default.html +1 -1
- package/package.json +10 -8
- package/test/device.test.ts +384 -0
- package/test/{platform.test.ts → platform.hap.test.ts} +23 -23
- package/test/platform.polling.test.ts +5 -5
- package/.copilot/instructions.md +0 -261
- package/.github/scripts/compute-version-override.cjs +0 -51
- package/.github/scripts/normalize-changelog-header.cjs +0 -86
- package/.github/scripts/npm-version-script-esm-auto.js +0 -201
- package/.github/scripts/resolve-version-bump-esm.js +0 -118
- package/dist/platform.d.ts +0 -146
- package/dist/platform.d.ts.map +0 -1
- package/dist/platform.js +0 -755
- package/dist/platform.js.map +0 -1
- package/test/connectivity-manager.test.ts +0 -590
- package/test/platform.matter.test.ts +0 -660
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import fs from 'node:fs'
|
|
4
|
-
import https from 'node:https'
|
|
5
|
-
import process from 'node:process'
|
|
6
|
-
|
|
7
|
-
const allowed = new Set(['major', 'minor', 'patch'])
|
|
8
|
-
|
|
9
|
-
function setOutput(name, value) {
|
|
10
|
-
if (process.env.GITHUB_OUTPUT) {
|
|
11
|
-
fs.appendFileSync(process.env.GITHUB_OUTPUT, `${name}=${value}\n`)
|
|
12
|
-
}
|
|
13
|
-
console.log(`${name}=${value}`)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function resolveFromLabels(labels) {
|
|
17
|
-
const majorLabels = new Set(['major', 'semver:major', 'release:major', 'breaking', 'breaking-change'])
|
|
18
|
-
const minorLabels = new Set(['minor', 'semver:minor', 'release:minor', 'feature'])
|
|
19
|
-
const patchLabels = new Set(['patch', 'semver:patch', 'release:patch', 'fix'])
|
|
20
|
-
|
|
21
|
-
if (labels.some(label => majorLabels.has(label))) return 'major'
|
|
22
|
-
if (labels.some(label => minorLabels.has(label))) return 'minor'
|
|
23
|
-
if (labels.some(label => patchLabels.has(label))) return 'patch'
|
|
24
|
-
return 'patch'
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function listPrsForCommit(owner, repo, sha, token) {
|
|
28
|
-
return new Promise((resolve, reject) => {
|
|
29
|
-
const path = `/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/commits/${sha}/pulls`
|
|
30
|
-
const req = https.request(
|
|
31
|
-
{
|
|
32
|
-
hostname: 'api.github.com',
|
|
33
|
-
method: 'GET',
|
|
34
|
-
path,
|
|
35
|
-
headers: {
|
|
36
|
-
Accept: 'application/vnd.github+json',
|
|
37
|
-
Authorization: `Bearer ${token}`,
|
|
38
|
-
'User-Agent': 'homebridge-resolve-version-bump',
|
|
39
|
-
'X-GitHub-Api-Version': '2022-11-28',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
(res) => {
|
|
43
|
-
let body = ''
|
|
44
|
-
res.setEncoding('utf8')
|
|
45
|
-
res.on('data', (chunk) => {
|
|
46
|
-
body += chunk
|
|
47
|
-
})
|
|
48
|
-
res.on('end', () => {
|
|
49
|
-
if (res.statusCode < 200 || res.statusCode >= 300) {
|
|
50
|
-
reject(new Error(`GitHub API request failed (${res.statusCode}): ${body}`))
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
const parsed = JSON.parse(body)
|
|
55
|
-
resolve(Array.isArray(parsed) ? parsed : [])
|
|
56
|
-
} catch (error) {
|
|
57
|
-
reject(new Error(`Failed to parse GitHub API response: ${error.message}`))
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
},
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
req.on('error', reject)
|
|
64
|
-
req.end()
|
|
65
|
-
})
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async function main() {
|
|
69
|
-
const manualInput = (process.argv[2] || '').trim().toLowerCase()
|
|
70
|
-
if (manualInput) {
|
|
71
|
-
if (!allowed.has(manualInput)) {
|
|
72
|
-
console.error(`Invalid version bump '${manualInput}'. Use major, minor, or patch.`)
|
|
73
|
-
process.exit(1)
|
|
74
|
-
}
|
|
75
|
-
console.error(`Using manual version bump input: ${manualInput}`)
|
|
76
|
-
setOutput('version_bump', manualInput)
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const repository = process.env.GITHUB_REPOSITORY || ''
|
|
81
|
-
const sha = process.env.GITHUB_SHA || ''
|
|
82
|
-
const token = process.env.GITHUB_TOKEN || ''
|
|
83
|
-
|
|
84
|
-
if (!repository || !sha || !token || !repository.includes('/')) {
|
|
85
|
-
console.error('Missing GITHUB_REPOSITORY, GITHUB_SHA, or GITHUB_TOKEN. Defaulting to patch.')
|
|
86
|
-
setOutput('version_bump', 'patch')
|
|
87
|
-
return
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const [owner, repo] = repository.split('/')
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
const prs = await listPrsForCommit(owner, repo, sha, token)
|
|
94
|
-
const pr = prs.find((candidate) => candidate.merged_at) || prs[0]
|
|
95
|
-
|
|
96
|
-
if (!pr) {
|
|
97
|
-
console.error('No PR associated with commit; defaulting to patch.')
|
|
98
|
-
setOutput('version_bump', 'patch')
|
|
99
|
-
return
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const labels = (pr.labels || [])
|
|
103
|
-
.map((label) => (typeof label === 'string' ? label : label.name || ''))
|
|
104
|
-
.map((label) => label.toLowerCase())
|
|
105
|
-
|
|
106
|
-
const bump = resolveFromLabels(labels)
|
|
107
|
-
console.error(`Resolved bump '${bump}' from PR #${pr.number} labels: ${labels.join(', ') || '(none)'}`)
|
|
108
|
-
setOutput('version_bump', bump)
|
|
109
|
-
} catch (error) {
|
|
110
|
-
console.error(`Failed to inspect PR labels, defaulting to patch: ${error.message}`)
|
|
111
|
-
setOutput('version_bump', 'patch')
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
main().catch((error) => {
|
|
116
|
-
console.error(error)
|
|
117
|
-
process.exit(1)
|
|
118
|
-
})
|
package/dist/platform.d.ts
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import type { API, DynamicPlatformPlugin, Logging, PlatformAccessory } from 'homebridge';
|
|
2
|
-
import type { AugustPlatformConfig, credentials, device, devicesConfig, options } from './settings.js';
|
|
3
|
-
import August from 'august-yale';
|
|
4
|
-
import { ConnectivityManager } from './connectivity-manager.js';
|
|
5
|
-
/**
|
|
6
|
-
* HomebridgePlatform
|
|
7
|
-
* This class is the main constructor for your plugin, this is where you should
|
|
8
|
-
* parse the user config and discover/register accessories with Homebridge.
|
|
9
|
-
*/
|
|
10
|
-
export declare class AugustPlatform implements DynamicPlatformPlugin {
|
|
11
|
-
accessories: PlatformAccessory[];
|
|
12
|
-
readonly api: API;
|
|
13
|
-
readonly log: Logging;
|
|
14
|
-
config: AugustPlatformConfig;
|
|
15
|
-
platformConfig: AugustPlatformConfig;
|
|
16
|
-
platformLogging: options['logging'];
|
|
17
|
-
platformRefreshRate: options['refreshRate'];
|
|
18
|
-
platformPushRate: options['pushRate'];
|
|
19
|
-
platformUpdateRate: options['updateRate'];
|
|
20
|
-
registeringDevice: boolean;
|
|
21
|
-
debugMode: boolean;
|
|
22
|
-
version: string;
|
|
23
|
-
augustConfig?: August;
|
|
24
|
-
connectivity?: ConnectivityManager;
|
|
25
|
-
private readonly lockMechanisms;
|
|
26
|
-
private pollTimer?;
|
|
27
|
-
private normalizedCredentialsCache?;
|
|
28
|
-
constructor(log: Logging, config: AugustPlatformConfig, api: API);
|
|
29
|
-
/**
|
|
30
|
-
* This function is invoked when homebridge restores cached accessories from disk at startup.
|
|
31
|
-
* It should be used to setup event handlers for characteristics and update respective values.
|
|
32
|
-
*/
|
|
33
|
-
configureAccessory(accessory: PlatformAccessory): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Verify the config passed to the plugin is valid
|
|
36
|
-
*/
|
|
37
|
-
verifyConfig(): Promise<void>;
|
|
38
|
-
/**
|
|
39
|
-
* This method looks to see if session is already Validate, if not then sends a validateCode and saves the installId.
|
|
40
|
-
* After validateCode is saved to the config user must restart homebridge
|
|
41
|
-
* this process then looks to see if session is already validated and if the validateCode in config;
|
|
42
|
-
* if isValidated is false then it will validate iwth the validateCode and save isValidated as true in the config.json file
|
|
43
|
-
* will also make the validateCode undefined
|
|
44
|
-
*/
|
|
45
|
-
validated(): Promise<void>;
|
|
46
|
-
augustCredentials(): Promise<void>;
|
|
47
|
-
/**
|
|
48
|
-
* Normalize credentials for August API compatibility
|
|
49
|
-
* Handle country code variations that may cause 403 errors
|
|
50
|
-
* Maps regional country codes to supported API endpoints
|
|
51
|
-
*/
|
|
52
|
-
private normalizeCredentialsForApi;
|
|
53
|
-
/**
|
|
54
|
-
* Clear the normalized credentials cache
|
|
55
|
-
* Should be called when credentials are updated
|
|
56
|
-
*/
|
|
57
|
-
clearNormalizedCredentialsCache(): void;
|
|
58
|
-
/**
|
|
59
|
-
* Public method to get normalized credentials for use by device classes
|
|
60
|
-
* Uses caching to avoid repeated normalization of the same credentials
|
|
61
|
-
*/
|
|
62
|
-
getNormalizedCredentials(): Promise<credentials>;
|
|
63
|
-
/**
|
|
64
|
-
* Start the platform-level poll cycle. Iterates registered locks
|
|
65
|
-
* SERIALLY (not in parallel) and short-circuits on the first failure.
|
|
66
|
-
*
|
|
67
|
-
* Why serial:
|
|
68
|
-
* - One outstanding request at a time on a healthy network is cheap
|
|
69
|
-
* enough (most cycles complete in <1s for a handful of locks) and
|
|
70
|
-
* avoids racing the August API.
|
|
71
|
-
* - On a failing network, a parallel cycle would produce N timeouts
|
|
72
|
-
* ~simultaneously, which is exactly the log-spam pattern the
|
|
73
|
-
* ConnectivityManager exists to prevent. Serial means one timeout,
|
|
74
|
-
* classified once, and the rest of the cycle aborts.
|
|
75
|
-
*
|
|
76
|
-
* Why short-circuit on first failure:
|
|
77
|
-
* - If the first call fails with a network error, the manager has
|
|
78
|
-
* already entered 'degraded' state and scheduled a probe. The
|
|
79
|
-
* remaining N-1 calls would all hit the same dead network and
|
|
80
|
-
* produce identical errors. Aborting the cycle is the correct
|
|
81
|
-
* thing to do.
|
|
82
|
-
*
|
|
83
|
-
* Why skip when offline:
|
|
84
|
-
* - The manager's state machine is already managing recovery via
|
|
85
|
-
* scheduled probes. Polling on top of that just wastes API calls
|
|
86
|
-
* and risks rate limiting.
|
|
87
|
-
*/
|
|
88
|
-
startPolling(): void;
|
|
89
|
-
/** Stop the platform poll cycle. Called from shutdown paths. */
|
|
90
|
-
stopPolling(): void;
|
|
91
|
-
pluginConfig(): Promise<{
|
|
92
|
-
pluginConfig: any;
|
|
93
|
-
currentConfig: any;
|
|
94
|
-
}>;
|
|
95
|
-
/**
|
|
96
|
-
* This method is used to discover the your location and devices.
|
|
97
|
-
*/
|
|
98
|
-
discoverDevices(): Promise<void>;
|
|
99
|
-
protected Lock(device: device & devicesConfig): Promise<void>;
|
|
100
|
-
registerDevice(device: device & devicesConfig): Promise<boolean>;
|
|
101
|
-
externalOrPlatform(device: device & devicesConfig, accessory: PlatformAccessory): Promise<void>;
|
|
102
|
-
externalAccessory(accessory: PlatformAccessory): Promise<void>;
|
|
103
|
-
unregisterPlatformAccessories(existingAccessory: PlatformAccessory, device: device & devicesConfig): Promise<void>;
|
|
104
|
-
/**
|
|
105
|
-
* Tear down the LockMechanism for a given lockId, releasing its PubNub
|
|
106
|
-
* subscription. Called when an accessory is unregistered (either via
|
|
107
|
-
* explicit removal or excludeLockIds config).
|
|
108
|
-
*/
|
|
109
|
-
private tearDownLockMechanism;
|
|
110
|
-
getPlatformLogSettings(): Promise<void>;
|
|
111
|
-
getPlatformRateSettings(): Promise<void>;
|
|
112
|
-
getPlatformConfigSettings(): Promise<void>;
|
|
113
|
-
/**
|
|
114
|
-
* Asynchronously retrieves the version of the plugin from the package.json file.
|
|
115
|
-
*
|
|
116
|
-
* This method reads the package.json file located in the parent directory,
|
|
117
|
-
* parses its content to extract the version, and logs the version using the debug logger.
|
|
118
|
-
* The extracted version is then assigned to the `version` property of the class.
|
|
119
|
-
*
|
|
120
|
-
* @returns {Promise<void>} A promise that resolves when the version has been retrieved and logged.
|
|
121
|
-
*/
|
|
122
|
-
getVersion(): Promise<void>;
|
|
123
|
-
/**
|
|
124
|
-
* Validate and clean a string value for a Name Characteristic.
|
|
125
|
-
* @param displayName - The display name of the accessory.
|
|
126
|
-
* @param name - The name of the characteristic.
|
|
127
|
-
* @param value - The value to be validated and cleaned.
|
|
128
|
-
* @returns The cleaned string value.
|
|
129
|
-
*/
|
|
130
|
-
validateAndCleanDisplayName(displayName: string, name: string, value: string): Promise<string>;
|
|
131
|
-
/**
|
|
132
|
-
* If device level logging is turned on, log to log.warn
|
|
133
|
-
* Otherwise send debug logs to log.debug
|
|
134
|
-
*/
|
|
135
|
-
infoLog(...log: any[]): Promise<void>;
|
|
136
|
-
successLog(...log: any[]): Promise<void>;
|
|
137
|
-
debugSuccessLog(...log: any[]): Promise<void>;
|
|
138
|
-
warnLog(...log: any[]): Promise<void>;
|
|
139
|
-
debugWarnLog(...log: any[]): Promise<void>;
|
|
140
|
-
errorLog(...log: any[]): Promise<void>;
|
|
141
|
-
debugErrorLog(...log: any[]): Promise<void>;
|
|
142
|
-
debugLog(...log: any[]): Promise<void>;
|
|
143
|
-
loggingIsDebug(): Promise<boolean>;
|
|
144
|
-
enablingPlatformLogging(): Promise<boolean>;
|
|
145
|
-
}
|
|
146
|
-
//# sourceMappingURL=platform.d.ts.map
|
package/dist/platform.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,qBAAqB,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAExF,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAKtG,OAAO,MAAM,MAAM,aAAa,CAAA;AAEhC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAI/D;;;;GAIG;AACH,qBAAa,cAAe,YAAW,qBAAqB;IACnD,WAAW,EAAE,iBAAiB,EAAE,CAAA;IACvC,SAAgB,GAAG,EAAE,GAAG,CAAA;IACxB,SAAgB,GAAG,EAAE,OAAO,CAAA;IACrB,MAAM,EAAG,oBAAoB,CAAA;IAEpC,cAAc,EAAG,oBAAoB,CAAA;IACrC,eAAe,EAAG,OAAO,CAAC,SAAS,CAAC,CAAA;IACpC,mBAAmB,EAAG,OAAO,CAAC,aAAa,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