homebridge
Version:
HomeKit support for the impatient
137 lines • 5.89 kB
TypeScript
/**
* Child Bridge Matter Manager
*
* Manages Matter server lifecycle and accessories for child bridges.
* This class extracts Matter-specific logic from childBridgeFork.ts to minimize changes to core files.
*/
import type { HomebridgeAPI } from '../api.js';
import type { BridgeConfiguration, BridgeOptions } from '../bridgeService.js';
import type { ChildBridgeExternalPortService } from '../externalPortService.js';
import type { AccessoryInfo } from './managerTypes.js';
import type { InternalMatterAccessory } from './types.js';
import { PluginManager } from '../pluginManager.js';
import { BaseMatterManager } from './BaseMatterManager.js';
/**
* Matter status information for child bridge IPC communication
*/
export interface ChildBridgeMatterStatusInfo {
qrCode?: string;
manualPairingCode?: string;
serialNumber?: string;
commissioned: boolean;
deviceCount: number;
}
/**
* Manages Matter server and accessories for a child bridge
*/
export declare class ChildBridgeMatterManager extends BaseMatterManager {
private readonly bridgeConfig;
private readonly bridgeOptions;
private readonly api;
private readonly externalPortService;
private readonly matterConfig?;
private matterSerialNumber?;
constructor(bridgeConfig: BridgeConfiguration, bridgeOptions: BridgeOptions, api: HomebridgeAPI, externalPortService: ChildBridgeExternalPortService, pluginManager: PluginManager);
protected releaseExternalMatterPort(uniqueId: string): void;
private readonly _onPublishExternalMatterAccessories;
private readonly _onRegisterMatterPlatformAccessories;
private readonly _onUpdateMatterPlatformAccessories;
private readonly _onUnregisterMatterPlatformAccessories;
private readonly _onUnregisterExternalMatterAccessories;
private readonly _onUpdateMatterAccessoryState;
private readonly _onMatterServerStateChange;
private _onCommissioningStatusChanged?;
private readonly _onRegisterMatterPlatformAccessoriesDropped;
private readonly _onUnregisterMatterPlatformAccessoriesDropped;
private externalsOnlyMode;
/**
* Initialize Matter server for child bridge. Three states:
*
* 1. Disabled (matter absent, or `enabled: false` without `externalsOnly`) → return early.
* 2. externalsOnly mode (`enabled: false` + `externalsOnly: true`) → attach
* listeners for external publishing AND debug-log drop stubs for bridged
* matter events, but do NOT start the bridge MatterServer.
* 3. Normal (`enabled !== false`) → full setup including server startup.
*
* @param onCommissioningChanged Optional callback when commissioning status changes
*/
initialize(onCommissioningChanged?: () => void): Promise<void>;
/**
* Start Matter server for child bridge
*/
private startMatterServer;
/**
* Set up all Matter API event listeners (external + bridged). Used in
* normal mode where the bridge MatterServer is running.
*/
private setupEventListeners;
/**
* Set up only the external-accessory listeners. These do not need a running
* bridge MatterServer — each external creates its own dedicated server.
* Used in normal mode (via setupEventListeners) and in externalsOnly mode.
*/
private setupExternalEventListeners;
/**
* Set up bridged-accessory listeners that require the bridge MatterServer.
* Used in normal mode only.
*/
private setupBridgedEventListeners;
/**
* Attach drop-stub listeners for bridged Matter events in externalsOnly
* mode. Each stub logs at debug level and returns without doing anything,
* so plugin authors who misconfigure a bridge get a breadcrumb without
* noisy warn-level output.
*/
private setupBridgedDropStubs;
/**
* Handle external Matter accessories - each gets its own dedicated Matter server
* This is required for devices like Robotic Vacuum Cleaners that Apple Home
* requires to be on their own bridge.
*/
handlePublishExternalAccessories(accessories: InternalMatterAccessory[], registrationId: string): Promise<void>;
/**
* Get Matter status information for IPC communication
* Returns undefined if Matter is not enabled for this child bridge
*/
getMatterStatusInfo(): ChildBridgeMatterStatusInfo | undefined;
/**
* Check if Matter is enabled for this child bridge
*/
isMatterEnabled(): boolean;
/**
* Whether this child bridge has Matter active in any form that can serve UI
* requests (control / list / accessory-info / state monitoring). This is true
* when the bridge Matter server is running OR when in externalsOnly mode,
* where external accessories publish via their own per-accessory servers even
* though the bridge node never starts. The message handler must gate on this
* (not `isMatterEnabled()`, which is false in externalsOnly) so external
* accessories on an externalsOnly child remain controllable and listable.
*/
hasActiveMatter(): boolean;
/**
* Enable state monitoring on all Matter servers
* Override to add bridge-specific logging
*/
enableStateMonitoring(): void;
/**
* Disable state monitoring on all Matter servers
* Override to add bridge-specific logging
*/
disableStateMonitoring(): void;
/**
* Collect all Matter accessories for UI display
*/
collectAllAccessories(): AccessoryInfo[];
/**
* Get detailed info for a specific Matter accessory
*
* @param uuid - Accessory UUID
* @returns Accessory info or undefined if not found
*/
getAccessoryInfo(uuid: string): AccessoryInfo | undefined;
/**
* Teardown Matter servers
*/
teardown(): Promise<void>;
}
//# sourceMappingURL=ChildBridgeMatterManager.d.ts.map