@switchbot/homebridge-switchbot 5.0.0-beta.111 → 5.0.0-beta.113
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/MIGRATION.md +10 -0
- package/README.md +43 -0
- package/TODO.md +263 -0
- package/config.schema.json +27 -10
- package/dist/device-types.d.ts.map +1 -1
- package/dist/device-types.js +93 -63
- package/dist/device-types.js.map +1 -1
- package/dist/deviceFactory.d.ts.map +1 -1
- package/dist/deviceFactory.js +55 -33
- package/dist/deviceFactory.js.map +1 -1
- package/dist/devices/genericDevice.d.ts +12 -1
- package/dist/devices/genericDevice.d.ts.map +1 -1
- package/dist/devices/genericDevice.js +121 -1
- package/dist/devices/genericDevice.js.map +1 -1
- package/dist/errors.d.ts +5 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +51 -0
- package/dist/errors.js.map +1 -0
- package/dist/homebridge-ui/endpoints/devices.d.ts.map +1 -1
- package/dist/homebridge-ui/endpoints/devices.js +80 -1
- package/dist/homebridge-ui/endpoints/devices.js.map +1 -1
- package/dist/homebridge-ui/endpoints/discovery.d.ts.map +1 -1
- package/dist/homebridge-ui/endpoints/discovery.js +73 -41
- package/dist/homebridge-ui/endpoints/discovery.js.map +1 -1
- package/dist/homebridge-ui/public/css/styles.css +209 -16
- package/dist/homebridge-ui/public/index.html +87 -56
- package/dist/homebridge-ui/public/js/api.d.ts +24 -1
- package/dist/homebridge-ui/public/js/api.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/api.js +33 -2
- package/dist/homebridge-ui/public/js/api.js.map +1 -1
- package/dist/homebridge-ui/public/js/api.ts +52 -3
- package/dist/homebridge-ui/public/js/app.js +1604 -143
- package/dist/homebridge-ui/public/js/app.js.map +3 -3
- package/dist/homebridge-ui/public/js/app.ts +2 -1
- package/dist/homebridge-ui/public/js/devices.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/devices.js +2 -0
- package/dist/homebridge-ui/public/js/devices.js.map +1 -1
- package/dist/homebridge-ui/public/js/devices.ts +13 -1
- package/dist/homebridge-ui/public/js/discovery.d.ts +1 -0
- package/dist/homebridge-ui/public/js/discovery.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/discovery.js +1244 -124
- package/dist/homebridge-ui/public/js/discovery.js.map +1 -1
- package/dist/homebridge-ui/public/js/discovery.ts +1344 -142
- package/dist/homebridge-ui/public/js/modals.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/modals.js +42 -0
- package/dist/homebridge-ui/public/js/modals.js.map +1 -1
- package/dist/homebridge-ui/public/js/modals.ts +50 -1
- package/dist/homebridge-ui/public/js/render.d.ts +3 -0
- package/dist/homebridge-ui/public/js/render.d.ts.map +1 -1
- package/dist/homebridge-ui/public/js/render.js +389 -36
- package/dist/homebridge-ui/public/js/render.js.map +1 -1
- package/dist/homebridge-ui/public/js/render.ts +421 -38
- package/dist/platform.d.ts +1 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +3 -4
- package/dist/platform.js.map +1 -1
- package/dist/switchbotClient.d.ts.map +1 -1
- package/dist/switchbotClient.js +51 -5
- package/dist/switchbotClient.js.map +1 -1
- package/docs/assets/highlight.css +9 -2
- package/docs/index.html +28 -2
- package/docs/variables/default.html +1 -1
- package/package.json +9 -8
- package/src/device-types.ts +95 -64
- package/src/deviceFactory.ts +55 -33
- package/src/devices/genericDevice.ts +113 -1
- package/src/errors.ts +43 -0
- package/src/homebridge-ui/endpoints/devices.ts +82 -1
- package/src/homebridge-ui/endpoints/discovery.ts +78 -44
- package/src/homebridge-ui/public/css/styles.css +209 -16
- package/src/homebridge-ui/public/index.html +87 -56
- package/src/homebridge-ui/public/js/api.ts +52 -3
- package/src/homebridge-ui/public/js/app.ts +2 -1
- package/src/homebridge-ui/public/js/devices.ts +13 -1
- package/src/homebridge-ui/public/js/discovery.ts +1344 -142
- package/src/homebridge-ui/public/js/modals.ts +50 -1
- package/src/homebridge-ui/public/js/render.ts +421 -38
- package/src/platform.ts +3 -4
- package/src/switchbotClient.ts +44 -9
- package/test/e2e/run-e2e.spec.ts +12 -10
- package/test/helpers/matter-harness.ts +2 -2
- package/test/matter-integration.spec.ts +21 -0
- package/todo/COMPLETED.md +313 -0
- package/todo/TODO.md +80 -66
- package/switchbot-homebridge-switchbot-5.0.0.tgz +0 -0
|
@@ -100,9 +100,18 @@ export async function fetchDevices(): Promise<any[]> {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
export
|
|
103
|
+
export type DiscoverRequestOptions = {
|
|
104
|
+
bleEnabled?: boolean
|
|
105
|
+
bleScanDurationSeconds?: number
|
|
106
|
+
bleTimeoutSeconds?: number
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export async function discoverDevices(
|
|
110
|
+
mode: 'all' | 'ble' | 'openapi' = 'all',
|
|
111
|
+
options?: DiscoverRequestOptions,
|
|
112
|
+
): Promise<any[]> {
|
|
104
113
|
try {
|
|
105
|
-
const resp = await homebridge.request('/discover', {})
|
|
114
|
+
const resp = await homebridge.request('/discover', { mode, ...options })
|
|
106
115
|
uiLog.info('Discover response:', resp)
|
|
107
116
|
|
|
108
117
|
if (!resp || resp.success === false) {
|
|
@@ -115,17 +124,57 @@ export async function discoverDevices(): Promise<any[]> {
|
|
|
115
124
|
}
|
|
116
125
|
}
|
|
117
126
|
|
|
127
|
+
export async function fetchBluetoothStatus(): Promise<{ available: boolean, message: string }> {
|
|
128
|
+
try {
|
|
129
|
+
const resp = await homebridge.request('/ble-status', {})
|
|
130
|
+
if (!resp || resp.success === false) {
|
|
131
|
+
return { available: false, message: 'Bluetooth status unavailable' }
|
|
132
|
+
}
|
|
133
|
+
return resp.data || { available: false, message: 'Bluetooth status unavailable' }
|
|
134
|
+
} catch (_e) {
|
|
135
|
+
return { available: false, message: 'Bluetooth status unavailable' }
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export async function testDeviceConnection(payload: {
|
|
140
|
+
deviceId: string
|
|
141
|
+
connectionType?: string
|
|
142
|
+
address?: string
|
|
143
|
+
}): Promise<{
|
|
144
|
+
success: boolean
|
|
145
|
+
deviceId: string
|
|
146
|
+
method: string
|
|
147
|
+
latencyMs: number
|
|
148
|
+
message: string
|
|
149
|
+
state?: Record<string, any>
|
|
150
|
+
}> {
|
|
151
|
+
const resp = await homebridge.request('/test-connection', payload)
|
|
152
|
+
if (!resp || resp.success === false) {
|
|
153
|
+
throw new Error(resp?.data?.message || 'Connection test failed')
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return resp.data || {
|
|
157
|
+
success: false,
|
|
158
|
+
deviceId: payload.deviceId,
|
|
159
|
+
method: 'Auto',
|
|
160
|
+
latencyMs: 0,
|
|
161
|
+
message: 'Connection test failed',
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
118
165
|
export async function addDevice(
|
|
119
166
|
deviceId: string,
|
|
120
167
|
name: string,
|
|
121
168
|
type: string,
|
|
122
|
-
options?: { address?: string, model?: string, rssi?: number },
|
|
169
|
+
options?: { address?: string, model?: string, rssi?: number, encryptionKey?: string, keyId?: string },
|
|
123
170
|
): Promise<any> {
|
|
124
171
|
try {
|
|
125
172
|
const payload: any = { deviceId, name, type }
|
|
126
173
|
if (options?.address) { payload.address = options.address }
|
|
127
174
|
if (options?.model) { payload.model = options.model }
|
|
128
175
|
if (options?.rssi !== undefined && options?.rssi !== null && options?.rssi !== 0) { payload.rssi = options.rssi }
|
|
176
|
+
if (options?.encryptionKey) { payload.encryptionKey = options.encryptionKey }
|
|
177
|
+
if (options?.keyId) { payload.keyId = options.keyId }
|
|
129
178
|
|
|
130
179
|
uiLog.info('Adding device to config:', payload)
|
|
131
180
|
const resp = await homebridge.request('/add-device', payload)
|