homebridge 2.0.0-beta.3 → 2.0.0-beta.31

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 (169) hide show
  1. package/README.md +16 -17
  2. package/bin/homebridge.js +22 -0
  3. package/config-sample.json +3 -3
  4. package/dist/api.d.ts +457 -0
  5. package/dist/api.d.ts.map +1 -0
  6. package/dist/api.js +221 -0
  7. package/dist/api.js.map +1 -0
  8. package/{lib → dist}/bridgeService.d.ts +19 -10
  9. package/dist/bridgeService.d.ts.map +1 -0
  10. package/{lib → dist}/bridgeService.js +85 -117
  11. package/dist/bridgeService.js.map +1 -0
  12. package/dist/childBridgeFork.d.ts +65 -0
  13. package/dist/childBridgeFork.d.ts.map +1 -0
  14. package/dist/childBridgeFork.js +531 -0
  15. package/dist/childBridgeFork.js.map +1 -0
  16. package/{lib → dist}/childBridgeService.d.ts +30 -7
  17. package/dist/childBridgeService.d.ts.map +1 -0
  18. package/{lib → dist}/childBridgeService.js +127 -69
  19. package/dist/childBridgeService.js.map +1 -0
  20. package/dist/cli.d.ts +3 -0
  21. package/dist/cli.d.ts.map +1 -0
  22. package/dist/cli.js +90 -0
  23. package/dist/cli.js.map +1 -0
  24. package/dist/externalPortService.d.ts +54 -0
  25. package/dist/externalPortService.d.ts.map +1 -0
  26. package/dist/externalPortService.js +125 -0
  27. package/dist/externalPortService.js.map +1 -0
  28. package/dist/index.d.ts +122 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +34 -0
  31. package/dist/index.js.map +1 -0
  32. package/{lib → dist}/ipcService.d.ts +22 -5
  33. package/dist/ipcService.d.ts.map +1 -0
  34. package/{lib → dist}/ipcService.js +12 -12
  35. package/dist/ipcService.js.map +1 -0
  36. package/{lib → dist}/logger.d.ts +12 -6
  37. package/dist/logger.d.ts.map +1 -0
  38. package/{lib → dist}/logger.js +27 -28
  39. package/dist/logger.js.map +1 -0
  40. package/dist/matter/index.d.ts +123 -0
  41. package/dist/matter/index.d.ts.map +1 -0
  42. package/dist/matter/index.js +19 -0
  43. package/dist/matter/index.js.map +1 -0
  44. package/dist/matter/matterAccessoryCache.d.ts +96 -0
  45. package/dist/matter/matterAccessoryCache.d.ts.map +1 -0
  46. package/dist/matter/matterAccessoryCache.js +192 -0
  47. package/dist/matter/matterAccessoryCache.js.map +1 -0
  48. package/dist/matter/matterBehaviors.d.ts +194 -0
  49. package/dist/matter/matterBehaviors.d.ts.map +1 -0
  50. package/dist/matter/matterBehaviors.js +665 -0
  51. package/dist/matter/matterBehaviors.js.map +1 -0
  52. package/dist/matter/matterConfigValidator.d.ts +81 -0
  53. package/dist/matter/matterConfigValidator.d.ts.map +1 -0
  54. package/dist/matter/matterConfigValidator.js +240 -0
  55. package/dist/matter/matterConfigValidator.js.map +1 -0
  56. package/dist/matter/matterErrorHandler.d.ts +106 -0
  57. package/dist/matter/matterErrorHandler.d.ts.map +1 -0
  58. package/dist/matter/matterErrorHandler.js +495 -0
  59. package/dist/matter/matterErrorHandler.js.map +1 -0
  60. package/dist/matter/matterLogFormatter.d.ts +19 -0
  61. package/dist/matter/matterLogFormatter.d.ts.map +1 -0
  62. package/dist/matter/matterLogFormatter.js +144 -0
  63. package/dist/matter/matterLogFormatter.js.map +1 -0
  64. package/dist/matter/matterNetworkMonitor.d.ts +68 -0
  65. package/dist/matter/matterNetworkMonitor.d.ts.map +1 -0
  66. package/dist/matter/matterNetworkMonitor.js +249 -0
  67. package/dist/matter/matterNetworkMonitor.js.map +1 -0
  68. package/dist/matter/matterServer.d.ts +656 -0
  69. package/dist/matter/matterServer.d.ts.map +1 -0
  70. package/dist/matter/matterServer.js +1690 -0
  71. package/dist/matter/matterServer.js.map +1 -0
  72. package/dist/matter/matterServerHelpers.d.ts +81 -0
  73. package/dist/matter/matterServerHelpers.d.ts.map +1 -0
  74. package/dist/matter/matterServerHelpers.js +323 -0
  75. package/dist/matter/matterServerHelpers.js.map +1 -0
  76. package/dist/matter/matterSharedTypes.d.ts +170 -0
  77. package/dist/matter/matterSharedTypes.d.ts.map +1 -0
  78. package/dist/matter/matterSharedTypes.js +52 -0
  79. package/dist/matter/matterSharedTypes.js.map +1 -0
  80. package/dist/matter/matterStorage.d.ts +128 -0
  81. package/dist/matter/matterStorage.d.ts.map +1 -0
  82. package/dist/matter/matterStorage.js +415 -0
  83. package/dist/matter/matterStorage.js.map +1 -0
  84. package/dist/matter/matterTypes.d.ts +745 -0
  85. package/dist/matter/matterTypes.d.ts.map +1 -0
  86. package/dist/matter/matterTypes.js +174 -0
  87. package/dist/matter/matterTypes.js.map +1 -0
  88. package/{lib → dist}/platformAccessory.d.ts +8 -6
  89. package/dist/platformAccessory.d.ts.map +1 -0
  90. package/{lib → dist}/platformAccessory.js +19 -16
  91. package/dist/platformAccessory.js.map +1 -0
  92. package/{lib → dist}/plugin.d.ts +2 -3
  93. package/dist/plugin.d.ts.map +1 -0
  94. package/{lib → dist}/plugin.js +39 -51
  95. package/dist/plugin.js.map +1 -0
  96. package/{lib → dist}/pluginManager.d.ts +3 -3
  97. package/dist/pluginManager.d.ts.map +1 -0
  98. package/{lib → dist}/pluginManager.js +76 -81
  99. package/dist/pluginManager.js.map +1 -0
  100. package/{lib → dist}/server.d.ts +23 -1
  101. package/dist/server.d.ts.map +1 -0
  102. package/dist/server.js +811 -0
  103. package/dist/server.js.map +1 -0
  104. package/{lib → dist}/storageService.d.ts.map +1 -1
  105. package/dist/storageService.js +41 -0
  106. package/dist/storageService.js.map +1 -0
  107. package/{lib → dist}/user.d.ts +1 -0
  108. package/dist/user.d.ts.map +1 -0
  109. package/dist/user.js +32 -0
  110. package/dist/user.js.map +1 -0
  111. package/{lib → dist}/util/mac.d.ts +1 -0
  112. package/dist/util/mac.d.ts.map +1 -0
  113. package/dist/util/mac.js +14 -0
  114. package/dist/util/mac.js.map +1 -0
  115. package/dist/version.d.ts.map +1 -0
  116. package/dist/version.js +16 -0
  117. package/dist/version.js.map +1 -0
  118. package/package.json +48 -49
  119. package/bin/homebridge +0 -17
  120. package/lib/api.d.ts +0 -210
  121. package/lib/api.d.ts.map +0 -1
  122. package/lib/api.js +0 -155
  123. package/lib/api.js.map +0 -1
  124. package/lib/bridgeService.d.ts.map +0 -1
  125. package/lib/bridgeService.js.map +0 -1
  126. package/lib/childBridgeFork.d.ts +0 -37
  127. package/lib/childBridgeFork.d.ts.map +0 -1
  128. package/lib/childBridgeFork.js +0 -244
  129. package/lib/childBridgeFork.js.map +0 -1
  130. package/lib/childBridgeService.d.ts.map +0 -1
  131. package/lib/childBridgeService.js.map +0 -1
  132. package/lib/cli.d.ts +0 -4
  133. package/lib/cli.d.ts.map +0 -1
  134. package/lib/cli.js +0 -111
  135. package/lib/cli.js.map +0 -1
  136. package/lib/externalPortService.d.ts +0 -33
  137. package/lib/externalPortService.d.ts.map +0 -1
  138. package/lib/externalPortService.js +0 -64
  139. package/lib/externalPortService.js.map +0 -1
  140. package/lib/index.d.ts +0 -76
  141. package/lib/index.d.ts.map +0 -1
  142. package/lib/index.js +0 -72
  143. package/lib/index.js.map +0 -1
  144. package/lib/ipcService.d.ts.map +0 -1
  145. package/lib/ipcService.js.map +0 -1
  146. package/lib/logger.d.ts.map +0 -1
  147. package/lib/logger.js.map +0 -1
  148. package/lib/platformAccessory.d.ts.map +0 -1
  149. package/lib/platformAccessory.js.map +0 -1
  150. package/lib/plugin.d.ts.map +0 -1
  151. package/lib/plugin.js.map +0 -1
  152. package/lib/pluginManager.d.ts.map +0 -1
  153. package/lib/pluginManager.js.map +0 -1
  154. package/lib/server.d.ts.map +0 -1
  155. package/lib/server.js +0 -457
  156. package/lib/server.js.map +0 -1
  157. package/lib/storageService.js +0 -70
  158. package/lib/storageService.js.map +0 -1
  159. package/lib/user.d.ts.map +0 -1
  160. package/lib/user.js +0 -36
  161. package/lib/user.js.map +0 -1
  162. package/lib/util/mac.d.ts.map +0 -1
  163. package/lib/util/mac.js +0 -20
  164. package/lib/util/mac.js.map +0 -1
  165. package/lib/version.d.ts.map +0 -1
  166. package/lib/version.js +0 -21
  167. package/lib/version.js.map +0 -1
  168. /package/{lib → dist}/storageService.d.ts +0 -0
  169. /package/{lib → dist}/version.d.ts +0 -0
@@ -0,0 +1,531 @@
1
+ /* global NodeJS */
2
+ import process from 'node:process';
3
+ import { HAPStorage } from 'hap-nodejs';
4
+ import { HomebridgeAPI } from './api.js';
5
+ import { BridgeService } from './bridgeService.js';
6
+ import { ChildBridgeExternalPortService } from './externalPortService.js';
7
+ import { Logger } from './logger.js';
8
+ import { MatterServer } from './matter/index.js';
9
+ import { PluginManager } from './pluginManager.js';
10
+ import { User } from './user.js';
11
+ import { generate } from './util/mac.js';
12
+ import 'source-map-support/register.js';
13
+ /**
14
+ * This is a standalone script executed as a child process fork
15
+ */
16
+ process.title = 'homebridge: child bridge';
17
+ export class ChildBridgeFork {
18
+ bridgeService;
19
+ api;
20
+ pluginManager;
21
+ externalPortService;
22
+ matterServer;
23
+ // External Matter servers for accessories that need their own bridge
24
+ externalMatterServers = new Map();
25
+ matterConfig;
26
+ matterSerialNumber;
27
+ type;
28
+ plugin;
29
+ identifier;
30
+ pluginConfig;
31
+ bridgeConfig;
32
+ bridgeOptions;
33
+ portRequestCallback = new Map();
34
+ constructor() {
35
+ // tell the parent process we are ready to accept plugin config
36
+ this.sendMessage("ready" /* ChildProcessMessageEventType.READY */);
37
+ }
38
+ sendMessage(type, data) {
39
+ if (process.send) {
40
+ process.send({
41
+ id: type,
42
+ data,
43
+ });
44
+ }
45
+ }
46
+ async loadPlugin(data) {
47
+ // set data
48
+ this.type = data.type;
49
+ this.identifier = data.identifier;
50
+ this.pluginConfig = data.pluginConfig;
51
+ this.bridgeConfig = data.bridgeConfig;
52
+ this.bridgeOptions = data.bridgeOptions;
53
+ // remove the _bridge key (some plugins do not like unknown config)
54
+ for (const config of this.pluginConfig) {
55
+ delete config._bridge;
56
+ }
57
+ // set bridge settings (inherited from main bridge)
58
+ if (this.bridgeOptions.noLogTimestamps) {
59
+ Logger.setTimestampEnabled(false);
60
+ }
61
+ if (this.bridgeOptions.debugModeEnabled) {
62
+ Logger.setDebugEnabled(true);
63
+ }
64
+ if (this.bridgeOptions.forceColourLogging) {
65
+ Logger.forceColor();
66
+ }
67
+ if (this.bridgeOptions.customStoragePath) {
68
+ User.setStoragePath(this.bridgeOptions.customStoragePath);
69
+ }
70
+ // Initialize HAP-NodeJS with a custom persist directory
71
+ HAPStorage.setCustomStoragePath(User.persistPath());
72
+ // load api
73
+ this.api = new HomebridgeAPI();
74
+ this.pluginManager = new PluginManager(this.api);
75
+ this.externalPortService = new ChildBridgeExternalPortService(this);
76
+ // load plugin
77
+ this.plugin = this.pluginManager.loadPlugin(data.pluginPath);
78
+ await this.plugin.load();
79
+ await this.pluginManager.initializePlugin(this.plugin, data.identifier);
80
+ // change process title to include plugin name
81
+ process.title = `homebridge: ${this.plugin.getPluginIdentifier()}`;
82
+ this.sendMessage("loaded" /* ChildProcessMessageEventType.LOADED */, {
83
+ version: this.plugin.version,
84
+ });
85
+ }
86
+ async startBridge() {
87
+ // Check if Matter is configured
88
+ this.matterConfig = this.bridgeConfig.matter;
89
+ // Initialize Matter if it's configured
90
+ if (this.matterConfig) {
91
+ Logger.internal.debug('Child bridge has Matter config (Combined HAP+Matter), starting Matter server');
92
+ // If Matter doesn't have a port configured, allocate one
93
+ if (!this.matterConfig.port) {
94
+ // Generate a unique username for Matter port allocation
95
+ const matterUsername = `${this.bridgeConfig.username}:MATTER`;
96
+ const matterPort = await this.externalPortService.requestPort(matterUsername);
97
+ if (!matterPort) {
98
+ throw new Error('Failed to allocate Matter port for child bridge. '
99
+ + 'Please specify a port manually in the _bridge.matter configuration, or free up ports in the configured range.');
100
+ }
101
+ this.matterConfig.port = matterPort;
102
+ Logger.internal.debug(`Allocated Matter port: ${this.matterConfig.port} (HAP port: ${this.bridgeConfig.port})`);
103
+ }
104
+ // Start Matter server
105
+ await this.startMatterServer(this.matterConfig);
106
+ // Unified status with both HAP and Matter info will be sent when HAP bridge is advertised
107
+ }
108
+ this.bridgeService = new BridgeService(this.api, this.pluginManager, this.externalPortService, this.bridgeOptions, this.bridgeConfig);
109
+ // watch bridge events to check when server is online
110
+ this.bridgeService.bridge.on("advertised" /* AccessoryEventTypes.ADVERTISED */, () => {
111
+ this.sendPairedStatusEvent();
112
+ });
113
+ // watch for the paired event to update the server status
114
+ this.bridgeService.bridge.on("paired" /* AccessoryEventTypes.PAIRED */, () => {
115
+ this.sendPairedStatusEvent();
116
+ });
117
+ // watch for the unpaired event to update the server status
118
+ this.bridgeService.bridge.on("unpaired" /* AccessoryEventTypes.UNPAIRED */, () => {
119
+ this.sendPairedStatusEvent();
120
+ });
121
+ // load the cached accessories
122
+ await this.bridgeService.loadCachedPlatformAccessoriesFromDisk();
123
+ for (const config of this.pluginConfig) {
124
+ if (this.type === "platform" /* PluginType.PLATFORM */) {
125
+ const plugin = this.pluginManager.getPluginForPlatform(this.identifier);
126
+ const displayName = config.name || plugin.getPluginIdentifier();
127
+ const logger = Logger.withPrefix(displayName);
128
+ const constructor = plugin.getPlatformConstructor(this.identifier);
129
+ const platform = new constructor(logger, config, this.api);
130
+ if (HomebridgeAPI.isDynamicPlatformPlugin(platform)) {
131
+ plugin.assignDynamicPlatform(this.identifier, platform);
132
+ }
133
+ else if (HomebridgeAPI.isStaticPlatformPlugin(platform)) { // Plugin 1.0, load accessories
134
+ await this.bridgeService.loadPlatformAccessories(plugin, platform, this.identifier, logger);
135
+ }
136
+ else {
137
+ // otherwise it's a IndependentPlatformPlugin which doesn't expose any methods at all.
138
+ // We just call the constructor and let it be enabled.
139
+ }
140
+ }
141
+ else if (this.type === "accessory" /* PluginType.ACCESSORY */) {
142
+ const plugin = this.pluginManager.getPluginForAccessory(this.identifier);
143
+ const displayName = config.name;
144
+ if (!displayName) {
145
+ Logger.internal.warn('Could not load accessory %s as it is missing the required \'name\' property!', this.identifier);
146
+ return;
147
+ }
148
+ const logger = Logger.withPrefix(displayName);
149
+ const constructor = plugin.getAccessoryConstructor(this.identifier);
150
+ const accessoryInstance = new constructor(logger, config, this.api);
151
+ // pass accessoryIdentifier for UUID generation, and optional parameter uuid_base which can be used instead of displayName for UUID generation
152
+ const accessory = this.bridgeService.createHAPAccessory(plugin, accessoryInstance, displayName, this.identifier, config.uuid_base);
153
+ if (accessory) {
154
+ this.bridgeService.bridge.addBridgedAccessory(accessory);
155
+ }
156
+ else {
157
+ logger('Accessory %s returned empty set of services. Won\'t adding it to the bridge!', this.identifier);
158
+ }
159
+ }
160
+ }
161
+ // restore the cached accessories
162
+ this.bridgeService.restoreCachedPlatformAccessories();
163
+ // Only restore Matter accessories if Matter is enabled for this bridge
164
+ if (this.matterServer) {
165
+ this.restoreCachedMatterAccessories();
166
+ }
167
+ this.bridgeService.publishBridge();
168
+ this.api.signalFinished();
169
+ // tell the parent we are online
170
+ this.sendMessage("online" /* ChildProcessMessageEventType.ONLINE */);
171
+ }
172
+ /**
173
+ * Request the next available external HAP port from the parent process
174
+ * @param username
175
+ */
176
+ async requestExternalPort(username) {
177
+ return new Promise((resolve) => {
178
+ const requestTimeout = setTimeout(() => {
179
+ Logger.internal.warn('Parent process did not respond to port allocation request within 5 seconds - assigning random port.');
180
+ resolve(undefined);
181
+ }, 5000);
182
+ // setup callback
183
+ const callback = (port) => {
184
+ clearTimeout(requestTimeout);
185
+ resolve(port);
186
+ this.portRequestCallback.delete(username);
187
+ };
188
+ this.portRequestCallback.set(username, callback);
189
+ // send port request
190
+ this.sendMessage("portRequest" /* ChildProcessMessageEventType.PORT_REQUEST */, { username });
191
+ });
192
+ }
193
+ /**
194
+ * Request the next available Matter port from the parent process
195
+ * @param uniqueId - MAC-derived identifier (without colons)
196
+ */
197
+ async requestMatterPort(uniqueId) {
198
+ return new Promise((resolve) => {
199
+ const requestTimeout = setTimeout(() => {
200
+ Logger.internal.warn('Parent process did not respond to Matter port allocation request within 5 seconds - assigning random port.');
201
+ resolve(undefined);
202
+ }, 5000);
203
+ // Use uniqueId as the key for the callback map
204
+ const mac = uniqueId;
205
+ // setup callback
206
+ const callback = (port) => {
207
+ clearTimeout(requestTimeout);
208
+ resolve(port);
209
+ this.portRequestCallback.delete(mac);
210
+ };
211
+ this.portRequestCallback.set(mac, callback);
212
+ // send Matter port request
213
+ this.sendMessage("portRequest" /* ChildProcessMessageEventType.PORT_REQUEST */, {
214
+ username: mac,
215
+ portType: 'matter',
216
+ });
217
+ });
218
+ }
219
+ /**
220
+ * Handles the port allocation response message from the parent process
221
+ * @param data
222
+ */
223
+ handleExternalResponse(data) {
224
+ const callback = this.portRequestCallback.get(data.username);
225
+ if (callback) {
226
+ callback(data.port);
227
+ }
228
+ }
229
+ /**
230
+ * Sends the current pairing status of the child bridge to the parent process
231
+ */
232
+ sendPairedStatusEvent() {
233
+ // Get Matter commissioning info if Matter is configured
234
+ let matterInfo;
235
+ if (this.matterConfig && this.matterServer) {
236
+ const commissioningInfo = this.matterServer.getCommissioningInfo();
237
+ matterInfo = {
238
+ qrCode: commissioningInfo.qrCode,
239
+ manualPairingCode: commissioningInfo.manualPairingCode,
240
+ serialNumber: this.matterSerialNumber || commissioningInfo.serialNumber,
241
+ commissioned: commissioningInfo.commissioned || false,
242
+ deviceCount: this.matterServer.getAccessories().length,
243
+ };
244
+ Logger.internal.debug('Including Matter info in unified status update');
245
+ }
246
+ this.sendMessage("status" /* ChildProcessMessageEventType.STATUS_UPDATE */, {
247
+ paired: this.bridgeService?.bridge?._accessoryInfo?.paired() ?? null,
248
+ setupUri: this.bridgeService?.bridge?.setupURI() ?? null,
249
+ // Include Matter commissioning info in unified message
250
+ ...(matterInfo && { matter: matterInfo }),
251
+ });
252
+ }
253
+ /**
254
+ * Restore cached Matter accessories
255
+ */
256
+ restoreCachedMatterAccessories() {
257
+ if (!this.matterServer) {
258
+ Logger.internal.debug('Matter server not available for restoring cached accessories');
259
+ return;
260
+ }
261
+ const cachedAccessories = this.matterServer.getAllCachedAccessories();
262
+ Logger.internal.debug(`Restoring ${cachedAccessories.length} cached Matter accessories`);
263
+ for (const cachedAccessory of cachedAccessories) {
264
+ let plugin = this.pluginManager.getPlugin(cachedAccessory.plugin);
265
+ if (!plugin) {
266
+ try {
267
+ // Try to find plugin by platform name (handles plugin renames)
268
+ plugin = this.pluginManager.getPluginByActiveDynamicPlatform(cachedAccessory.platform);
269
+ if (plugin) {
270
+ Logger.internal.info(`When searching for the associated plugin of the Matter accessory '${cachedAccessory.displayName}' `
271
+ + `it seems like the plugin name changed from '${cachedAccessory.plugin}' to '${plugin.getPluginIdentifier()}'. Plugin association is now being transformed!`);
272
+ }
273
+ }
274
+ catch (error) {
275
+ Logger.internal.warn(`Could not find the associated plugin for the Matter accessory '${cachedAccessory.displayName}'. `
276
+ + `Tried to find the plugin by the platform name but ${error.message}`);
277
+ }
278
+ }
279
+ const platformPlugin = plugin && plugin.getActiveDynamicPlatform(cachedAccessory.platform);
280
+ if (!platformPlugin) {
281
+ Logger.internal.warn(`Failed to find plugin to handle Matter accessory ${cachedAccessory.displayName} (plugin: ${cachedAccessory.plugin}, platform: ${cachedAccessory.platform})`);
282
+ // Note: Matter accessories are not added to the bridge here - they're registered via plugin's didFinishLaunching
283
+ // The plugin can check if this accessory still exists and re-register or remove it
284
+ }
285
+ else {
286
+ // Call configureMatterAccessory if the plugin implements it
287
+ if (platformPlugin.configureMatterAccessory) {
288
+ Logger.internal.debug(`Calling configureMatterAccessory for ${cachedAccessory.displayName}`);
289
+ platformPlugin.configureMatterAccessory(cachedAccessory);
290
+ }
291
+ else {
292
+ Logger.internal.debug(`Platform ${cachedAccessory.platform} does not implement configureMatterAccessory`);
293
+ }
294
+ }
295
+ }
296
+ }
297
+ /**
298
+ * Start Matter server for child bridge
299
+ */
300
+ async startMatterServer(matterConfig) {
301
+ Logger.internal.info('Starting Matter server in child bridge process');
302
+ // Create Matter server with the provided configuration
303
+ const serialNumber = this.bridgeConfig.username.replace(/:/g, '');
304
+ // Normalize bind config to array format
305
+ const networkInterfaces = this.bridgeConfig.bind
306
+ ? Array.isArray(this.bridgeConfig.bind)
307
+ ? this.bridgeConfig.bind
308
+ : [this.bridgeConfig.bind]
309
+ : undefined;
310
+ this.matterServer = new MatterServer({
311
+ port: matterConfig.port || 5540,
312
+ uniqueId: serialNumber,
313
+ storagePath: User.matterPath(),
314
+ debugModeEnabled: this.bridgeOptions.debugModeEnabled,
315
+ manufacturer: this.bridgeConfig.manufacturer,
316
+ model: this.bridgeConfig.model,
317
+ firmwareRevision: this.bridgeConfig.firmwareRevision,
318
+ serialNumber,
319
+ networkInterfaces,
320
+ });
321
+ await this.matterServer.start();
322
+ // Inform the API that Matter is enabled
323
+ this.api._setMatterEnabled(true);
324
+ // Set the Matter server reference for API methods like getAccessoryState
325
+ this.api._setMatterServer(this.matterServer);
326
+ const commissioningInfo = this.matterServer.getCommissioningInfo();
327
+ Logger.internal.info('Matter server started with commissioning info:', commissioningInfo);
328
+ // Store the serial number for status updates
329
+ this.matterSerialNumber = commissioningInfo.serialNumber;
330
+ // Listen for Matter commissioning events to update status
331
+ this.matterServer.on('commissioning-changed', (commissioned, fabricCount) => {
332
+ Logger.internal.info(`Matter commissioning state changed: commissioned=${commissioned}, fabricCount=${fabricCount}`);
333
+ this.sendPairedStatusEvent();
334
+ });
335
+ // Set up event listeners for Matter API calls
336
+ this.api.on("publishExternalMatterAccessories" /* InternalAPIEvent.PUBLISH_EXTERNAL_MATTER_ACCESSORIES */, (accessories) => {
337
+ this.handlePublishExternalMatterAccessories(accessories).catch((error) => {
338
+ Logger.internal.error('Failed to publish external Matter accessories:', error);
339
+ });
340
+ });
341
+ this.api.on("registerMatterPlatformAccessories" /* InternalAPIEvent.REGISTER_MATTER_PLATFORM_ACCESSORIES */, (pluginIdentifier, platformName, accessories) => {
342
+ if (this.matterServer) {
343
+ this.matterServer.registerPlatformAccessories(pluginIdentifier, platformName, accessories).catch((error) => {
344
+ Logger.internal.error(`Failed to register Matter accessories for ${pluginIdentifier}:`, error);
345
+ });
346
+ }
347
+ });
348
+ this.api.on("unregisterMatterPlatformAccessories" /* InternalAPIEvent.UNREGISTER_MATTER_PLATFORM_ACCESSORIES */, (pluginIdentifier, platformName, accessories) => {
349
+ if (this.matterServer) {
350
+ this.matterServer.unregisterPlatformAccessories(pluginIdentifier, platformName, accessories).catch((error) => {
351
+ Logger.internal.error(`Failed to unregister Matter accessories for ${pluginIdentifier}:`, error);
352
+ });
353
+ }
354
+ });
355
+ this.api.on("updateMatterAccessoryState" /* InternalAPIEvent.UPDATE_MATTER_ACCESSORY_STATE */, (uuid, cluster, attributes, partId) => {
356
+ // Check if this is an external accessory first (each has its own MatterServer)
357
+ if (this.externalMatterServers.has(uuid)) {
358
+ const externalServer = this.externalMatterServers.get(uuid);
359
+ externalServer.updateAccessoryState(uuid, cluster, attributes, partId).catch((error) => {
360
+ Logger.internal.error(`Failed to update Matter accessory state for external accessory ${uuid}:`, error);
361
+ });
362
+ }
363
+ else if (this.matterServer) {
364
+ // Otherwise, try the main child bridge Matter server
365
+ this.matterServer.updateAccessoryState(uuid, cluster, attributes, partId).catch((error) => {
366
+ Logger.internal.error(`Failed to update Matter accessory state for ${uuid}:`, error);
367
+ });
368
+ }
369
+ });
370
+ }
371
+ /**
372
+ * Handle external Matter accessories - each gets its own dedicated Matter server
373
+ * This is required for devices like Robotic Vacuum Cleaners that Apple Home
374
+ * requires to be on their own bridge.
375
+ */
376
+ async handlePublishExternalMatterAccessories(accessories) {
377
+ Logger.internal.info(`Publishing ${accessories.length} external Matter accessor${accessories.length === 1 ? 'y' : 'ies'} from child bridge`);
378
+ for (const accessory of accessories) {
379
+ try {
380
+ // Validate accessory has required fields
381
+ if (!accessory.uuid) {
382
+ Logger.internal.error('External Matter accessory missing UUID - skipping');
383
+ continue;
384
+ }
385
+ if (!accessory.displayName) {
386
+ Logger.internal.error(`External Matter accessory ${accessory.uuid} missing displayName - skipping`);
387
+ continue;
388
+ }
389
+ // Check if already published
390
+ if (this.externalMatterServers.has(accessory.uuid)) {
391
+ Logger.internal.warn(`External Matter accessory ${accessory.displayName} (${accessory.uuid}) is already published`);
392
+ continue;
393
+ }
394
+ // Generate deterministic MAC address from UUID (same pattern as HAP external accessories)
395
+ const advertiseAddress = generate(accessory.uuid);
396
+ // For Matter, use the MAC without colons as uniqueId
397
+ const uniqueId = advertiseAddress.replace(/:/g, '');
398
+ // Allocate Matter port from parent process via IPC
399
+ const port = await this.externalPortService.requestMatterPort(uniqueId);
400
+ if (!port) {
401
+ Logger.internal.error(`Failed to allocate Matter port for external Matter accessory ${accessory.displayName}`);
402
+ Logger.internal.error('Please configure matterPorts in config.json or free up ports in the default range (5530-5541)');
403
+ continue;
404
+ }
405
+ Logger.internal.info(`Allocated port ${port} for external Matter accessory: ${accessory.displayName}`);
406
+ // Normalize bind config to array format (inherit from bridge)
407
+ const networkInterfaces = this.bridgeConfig.bind
408
+ ? Array.isArray(this.bridgeConfig.bind)
409
+ ? this.bridgeConfig.bind
410
+ : [this.bridgeConfig.bind]
411
+ : undefined;
412
+ // Create dedicated Matter server for this accessory
413
+ const matterServer = new MatterServer({
414
+ port,
415
+ uniqueId,
416
+ storagePath: User.matterPath(),
417
+ manufacturer: accessory.manufacturer,
418
+ model: accessory.model,
419
+ firmwareRevision: accessory.firmwareRevision,
420
+ serialNumber: accessory.serialNumber || uniqueId, // Use uniqueId as fallback serial number
421
+ debugModeEnabled: this.bridgeOptions.debugModeEnabled,
422
+ externalAccessory: true, // external accessory, so added before server runs
423
+ networkInterfaces,
424
+ });
425
+ // Start the Matter server (but don't run it yet due to externalAccessory mode)
426
+ await matterServer.start();
427
+ // Get plugin identifier from accessory
428
+ const pluginIdentifier = accessory._associatedPlugin || 'unknown';
429
+ // Register the accessory to this dedicated server
430
+ await matterServer.registerPlatformAccessories(pluginIdentifier, 'ExternalMatter', [accessory]);
431
+ // Now run the server with the device already attached (required for external accessories)
432
+ await matterServer.runServer();
433
+ // Store the server instance
434
+ this.externalMatterServers.set(accessory.uuid, matterServer);
435
+ Logger.internal.info(`✓ External Matter accessory published: ${accessory.displayName} on port ${port}`);
436
+ // Log commissioning info
437
+ const commissioningInfo = matterServer.getCommissioningInfo();
438
+ if (commissioningInfo.qrCode && commissioningInfo.manualPairingCode) {
439
+ Logger.internal.info(`📱 Commissioning codes for ${accessory.displayName}:`);
440
+ Logger.internal.info(` QR Code: ${commissioningInfo.qrCode}`);
441
+ Logger.internal.info(` Manual Code: ${commissioningInfo.manualPairingCode}`);
442
+ }
443
+ }
444
+ catch (error) {
445
+ Logger.internal.error(`Failed to publish external Matter accessory ${accessory.displayName}:`, error);
446
+ }
447
+ }
448
+ }
449
+ /**
450
+ * Handle metadata request from parent process
451
+ * Sends unified HAP+Matter status
452
+ */
453
+ handleMetadataRequest() {
454
+ // Send unified status with both HAP and Matter information
455
+ this.sendPairedStatusEvent();
456
+ }
457
+ shutdown() {
458
+ this.bridgeService.teardown();
459
+ // Stop main Matter server if it was initialized
460
+ if (this.matterServer && typeof this.matterServer.stop === 'function') {
461
+ Logger.internal.debug('Stopping Matter server');
462
+ this.matterServer.stop().catch((error) => {
463
+ Logger.internal.error('Error stopping Matter server:', error);
464
+ });
465
+ }
466
+ // Stop all external Matter servers
467
+ for (const [uuid, matterServer] of this.externalMatterServers) {
468
+ Logger.internal.debug(`Stopping external Matter server for ${uuid}`);
469
+ matterServer.stop().catch((error) => {
470
+ Logger.internal.error(`Error stopping external Matter server for ${uuid}:`, error);
471
+ });
472
+ }
473
+ this.externalMatterServers.clear();
474
+ }
475
+ }
476
+ /**
477
+ * Start Self
478
+ */
479
+ const childPluginFork = new ChildBridgeFork();
480
+ /**
481
+ * Handle incoming IPC messages from the parent Homebridge process
482
+ */
483
+ process.on('message', (message) => {
484
+ if (typeof message !== 'object' || !message.id) {
485
+ return;
486
+ }
487
+ switch (message.id) {
488
+ case "load" /* ChildProcessMessageEventType.LOAD */: {
489
+ childPluginFork.loadPlugin(message.data);
490
+ break;
491
+ }
492
+ case "start" /* ChildProcessMessageEventType.START */: {
493
+ childPluginFork.startBridge();
494
+ break;
495
+ }
496
+ case "portAllocated" /* ChildProcessMessageEventType.PORT_ALLOCATED */: {
497
+ childPluginFork.handleExternalResponse(message.data);
498
+ break;
499
+ }
500
+ }
501
+ });
502
+ /**
503
+ * Handle the sigterm shutdown signals
504
+ */
505
+ let shuttingDown = false;
506
+ function signalHandler(signal, signalNum) {
507
+ if (shuttingDown) {
508
+ return;
509
+ }
510
+ shuttingDown = true;
511
+ Logger.internal.info('Got %s, shutting down child bridge process...', signal);
512
+ try {
513
+ childPluginFork.shutdown();
514
+ }
515
+ catch (error) {
516
+ // do nothing
517
+ }
518
+ setTimeout(() => process.exit(128 + signalNum), 5000);
519
+ }
520
+ process.on('SIGINT', signalHandler.bind(undefined, 'SIGINT', 2));
521
+ process.on('SIGTERM', signalHandler.bind(undefined, 'SIGTERM', 15));
522
+ /**
523
+ * Ensure orphaned processes are cleaned up
524
+ */
525
+ setInterval(() => {
526
+ if (!process.connected) {
527
+ Logger.internal.info('Parent process not connected, terminating process...');
528
+ process.exit(1);
529
+ }
530
+ }, 5000);
531
+ //# sourceMappingURL=childBridgeFork.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"childBridgeFork.js","sourceRoot":"","sources":["../src/childBridgeFork.ts"],"names":[],"mappings":"AAAA,mBAAmB;AAsBnB,OAAO,OAAO,MAAM,cAAc,CAAA;AAElC,OAAO,EAAuB,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5D,OAAO,EAAE,aAAa,EAAgC,MAAM,UAAU,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAA;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,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CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,aAAa;IACf,CAAC;IAED,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,EAAE,IAAI,CAAC,CAAA;AACvD,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAA;AAChE,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC,CAAA;AAEnE;;GAEG;AACH,WAAW,CAAC,GAAG,EAAE;IACf,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACvB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAA;QAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC,EAAE,IAAI,CAAC,CAAA"}
@@ -1,10 +1,12 @@
1
- import { MacAddress } from "hap-nodejs";
2
- import { HomebridgeAPI, PluginType } from "./api";
3
- import { AccessoryConfig, BridgeConfiguration, BridgeOptions, HomebridgeConfig, PlatformConfig } from "./bridgeService";
4
- import { ExternalPortService } from "./externalPortService";
5
- import { IpcService } from "./ipcService";
6
- import { Plugin } from "./plugin";
7
- import { HomebridgeOptions } from "./server";
1
+ import type { MacAddress } from 'hap-nodejs';
2
+ import type { HomebridgeAPI } from './api.js';
3
+ import type { AccessoryConfig, BridgeConfiguration, BridgeOptions, HomebridgeConfig, PlatformConfig } from './bridgeService.js';
4
+ import type { ExternalPortService } from './externalPortService.js';
5
+ import type { IpcService } from './ipcService.js';
6
+ import type { MatterConfig } from './matter/index.js';
7
+ import type { Plugin } from './plugin.js';
8
+ import type { HomebridgeOptions } from './server.js';
9
+ import { PluginType } from './api.js';
8
10
  export declare const enum ChildProcessMessageEventType {
9
11
  /**
10
12
  * Sent from the child process when it is ready to accept config
@@ -71,6 +73,7 @@ export interface ChildProcessPluginLoadedEventData {
71
73
  }
72
74
  export interface ChildProcessPortRequestEventData {
73
75
  username: MacAddress;
76
+ portType?: 'hap' | 'matter';
74
77
  }
75
78
  export interface ChildProcessPortAllocatedEventData {
76
79
  username: MacAddress;
@@ -80,17 +83,34 @@ export interface ChildBridgePairedStatusEventData {
80
83
  paired: boolean | null;
81
84
  setupUri: string | null;
82
85
  }
86
+ /**
87
+ * Child bridge metadata
88
+ *
89
+ * Contains all metadata for a child bridge, including HAP properties
90
+ * like paired status, setupUri, and pin.
91
+ *
92
+ * When Matter is enabled (_bridge.matter is configured), this interface
93
+ * also includes Matter commissioning information for unified status reporting.
94
+ */
83
95
  export interface ChildMetadata {
84
96
  status: ChildBridgeStatus;
85
97
  paired?: boolean | null;
86
98
  setupUri?: string | null;
87
99
  username: MacAddress;
100
+ port?: number;
88
101
  pin: string;
89
102
  name: string;
90
103
  plugin: string;
91
104
  identifier: string;
92
105
  manuallyStopped: boolean;
93
106
  pid?: number;
107
+ matterConfig?: MatterConfig;
108
+ matterIdentifier?: string;
109
+ matterSetupUri?: string;
110
+ matterPin?: string;
111
+ matterSerialNumber?: string;
112
+ matterCommissioned?: boolean;
113
+ matterDeviceCount?: number;
94
114
  }
95
115
  /**
96
116
  * Manages the child processes of platforms/accessories being exposed as separate forked bridges.
@@ -114,9 +134,12 @@ export declare class ChildBridgeService {
114
134
  private pairedStatus;
115
135
  private manuallyStopped;
116
136
  private setupUri;
137
+ private matterCommissioningInfo?;
117
138
  private pluginConfig;
118
139
  private log;
119
140
  private displayName?;
141
+ private restartCount;
142
+ private readonly maxRestarts;
120
143
  constructor(type: PluginType, identifier: string, plugin: Plugin, bridgeConfig: BridgeConfiguration, homebridgeConfig: HomebridgeConfig, homebridgeOptions: HomebridgeOptions, api: HomebridgeAPI, ipcService: IpcService, externalPortService: ExternalPortService);
121
144
  /**
122
145
  * Start the child bridge service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