homebridge 2.0.0-alpha.40 → 2.0.0-alpha.41
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/config-sample.json +1 -12
- package/dist/api.d.ts +4 -20
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +1 -27
- package/dist/api.js.map +1 -1
- package/dist/bridgeService.d.ts +12 -15
- package/dist/bridgeService.d.ts.map +1 -1
- package/dist/bridgeService.js +7 -7
- package/dist/bridgeService.js.map +1 -1
- package/dist/childBridgeService.d.ts +1 -0
- package/dist/childBridgeService.d.ts.map +1 -1
- package/dist/childBridgeService.js +1 -0
- package/dist/childBridgeService.js.map +1 -1
- package/dist/childMatterBridgeFork.d.ts +108 -0
- package/dist/childMatterBridgeFork.d.ts.map +1 -0
- package/dist/childMatterBridgeFork.js +330 -0
- package/dist/childMatterBridgeFork.js.map +1 -0
- package/dist/childMatterBridgeService.d.ts +166 -0
- package/dist/childMatterBridgeService.d.ts.map +1 -0
- package/dist/childMatterBridgeService.js +623 -0
- package/dist/childMatterBridgeService.js.map +1 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/ipcService.d.ts +19 -3
- package/dist/ipcService.d.ts.map +1 -1
- package/dist/ipcService.js +13 -0
- package/dist/ipcService.js.map +1 -1
- package/dist/matter/index.d.ts +13 -0
- package/dist/matter/index.d.ts.map +1 -0
- package/dist/matter/index.js +12 -0
- package/dist/matter/index.js.map +1 -0
- package/dist/matter/matterBridge.d.ts +64 -0
- package/dist/matter/matterBridge.d.ts.map +1 -0
- package/dist/matter/matterBridge.js +154 -0
- package/dist/matter/matterBridge.js.map +1 -0
- package/dist/matter/matterConfigValidator.d.ts +27 -0
- package/dist/matter/matterConfigValidator.d.ts.map +1 -0
- package/dist/matter/matterConfigValidator.js +162 -0
- package/dist/matter/matterConfigValidator.js.map +1 -0
- package/dist/matter/matterDevice.d.ts +107 -0
- package/dist/matter/matterDevice.d.ts.map +1 -0
- package/dist/matter/matterDevice.js +913 -0
- package/dist/matter/matterDevice.js.map +1 -0
- package/dist/matter/matterDiagnostics.d.ts +121 -0
- package/dist/matter/matterDiagnostics.d.ts.map +1 -0
- package/dist/matter/matterDiagnostics.js +323 -0
- package/dist/matter/matterDiagnostics.js.map +1 -0
- package/dist/matter/matterErrorHandler.d.ts +113 -0
- package/dist/matter/matterErrorHandler.d.ts.map +1 -0
- package/dist/matter/matterErrorHandler.js +482 -0
- package/dist/matter/matterErrorHandler.js.map +1 -0
- package/dist/matter/matterNetworkMonitor.d.ts +65 -0
- package/dist/matter/matterNetworkMonitor.d.ts.map +1 -0
- package/dist/matter/matterNetworkMonitor.js +227 -0
- package/dist/matter/matterNetworkMonitor.js.map +1 -0
- package/dist/matter/matterServer.d.ts +110 -0
- package/dist/matter/matterServer.d.ts.map +1 -0
- package/dist/matter/matterServer.js +584 -0
- package/dist/matter/matterServer.js.map +1 -0
- package/dist/matter/matterSharedTypes.d.ts +167 -0
- package/dist/matter/matterSharedTypes.d.ts.map +1 -0
- package/dist/matter/matterSharedTypes.js +55 -0
- package/dist/matter/matterSharedTypes.js.map +1 -0
- package/dist/{matterTypes.d.ts → matter/matterTypes.d.ts} +15 -0
- package/dist/matter/matterTypes.d.ts.map +1 -0
- package/dist/{matterTypes.js → matter/matterTypes.js} +4 -4
- package/dist/matter/matterTypes.js.map +1 -0
- package/dist/matter/portAllocator.d.ts +85 -0
- package/dist/matter/portAllocator.d.ts.map +1 -0
- package/dist/matter/portAllocator.js +296 -0
- package/dist/matter/portAllocator.js.map +1 -0
- package/dist/server.d.ts +9 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +363 -31
- package/dist/server.js.map +1 -1
- package/package.json +10 -10
- package/dist/matterConfigValidator.d.ts +0 -34
- package/dist/matterConfigValidator.d.ts.map +0 -1
- package/dist/matterConfigValidator.js +0 -249
- package/dist/matterConfigValidator.js.map +0 -1
- package/dist/matterService.d.ts +0 -168
- package/dist/matterService.d.ts.map +0 -1
- package/dist/matterService.js +0 -677
- package/dist/matterService.js.map +0 -1
- package/dist/matterTypes.d.ts.map +0 -1
- package/dist/matterTypes.js.map +0 -1
- package/dist/util/matter-cli.d.ts +0 -3
- package/dist/util/matter-cli.d.ts.map +0 -1
- package/dist/util/matter-cli.js +0 -211
- package/dist/util/matter-cli.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"portAllocator.js","sourceRoot":"","sources":["../../src/matter/portAllocator.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;AAEvC;;GAEG;AACH,MAAM,KAAK;IACD,KAAK,GAAsB,EAAE,CAAA;IAC7B,MAAM,GAAG,KAAK,CAAA;IACL,cAAc,GAAG,GAAG,CAAA,CAAC,2BAA2B;IAEjE;;OAEG;IACH,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAA;YAClB,OAAM;QACR,CAAC;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,+CAA+C,IAAI,CAAC,cAAc,GAAG,CAAC,CAAA;QACxF,CAAC;QAED,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACnC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC1B,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,OAAO;QACL,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAA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AAC,SAAS,GAAG,MAAM,EAAE,CAAC;gBAC7C,MAAM,GAAG,UAAU,CAAC,SAAS,CAAA;YAC/B,CAAC;QACH,CAAC;QAED,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI;YACxC,WAAW;YACX,QAAQ;YACR,gBAAgB,EAAE,MAAM;YACxB,gBAAgB,EAAE,MAAM;SACzB,CAAA;IACH,CAAC;CACF;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC,WAAW,EAAE,CAAA"}
|
package/dist/server.d.ts
CHANGED
|
@@ -28,11 +28,12 @@ export declare class Server {
|
|
|
28
28
|
private readonly api;
|
|
29
29
|
private readonly pluginManager;
|
|
30
30
|
private readonly bridgeService;
|
|
31
|
-
private readonly matterService;
|
|
32
31
|
private readonly ipcService;
|
|
33
32
|
private readonly externalPortService;
|
|
34
33
|
private readonly config;
|
|
35
34
|
private readonly childBridges;
|
|
35
|
+
private readonly childMatterBridges;
|
|
36
|
+
private readonly platformConfigs;
|
|
36
37
|
private serverStatus;
|
|
37
38
|
constructor(options?: HomebridgeOptions);
|
|
38
39
|
/**
|
|
@@ -41,10 +42,15 @@ export declare class Server {
|
|
|
41
42
|
*/
|
|
42
43
|
private setServerStatus;
|
|
43
44
|
start(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* Get the status of all Matter bridges (child bridges only)
|
|
47
|
+
*/
|
|
48
|
+
getMatterBridgesStatus(): any[];
|
|
44
49
|
teardown(): void;
|
|
45
50
|
private publishBridge;
|
|
46
|
-
private
|
|
47
|
-
private
|
|
51
|
+
private handlePublishExternalAccessories;
|
|
52
|
+
private handleRegisterPlatformAccessories;
|
|
53
|
+
private handleUnregisterPlatformAccessories;
|
|
48
54
|
private static loadConfig;
|
|
49
55
|
private loadAccessories;
|
|
50
56
|
private loadPlatforms;
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.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AsB,IAAI,GAAG,EAAE;IAI/B,QAAQ,IAAI,IAAI;IAavB,OAAO,CAAC,aAAa;IAQrB,OAAO,CAAC,gCAAgC;IAmHxC,OAAO,CAAC,iCAAiC;IAyBzC,OAAO,CAAC,mCAAmC;IAyB3C,OAAO,CAAC,MAAM,CAAC,UAAU;IAoFzB,OAAO,CAAC,eAAe;IAsJvB,OAAO,CAAC,aAAa;IAoJrB;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAiCjC;;OAEG;IACH,OAAO,CAAC,0BAA0B;IA4IlC,OAAO,CAAC,cAAc;CAqBvB"}
|
package/dist/server.js
CHANGED
|
@@ -5,10 +5,11 @@ import qrcode from 'qrcode-terminal';
|
|
|
5
5
|
import { HomebridgeAPI } from './api.js';
|
|
6
6
|
import { BridgeService } from './bridgeService.js';
|
|
7
7
|
import { ChildBridgeService } from './childBridgeService.js';
|
|
8
|
+
import { ChildMatterBridgeService } from './childMatterBridgeService.js';
|
|
8
9
|
import { ExternalPortService } from './externalPortService.js';
|
|
9
10
|
import { IpcService } from './ipcService.js';
|
|
10
11
|
import { Logger } from './logger.js';
|
|
11
|
-
import {
|
|
12
|
+
import { MatterConfigValidator } from './matter/matterConfigValidator.js';
|
|
12
13
|
import { PluginManager } from './pluginManager.js';
|
|
13
14
|
import { User } from './user.js';
|
|
14
15
|
import { validMacAddress } from './util/mac.js';
|
|
@@ -34,12 +35,14 @@ export class Server {
|
|
|
34
35
|
api;
|
|
35
36
|
pluginManager;
|
|
36
37
|
bridgeService;
|
|
37
|
-
matterService;
|
|
38
38
|
ipcService;
|
|
39
39
|
externalPortService;
|
|
40
40
|
config;
|
|
41
41
|
// used to keep track of child bridges
|
|
42
42
|
childBridges = new Map();
|
|
43
|
+
childMatterBridges = new Map();
|
|
44
|
+
// Track platform configurations for routing accessories
|
|
45
|
+
platformConfigs = new Map();
|
|
43
46
|
// current server status
|
|
44
47
|
serverStatus = "pending" /* ServerStatus.PENDING */;
|
|
45
48
|
constructor(options = {}) {
|
|
@@ -67,11 +70,12 @@ export class Server {
|
|
|
67
70
|
// shallow copy the homebridge options to the bridge options object
|
|
68
71
|
Object.assign(bridgeConfig, this.options);
|
|
69
72
|
this.bridgeService = new BridgeService(this.api, this.pluginManager, this.externalPortService, bridgeConfig, this.config.bridge, this.config);
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this.api.on("
|
|
74
|
-
|
|
73
|
+
// Matter is handled via _matter configuration, not API events
|
|
74
|
+
// Intercept platform accessory registration to route to Matter bridges if needed
|
|
75
|
+
this.api.on("registerPlatformAccessories" /* InternalAPIEvent.REGISTER_PLATFORM_ACCESSORIES */, this.handleRegisterPlatformAccessories.bind(this));
|
|
76
|
+
this.api.on("unregisterPlatformAccessories" /* InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES */, this.handleUnregisterPlatformAccessories.bind(this));
|
|
77
|
+
// Handle external accessories (cameras, etc.) for Matter
|
|
78
|
+
this.api.on("publishExternalAccessories" /* InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES */, this.handlePublishExternalAccessories.bind(this));
|
|
75
79
|
// watch bridge events to check when server is online
|
|
76
80
|
this.bridgeService.bridge.on("advertised" /* AccessoryEventTypes.ADVERTISED */, () => {
|
|
77
81
|
this.setServerStatus("ok" /* ServerStatus.OK */);
|
|
@@ -91,19 +95,37 @@ export class Server {
|
|
|
91
95
|
*/
|
|
92
96
|
setServerStatus(status) {
|
|
93
97
|
this.serverStatus = status;
|
|
98
|
+
// Collect child Matter bridge statuses
|
|
99
|
+
const childMatterBridgeStatuses = Array.from(this.childMatterBridges.values()).map(bridge => bridge.getMetadata());
|
|
100
|
+
// Get Matter bridges status (child bridges only)
|
|
101
|
+
const matterStatus = childMatterBridgeStatuses.length > 0
|
|
102
|
+
? {
|
|
103
|
+
children: childMatterBridgeStatuses,
|
|
104
|
+
}
|
|
105
|
+
: undefined;
|
|
94
106
|
this.ipcService.sendMessage("serverStatusUpdate" /* IpcOutgoingEvent.SERVER_STATUS_UPDATE */, {
|
|
107
|
+
type: 'hap', // Main bridge is HAP
|
|
95
108
|
status: this.serverStatus,
|
|
96
109
|
paired: this.bridgeService?.bridge?._accessoryInfo?.paired() ?? null,
|
|
97
110
|
setupUri: this.bridgeService?.bridge?.setupURI() ?? null,
|
|
98
111
|
name: this.bridgeService?.bridge?.displayName || this.config.bridge.name,
|
|
99
112
|
username: this.config.bridge.username,
|
|
100
113
|
pin: this.config.bridge.pin,
|
|
114
|
+
matterStatus,
|
|
101
115
|
});
|
|
102
116
|
}
|
|
103
117
|
async start() {
|
|
104
118
|
if (this.config.bridge.disableIpc !== true) {
|
|
105
119
|
this.initializeIpcEventHandlers();
|
|
106
120
|
}
|
|
121
|
+
// Track existing Matter bridges before loading new configuration
|
|
122
|
+
const existingMatterBridgeIds = new Set(this.childMatterBridges.keys());
|
|
123
|
+
// Validate child Matter configurations
|
|
124
|
+
const matterValidation = MatterConfigValidator.validateAllChildMatterConfigs(this.config.platforms, this.config.accessories);
|
|
125
|
+
if (!matterValidation.isValid) {
|
|
126
|
+
log.error('Child Matter configuration validation failed. Please fix the errors above.');
|
|
127
|
+
// Continue anyway but child Matter bridges may not work properly
|
|
128
|
+
}
|
|
107
129
|
const promises = [];
|
|
108
130
|
// load the cached accessories
|
|
109
131
|
await this.bridgeService.loadCachedPlatformAccessoriesFromDisk();
|
|
@@ -115,10 +137,52 @@ export class Server {
|
|
|
115
137
|
if (this.config.accessories.length > 0) {
|
|
116
138
|
this.loadAccessories();
|
|
117
139
|
}
|
|
118
|
-
//
|
|
140
|
+
// Track which Matter bridges are still in the configuration
|
|
141
|
+
const currentMatterBridgeIds = new Set();
|
|
142
|
+
// Check platforms for Matter bridges
|
|
143
|
+
this.config.platforms.forEach((platformConfig) => {
|
|
144
|
+
if (platformConfig._matter && platformConfig.platform) {
|
|
145
|
+
try {
|
|
146
|
+
const plugin = this.pluginManager.getPluginForPlatform(platformConfig.platform);
|
|
147
|
+
const matterIdentifier = `${plugin.getPluginIdentifier()}-${platformConfig.platform}`;
|
|
148
|
+
currentMatterBridgeIds.add(matterIdentifier);
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
// Plugin not found, skip
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
// Check accessories for Matter bridges
|
|
156
|
+
this.config.accessories.forEach((accessoryConfig) => {
|
|
157
|
+
if (accessoryConfig._matter && accessoryConfig.accessory) {
|
|
158
|
+
try {
|
|
159
|
+
const plugin = this.pluginManager.getPluginForAccessory(accessoryConfig.accessory);
|
|
160
|
+
const matterIdentifier = `${plugin.getPluginIdentifier()}-${accessoryConfig.accessory}`;
|
|
161
|
+
currentMatterBridgeIds.add(matterIdentifier);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
// Plugin not found, skip
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
// Clean up Matter bridges that were removed from configuration
|
|
169
|
+
for (const bridgeId of existingMatterBridgeIds) {
|
|
170
|
+
if (!currentMatterBridgeIds.has(bridgeId) && this.childMatterBridges.has(bridgeId)) {
|
|
171
|
+
const removedBridge = this.childMatterBridges.get(bridgeId);
|
|
172
|
+
log.info(`Matter bridge "${bridgeId}" was removed from configuration, cleaning up...`);
|
|
173
|
+
// Stop and clean up the removed bridge (with permanent flag)
|
|
174
|
+
await removedBridge.teardown(true);
|
|
175
|
+
this.childMatterBridges.delete(bridgeId);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// start child HAP bridges
|
|
119
179
|
for (const childBridge of this.childBridges.values()) {
|
|
120
180
|
childBridge.start();
|
|
121
181
|
}
|
|
182
|
+
// start child Matter bridges
|
|
183
|
+
for (const childMatterBridge of this.childMatterBridges.values()) {
|
|
184
|
+
promises.push(childMatterBridge.start());
|
|
185
|
+
}
|
|
122
186
|
// restore cached accessories
|
|
123
187
|
this.bridgeService.restoreCachedPlatformAccessories();
|
|
124
188
|
this.api.signalFinished();
|
|
@@ -126,41 +190,159 @@ export class Server {
|
|
|
126
190
|
await Promise.all(promises)
|
|
127
191
|
.then(() => this.publishBridge());
|
|
128
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Get the status of all Matter bridges (child bridges only)
|
|
195
|
+
*/
|
|
196
|
+
getMatterBridgesStatus() {
|
|
197
|
+
return Array.from(this.childMatterBridges.values()).map(bridge => bridge.getMetadata());
|
|
198
|
+
}
|
|
129
199
|
teardown() {
|
|
130
200
|
this.bridgeService.teardown();
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
201
|
+
// Stop all child Matter bridges
|
|
202
|
+
for (const childMatterBridge of this.childMatterBridges.values()) {
|
|
203
|
+
childMatterBridge.teardown().catch((error) => {
|
|
204
|
+
log.error(`Failed to stop child Matter bridge ${childMatterBridge.getDisplayName()}:`, error);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
134
207
|
this.setServerStatus("down" /* ServerStatus.DOWN */);
|
|
135
208
|
}
|
|
136
209
|
publishBridge() {
|
|
137
210
|
this.bridgeService.publishBridge();
|
|
138
|
-
// Initialize and start Matter service if enabled
|
|
139
|
-
this.matterService.initialize().then(() => {
|
|
140
|
-
this.matterService.start().catch((error) => {
|
|
141
|
-
log.error('Failed to start Matter service:', error);
|
|
142
|
-
});
|
|
143
|
-
}).catch((error) => {
|
|
144
|
-
log.error('Failed to initialize Matter service:', error);
|
|
145
|
-
});
|
|
146
211
|
this.printSetupInfo(this.config.bridge.pin);
|
|
147
212
|
}
|
|
148
|
-
|
|
149
|
-
|
|
213
|
+
// Matter accessories are managed via _matter configuration, not API methods
|
|
214
|
+
handlePublishExternalAccessories(accessories) {
|
|
215
|
+
log.info(`Publishing ${accessories.length} external accessories`);
|
|
216
|
+
// External accessories are only published to child Matter bridges, not main bridge
|
|
217
|
+
// Group accessories by plugin
|
|
218
|
+
const accessoriesByPlugin = new Map();
|
|
150
219
|
accessories.forEach((accessory) => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
220
|
+
const pluginIdentifier = accessory._associatedPlugin;
|
|
221
|
+
if (!pluginIdentifier) {
|
|
222
|
+
log.warn(`External accessory "${accessory.displayName}" has no plugin identifier`);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
if (!accessoriesByPlugin.has(pluginIdentifier)) {
|
|
226
|
+
accessoriesByPlugin.set(pluginIdentifier, []);
|
|
227
|
+
}
|
|
228
|
+
accessoriesByPlugin.get(pluginIdentifier).push(accessory);
|
|
154
229
|
});
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
this.
|
|
160
|
-
|
|
161
|
-
|
|
230
|
+
// Process each plugin's external accessories
|
|
231
|
+
accessoriesByPlugin.forEach((pluginAccessories, pluginIdentifier) => {
|
|
232
|
+
// Check if there's already an external Matter bridge for this plugin
|
|
233
|
+
const externalMatterBridgeId = `${pluginIdentifier}-external`;
|
|
234
|
+
let externalMatterBridge = this.childMatterBridges.get(externalMatterBridgeId);
|
|
235
|
+
if (!externalMatterBridge) {
|
|
236
|
+
// Check if this plugin has any Matter-enabled platform config
|
|
237
|
+
let hasMatterConfig = false;
|
|
238
|
+
let baseMatterConfig = {};
|
|
239
|
+
// Look for any platform with Matter config from this plugin
|
|
240
|
+
for (const [bridgeId, childBridge] of this.childMatterBridges) {
|
|
241
|
+
if (bridgeId.startsWith(`${pluginIdentifier}-`) && childBridge.type === "platform" /* PluginType.PLATFORM */) {
|
|
242
|
+
hasMatterConfig = true;
|
|
243
|
+
// Use existing Matter bridge configuration as template
|
|
244
|
+
baseMatterConfig = {
|
|
245
|
+
// Port will be auto-allocated
|
|
246
|
+
};
|
|
247
|
+
break;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// If plugin has Matter-enabled platforms, create external bridge automatically
|
|
251
|
+
if (hasMatterConfig) {
|
|
252
|
+
log.info(`Automatically creating external Matter bridge for ${pluginIdentifier}`);
|
|
253
|
+
const plugin = this.pluginManager.getPlugin(pluginIdentifier);
|
|
254
|
+
if (!plugin) {
|
|
255
|
+
log.warn(`Could not find plugin ${pluginIdentifier} to create external Matter bridge`);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
// Create synthetic config for external bridge
|
|
259
|
+
const externalConfig = {
|
|
260
|
+
platform: '__external__',
|
|
261
|
+
name: `${pluginIdentifier} External`,
|
|
262
|
+
_matter: {
|
|
263
|
+
...baseMatterConfig,
|
|
264
|
+
name: `${pluginIdentifier} External Matter`,
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
externalMatterBridge = new ChildMatterBridgeService("platform" /* PluginType.PLATFORM */, plugin, externalConfig._matter, externalConfig, this.api, this.externalPortService, this.options, this.ipcService, this.config);
|
|
268
|
+
this.childMatterBridges.set(externalMatterBridgeId, externalMatterBridge);
|
|
269
|
+
// Start the external bridge
|
|
270
|
+
externalMatterBridge.start().catch((error) => {
|
|
271
|
+
log.error(`Failed to start external Matter bridge for ${pluginIdentifier}:`, error);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
// Publish accessories to appropriate bridge
|
|
276
|
+
if (externalMatterBridge) {
|
|
277
|
+
pluginAccessories.forEach((accessory) => {
|
|
278
|
+
externalMatterBridge.addAccessory(accessory);
|
|
279
|
+
log.info(`External accessory "${accessory.displayName}" added to automatic external Matter bridge`);
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
// Check if any child Matter bridge from this plugin can handle it
|
|
284
|
+
let publishedToChildBridge = false;
|
|
285
|
+
for (const [bridgeId, childBridge] of this.childMatterBridges) {
|
|
286
|
+
if (bridgeId.startsWith(`${pluginIdentifier}-`)) {
|
|
287
|
+
pluginAccessories.forEach((accessory) => {
|
|
288
|
+
childBridge.addAccessory(accessory);
|
|
289
|
+
log.info(`External accessory "${accessory.displayName}" added to plugin's Matter bridge`);
|
|
290
|
+
});
|
|
291
|
+
publishedToChildBridge = true;
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
// External accessories are only published to child Matter bridges, not main bridge
|
|
296
|
+
if (!publishedToChildBridge) {
|
|
297
|
+
pluginAccessories.forEach((accessory) => {
|
|
298
|
+
log.debug(`External accessory "${accessory.displayName}" not published to Matter - configure _matter property for Matter support`);
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
}
|
|
162
302
|
});
|
|
163
303
|
}
|
|
304
|
+
handleRegisterPlatformAccessories(accessories) {
|
|
305
|
+
// Route to HAP bridge (default behavior)
|
|
306
|
+
this.bridgeService.handleRegisterPlatformAccessories(accessories);
|
|
307
|
+
// Check if we need to also route to Matter bridges
|
|
308
|
+
for (const accessory of accessories) {
|
|
309
|
+
const platformKey = `${accessory._associatedPlugin}-${accessory._associatedPlatform}`;
|
|
310
|
+
const platformConfig = this.platformConfigs.get(platformKey);
|
|
311
|
+
if (platformConfig) {
|
|
312
|
+
// Check if platform has child Matter bridge
|
|
313
|
+
if (platformConfig._matter && typeof platformConfig._matter === 'object') {
|
|
314
|
+
const matterIdentifier = `${accessory._associatedPlugin}-${accessory._associatedPlatform}`;
|
|
315
|
+
const childMatterBridge = this.childMatterBridges.get(matterIdentifier);
|
|
316
|
+
if (childMatterBridge) {
|
|
317
|
+
childMatterBridge.addAccessory(accessory).catch((error) => {
|
|
318
|
+
log.error(`Failed to add accessory "${accessory.displayName}" to child Matter bridge:`, error);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
handleUnregisterPlatformAccessories(accessories) {
|
|
326
|
+
// Route to HAP bridge (default behavior)
|
|
327
|
+
this.bridgeService.handleUnregisterPlatformAccessories(accessories);
|
|
328
|
+
// Check if we need to also unregister from Matter bridges
|
|
329
|
+
for (const accessory of accessories) {
|
|
330
|
+
const platformKey = `${accessory._associatedPlugin}-${accessory._associatedPlatform}`;
|
|
331
|
+
const platformConfig = this.platformConfigs.get(platformKey);
|
|
332
|
+
if (platformConfig) {
|
|
333
|
+
// Check if platform has child Matter bridge
|
|
334
|
+
if (platformConfig._matter && typeof platformConfig._matter === 'object') {
|
|
335
|
+
const matterIdentifier = `${accessory._associatedPlugin}-${accessory._associatedPlatform}`;
|
|
336
|
+
const childMatterBridge = this.childMatterBridges.get(matterIdentifier);
|
|
337
|
+
if (childMatterBridge) {
|
|
338
|
+
childMatterBridge.removeAccessory(accessory).catch((error) => {
|
|
339
|
+
log.error(`Failed to remove accessory "${accessory.displayName}" from child Matter bridge:`, error);
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
164
346
|
static loadConfig() {
|
|
165
347
|
// Look for the configuration file
|
|
166
348
|
const configPath = User.configPath();
|
|
@@ -295,6 +477,40 @@ export class Server {
|
|
|
295
477
|
}
|
|
296
478
|
// add config to child bridge service
|
|
297
479
|
childBridge.addConfig(accessoryConfig);
|
|
480
|
+
// If _matter is not defined, we're done - this accessory only uses HAP child bridge
|
|
481
|
+
if (!accessoryConfig._matter) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
// Handle child Matter bridge for accessories
|
|
486
|
+
if (accessoryConfig._matter && typeof accessoryConfig._matter === 'object') {
|
|
487
|
+
const matterIdentifier = `${plugin.getPluginIdentifier()}-${accessoryIdentifier}`;
|
|
488
|
+
logger(`Initializing child Matter bridge for accessory ${accessoryIdentifier}`);
|
|
489
|
+
// Ensure Matter config has proper name
|
|
490
|
+
// Try to get a human-friendly name from the accessory
|
|
491
|
+
// Convert CamelCase accessory identifier to spaces
|
|
492
|
+
const formattedAccessoryId = accessoryIdentifier.replace(/([A-Z])/g, ' $1').trim();
|
|
493
|
+
// Get plugin name without 'homebridge-' prefix and replace dashes with spaces
|
|
494
|
+
const pluginDisplayName = plugin.getPluginIdentifier()
|
|
495
|
+
.replace('homebridge-', '')
|
|
496
|
+
.replace(/-/g, ' ')
|
|
497
|
+
.split(' ')
|
|
498
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
499
|
+
.join(' ');
|
|
500
|
+
const defaultName = accessoryConfig.name || formattedAccessoryId || pluginDisplayName;
|
|
501
|
+
const matterConfig = {
|
|
502
|
+
...accessoryConfig._matter,
|
|
503
|
+
name: accessoryConfig._matter.name || defaultName,
|
|
504
|
+
};
|
|
505
|
+
const childMatterBridge = new ChildMatterBridgeService("accessory" /* PluginType.ACCESSORY */, plugin, matterConfig, accessoryConfig, this.api, this.externalPortService, this.options, this.ipcService);
|
|
506
|
+
this.childMatterBridges.set(matterIdentifier, childMatterBridge);
|
|
507
|
+
// If _bridge is also defined, we're done - accessory uses both protocols
|
|
508
|
+
if (accessoryConfig._bridge) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
// If both _bridge and _matter are defined, the accessory is handled by child bridges
|
|
513
|
+
if (accessoryConfig._bridge || accessoryConfig._matter) {
|
|
298
514
|
return;
|
|
299
515
|
}
|
|
300
516
|
const accessoryInstance = new constructor(logger, accessoryConfig, this.api);
|
|
@@ -352,6 +568,10 @@ export class Server {
|
|
|
352
568
|
}
|
|
353
569
|
const logger = Logger.withPrefix(displayName);
|
|
354
570
|
logger('Initializing %s platform...', platformIdentifier);
|
|
571
|
+
// Store platform config for later routing
|
|
572
|
+
const platformKey = `${plugin.getPluginIdentifier()}-${platformIdentifier}`;
|
|
573
|
+
this.platformConfigs.set(platformKey, platformConfig);
|
|
574
|
+
// Handle child HAP bridge
|
|
355
575
|
if (platformConfig._bridge) {
|
|
356
576
|
// ensure the username is always uppercase
|
|
357
577
|
platformConfig._bridge.username = platformConfig._bridge.username.toUpperCase();
|
|
@@ -367,6 +587,40 @@ export class Server {
|
|
|
367
587
|
this.childBridges.set(platformConfig._bridge.username, childBridge);
|
|
368
588
|
// add config to child bridge service
|
|
369
589
|
childBridge.addConfig(platformConfig);
|
|
590
|
+
// If _matter is not defined, we're done - this platform only uses HAP child bridge
|
|
591
|
+
if (!platformConfig._matter) {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
// Handle child Matter bridge
|
|
596
|
+
if (platformConfig._matter && typeof platformConfig._matter === 'object') {
|
|
597
|
+
const matterIdentifier = `${plugin.getPluginIdentifier()}-${platformIdentifier}`;
|
|
598
|
+
logger(`Initializing child Matter bridge for ${platformIdentifier}`);
|
|
599
|
+
// Ensure Matter config has proper name
|
|
600
|
+
// Try to get a human-friendly name from the platform
|
|
601
|
+
// Convert CamelCase platform identifier to spaces (e.g., "Ring" stays "Ring", "MySmartHome" becomes "My Smart Home")
|
|
602
|
+
const formattedPlatformId = platformIdentifier.replace(/([A-Z])/g, ' $1').trim();
|
|
603
|
+
// Get plugin name without 'homebridge-' prefix and replace dashes with spaces
|
|
604
|
+
const pluginDisplayName = plugin.getPluginIdentifier()
|
|
605
|
+
.replace('homebridge-', '')
|
|
606
|
+
.replace(/-/g, ' ')
|
|
607
|
+
.split(' ')
|
|
608
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
609
|
+
.join(' ');
|
|
610
|
+
const defaultName = platformConfig.name || formattedPlatformId || pluginDisplayName;
|
|
611
|
+
const matterConfig = {
|
|
612
|
+
...platformConfig._matter,
|
|
613
|
+
name: platformConfig._matter.name || defaultName,
|
|
614
|
+
};
|
|
615
|
+
const childMatterBridge = new ChildMatterBridgeService("platform" /* PluginType.PLATFORM */, plugin, matterConfig, platformConfig, this.api, this.externalPortService, this.options, this.ipcService);
|
|
616
|
+
this.childMatterBridges.set(matterIdentifier, childMatterBridge);
|
|
617
|
+
// If _bridge is also defined, we're done - platform uses both protocols
|
|
618
|
+
if (platformConfig._bridge) {
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
// If both _bridge and _matter are defined, the platform is handled by child bridges
|
|
623
|
+
if (platformConfig._bridge || platformConfig._matter) {
|
|
370
624
|
return;
|
|
371
625
|
}
|
|
372
626
|
const platform = new constructor(logger, platformConfig, this.api);
|
|
@@ -442,6 +696,84 @@ export class Server {
|
|
|
442
696
|
this.ipcService.on("childBridgeMetadataRequest" /* IpcIncomingEvent.CHILD_BRIDGE_METADATA_REQUEST */, () => {
|
|
443
697
|
this.ipcService.sendMessage("childBridgeMetadataResponse" /* IpcOutgoingEvent.CHILD_BRIDGE_METADATA_RESPONSE */, Array.from(this.childBridges.values()).map(x => x.getMetadata()));
|
|
444
698
|
});
|
|
699
|
+
// Matter bridge IPC handlers
|
|
700
|
+
this.ipcService.on("restartMatterBridge" /* IpcIncomingEvent.RESTART_MATTER_BRIDGE */, (matterBridgeId) => {
|
|
701
|
+
log.info(`Received restart request for Matter bridge: ${matterBridgeId}`);
|
|
702
|
+
if (typeof matterBridgeId === 'string') {
|
|
703
|
+
const matterBridge = this.childMatterBridges.get(matterBridgeId);
|
|
704
|
+
if (matterBridge) {
|
|
705
|
+
log.info(`Restarting Matter bridge: ${matterBridgeId}`);
|
|
706
|
+
matterBridge.restartChildBridge();
|
|
707
|
+
}
|
|
708
|
+
else {
|
|
709
|
+
log.warn(`Matter bridge not found: ${matterBridgeId}`);
|
|
710
|
+
log.debug('Available Matter bridges:', Array.from(this.childMatterBridges.keys()));
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
this.ipcService.on("stopMatterBridge" /* IpcIncomingEvent.STOP_MATTER_BRIDGE */, (matterBridgeId) => {
|
|
715
|
+
log.info(`Received stop request for Matter bridge: ${matterBridgeId}`);
|
|
716
|
+
if (typeof matterBridgeId === 'string') {
|
|
717
|
+
const matterBridge = this.childMatterBridges.get(matterBridgeId);
|
|
718
|
+
if (matterBridge) {
|
|
719
|
+
log.info(`Stopping Matter bridge: ${matterBridgeId}`);
|
|
720
|
+
matterBridge.stopChildBridge();
|
|
721
|
+
}
|
|
722
|
+
else {
|
|
723
|
+
log.warn(`Matter bridge not found: ${matterBridgeId}`);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
this.ipcService.on("startMatterBridge" /* IpcIncomingEvent.START_MATTER_BRIDGE */, (matterBridgeId) => {
|
|
728
|
+
log.info(`Received start request for Matter bridge: ${matterBridgeId}`);
|
|
729
|
+
if (typeof matterBridgeId === 'string') {
|
|
730
|
+
const matterBridge = this.childMatterBridges.get(matterBridgeId);
|
|
731
|
+
if (matterBridge) {
|
|
732
|
+
log.info(`Starting Matter bridge: ${matterBridgeId}`);
|
|
733
|
+
matterBridge.startChildBridge();
|
|
734
|
+
}
|
|
735
|
+
else {
|
|
736
|
+
log.warn(`Matter bridge not found: ${matterBridgeId}`);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
this.ipcService.on("matterBridgeMetadataRequest" /* IpcIncomingEvent.MATTER_BRIDGE_METADATA_REQUEST */, () => {
|
|
741
|
+
// Return all child Matter bridge metadata
|
|
742
|
+
this.ipcService.sendMessage("matterBridgeMetadataResponse" /* IpcOutgoingEvent.MATTER_BRIDGE_METADATA_RESPONSE */, Array.from(this.childMatterBridges.values()).map(x => x.getMetadata()));
|
|
743
|
+
});
|
|
744
|
+
this.ipcService.on("matterAccessoriesRequest" /* IpcIncomingEvent.MATTER_ACCESSORIES_REQUEST */, () => {
|
|
745
|
+
// Collect Matter accessories from all child bridges
|
|
746
|
+
const allMatterAccessories = {
|
|
747
|
+
children: {},
|
|
748
|
+
};
|
|
749
|
+
// Add child bridge accessories
|
|
750
|
+
for (const [bridgeId, childBridge] of this.childMatterBridges) {
|
|
751
|
+
allMatterAccessories.children[bridgeId] = childBridge.getMatterAccessories ? childBridge.getMatterAccessories() : [];
|
|
752
|
+
}
|
|
753
|
+
this.ipcService.sendMessage("matterAccessoriesResponse" /* IpcOutgoingEvent.MATTER_ACCESSORIES_RESPONSE */, allMatterAccessories);
|
|
754
|
+
});
|
|
755
|
+
// Handle new Matter IPC events
|
|
756
|
+
this.ipcService.on("toggleMatterDevice" /* IpcIncomingEvent.TOGGLE_MATTER_DEVICE */, (data) => {
|
|
757
|
+
if (data && data.uuid) {
|
|
758
|
+
// This would toggle Matter for a specific device
|
|
759
|
+
// Implementation depends on how devices are managed
|
|
760
|
+
log.debug(`Toggle Matter for device ${data.uuid}: ${data.enabled}`);
|
|
761
|
+
// Send status update
|
|
762
|
+
this.ipcService.sendMessage("matterDeviceStatusUpdate" /* IpcOutgoingEvent.MATTER_DEVICE_STATUS_UPDATE */, {
|
|
763
|
+
uuid: data.uuid,
|
|
764
|
+
matterEnabled: data.enabled,
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
this.ipcService.on("matterCommissioningInfoRequest" /* IpcIncomingEvent.MATTER_COMMISSIONING_INFO_REQUEST */, (matterBridgeId) => {
|
|
769
|
+
let commissioningInfo = null;
|
|
770
|
+
// Get child bridge commissioning info
|
|
771
|
+
const childBridge = this.childMatterBridges.get(matterBridgeId);
|
|
772
|
+
if (childBridge && childBridge.getCommissioningInfo) {
|
|
773
|
+
commissioningInfo = childBridge.getCommissioningInfo();
|
|
774
|
+
}
|
|
775
|
+
this.ipcService.sendMessage("matterCommissioningInfoResponse" /* IpcOutgoingEvent.MATTER_COMMISSIONING_INFO_RESPONSE */, commissioningInfo || { commissioned: false });
|
|
776
|
+
});
|
|
445
777
|
}
|
|
446
778
|
printSetupInfo(pin) {
|
|
447
779
|
/* eslint-disable no-console */
|