homebridge
    Preparing search index...

    Interface API

    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;
    }
    Index

    Properties

    hap: __module
    hapLegacyTypes: __module
    isMatterAvailable: () => boolean

    Check if Matter is available in this version of Homebridge

    Type Declaration

      • (): boolean
      • Returns boolean

        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

    Type Declaration

      • (): boolean
      • Returns boolean

        true if Matter is enabled

    matter?: 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 disabled
    if (api.isMatterEnabled()) {
    api.matter!.registerPlatformAccessories(...) // explicit guard
    }
    // Register a Matter accessory
    api.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 state
    await api.matter?.updateAccessoryState(uuid, 'onOff', { onOff: true })
    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

    The current homebridge semver version.

    unregisterPlatformAccessories: (
        pluginIdentifier: string,
        platformName: string,
        accessories: PlatformAccessory<UnknownContext>[],
    ) => void
    updatePlatformAccessories: (
        accessories: PlatformAccessory<UnknownContext>[],
    ) => void
    user: typeof User
    version: 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 true