docs/interfaces/API.html
Export types for basically everything but the actual API implementation
interface API {
hap: __module;
hapLegacyTypes: __module;
isMatterAvailable: () => boolean;
isMatterEnabled: () => boolean;
matter?: MatterAPI;
on: (event: "didFinishLaunching", listener: () => void) => this & (
event: "shutdown",
listener: () => void,
) => this;
platformAccessory: typeof PlatformAccessory;
publishExternalAccessories: (
pluginIdentifier: string,
accessories: PlatformAccessory<UnknownContext>[],
) => void;
registerAccessory: (
accessoryName: string,
constructor: AccessoryPluginConstructor,
) => void & (
pluginIdentifier: string,
accessoryName: string,
constructor: AccessoryPluginConstructor,
) => void;
registerPlatform: <Config extends PlatformConfig>(
platformName: string,
constructor: PlatformPluginConstructor<Config>,
) => void & <Config extends PlatformConfig>(
pluginIdentifier: string,
platformName: string,
constructor: PlatformPluginConstructor<Config>,
) => void;
registerPlatformAccessories: (
pluginIdentifier: string,
platformName: string,
accessories: PlatformAccessory<UnknownContext>[],
) => void;
serverVersion: string;
unregisterPlatformAccessories: (
pluginIdentifier: string,
platformName: string,
accessories: PlatformAccessory<UnknownContext>[],
) => void;
updatePlatformAccessories: (
accessories: PlatformAccessory<UnknownContext>[],
) => void;
user: typeof User;
version: number;
versionGreaterOrEqual: (version: string) => boolean;
}
haphapLegacyTypesisMatterAvailableisMatterEnabledmatter?onplatformAccessorypublishExternalAccessoriesregisterAccessoryregisterPlatformregisterPlatformAccessoriesserverVersionunregisterPlatformAccessoriesupdatePlatformAccessoriesuserversionversionGreaterOrEqual
Readonlyhaphap: __module
ReadonlyhapLegacyTypeshapLegacyTypes: __module
isMatterAvailable: () => boolean
Check if Matter is available in this version of Homebridge
true if Homebridge version is >= 2.0.0-alpha.0
isMatterEnabled: () => boolean
Check if Matter is enabled for this bridge For main bridge: returns true if Matter is enabled in bridge.matter config For child bridge: returns true if Matter is enabled in the _bridge.matter config
true if Matter is enabled
Optional Readonlymattermatter?: MatterAPI
Matter Protocol API.
Defined when Matter is configured for this bridge (i.e. when api.isMatterEnabled() returns true), undefined otherwise. Loaded automatically before plugins run on Matter-enabled bridges, so plugins can access it from their initializer, platform/accessory constructor, or didFinishLaunching handler.
Safe access patterns:
api.matter?.registerPlatformAccessories(...) // defensive, no-ops when disabledif (api.isMatterEnabled()) { api.matter!.registerPlatformAccessories(...) // explicit guard}Copy
// Register a Matter accessoryapi.matter?.registerPlatformAccessories('homebridge-example', 'Example', [{ UUID: api.hap.uuid.generate('my-light'), displayName: 'Living Room Light', deviceType: api.matter!.deviceTypes.OnOffLight, manufacturer: 'Example', model: 'Example Light', serialNumber: 'EX-001', clusters: { onOff: { onOff: false } },}])// Update stateawait api.matter?.updateAccessoryState(uuid, 'onOff', { onOff: true })Copy
on: (event: "didFinishLaunching", listener: () => void) => this & (
event: "shutdown",
listener: () => void,
) => this
ReadonlyplatformAccessoryplatformAccessory: typeof PlatformAccessory
publishExternalAccessories: (
pluginIdentifier: string,
accessories: PlatformAccessory<UnknownContext>[],
) => void
registerAccessory: (
accessoryName: string,
constructor: AccessoryPluginConstructor,
) => void & (
pluginIdentifier: string,
accessoryName: string,
constructor: AccessoryPluginConstructor,
) => void
registerPlatform: <Config extends PlatformConfig>(
platformName: string,
constructor: PlatformPluginConstructor<Config>,
) => void & <Config extends PlatformConfig>(
pluginIdentifier: string,
platformName: string,
constructor: PlatformPluginConstructor<Config>,
) => void
registerPlatformAccessories: (
pluginIdentifier: string,
platformName: string,
accessories: PlatformAccessory<UnknownContext>[],
) => void
ReadonlyserverVersionserverVersion: string
The current homebridge semver version.
unregisterPlatformAccessories: (
pluginIdentifier: string,
platformName: string,
accessories: PlatformAccessory<UnknownContext>[],
) => void
updatePlatformAccessories: (
accessories: PlatformAccessory<UnknownContext>[],
) => void
Readonlyuseruser: typeof User
Readonlyversionversion: number
The homebridge API version as a floating point number.
versionGreaterOrEqual: (version: string) => boolean
Returns true if the current running homebridge version is greater or equal to the passed version string.
Example:
We assume the homebridge version 1.3.0-beta.12 (serverVersion) and the following example calls below
versionGreaterOrEqual("1.2.0"); // will return true versionGreaterOrEqual("1.3.0"); // will return false (the RELEASE version 1.3.0 is bigger than the BETA version 1.3.0-beta.12) versionGreaterOrEqual("1.3.0-beta.8); // will return trueCopy
Member Visibility
ThemeOSLightDark
Properties haphapLegacyTypesisMatterAvailableisMatterEnabledmatteronplatformAccessorypublishExternalAccessoriesregisterAccessoryregisterPlatformregisterPlatformAccessoriesserverVersionunregisterPlatformAccessoriesupdatePlatformAccessoriesuserversionversionGreaterOrEqual