Back to Homebridge

Interface API

docs/interfaces/API.html

1.11.49.0 KB
Original Source
  • API

Interface API

Export types for basically everything but the actual API implementation

interface API {
hap: __module;
hapLegacyTypes: __module;
platformAccessory: typeof PlatformAccessory;
serverVersion: string;
user: typeof User;
version: number;
on(event: "didFinishLaunching", listener: () => void): this;
on(event: "shutdown", listener: () => void): this;
publishCameraAccessories(
pluginIdentifier: string,
accessories: PlatformAccessory<UnknownContext>[],
): void;
publishExternalAccessories(
pluginIdentifier: string,
accessories: PlatformAccessory<UnknownContext>[],
): void;
registerAccessory(
accessoryName: string,
constructor: AccessoryPluginConstructor,
): void;
registerAccessory(
pluginIdentifier: string,
accessoryName: string,
constructor: AccessoryPluginConstructor,
): void;
registerPlatform<Config extends PlatformConfig>(
platformName: string,
constructor: PlatformPluginConstructor<Config>,
): void;
registerPlatform<Config extends PlatformConfig>(
pluginIdentifier: string,
platformName: string,
constructor: PlatformPluginConstructor<Config>,
): void;
registerPlatformAccessories(
pluginIdentifier: string,
platformName: string,
accessories: PlatformAccessory<UnknownContext>[],
): void;
unregisterPlatformAccessories(
pluginIdentifier: string,
platformName: string,
accessories: PlatformAccessory<UnknownContext>[],
): void;
updatePlatformAccessories(
accessories: PlatformAccessory<UnknownContext>[],
): void;
versionGreaterOrEqual(version: string): boolean;
}

Index

Properties

haphapLegacyTypesplatformAccessoryserverVersionuserversion

Methods

onpublishCameraAccessoriespublishExternalAccessoriesregisterAccessoryregisterPlatformregisterPlatformAccessoriesunregisterPlatformAccessoriesupdatePlatformAccessoriesversionGreaterOrEqual

Properties

Readonlyhap

hap: __module

ReadonlyhapLegacyTypes

hapLegacyTypes: __module

ReadonlyplatformAccessory

platformAccessory: typeof PlatformAccessory

ReadonlyserverVersion

serverVersion: string

The current homebridge semver version.

Readonlyuser

user: typeof User

Readonlyversion

version: number

The homebridge API version as a floating point number.

Methods

on

on(event: "didFinishLaunching", listener: () => void): this

Parameters

  • event: "didFinishLaunching"
  • listener: () => void

Returns this

on(event: "shutdown", listener: () => void): this

Parameters

  • event: "shutdown"
  • listener: () => void

Returns this

publishCameraAccessories

publishCameraAccessories(
pluginIdentifier: string,
accessories: PlatformAccessory<UnknownContext>[],
): void

Parameters

Returns void

Deprecated

use publishExternalAccessories directly to publish a standalone Accessory

publishExternalAccessories

publishExternalAccessories(
pluginIdentifier: string,
accessories: PlatformAccessory<UnknownContext>[],
): void

Parameters

Returns void

registerAccessory

registerAccessory(
accessoryName: string,
constructor: AccessoryPluginConstructor,
): void

Parameters

Returns void

registerAccessory(
pluginIdentifier: string,
accessoryName: string,
constructor: AccessoryPluginConstructor,
): void

Parameters

Returns void

registerPlatform

registerPlatform<Config extends PlatformConfig>(
platformName: string,
constructor: PlatformPluginConstructor<Config>,
): void

Type Parameters

Parameters

Returns void

registerPlatform<Config extends PlatformConfig>(
pluginIdentifier: string,
platformName: string,
constructor: PlatformPluginConstructor<Config>,
): void

Type Parameters

Parameters

Returns void

registerPlatformAccessories

registerPlatformAccessories(
pluginIdentifier: string,
platformName: string,
accessories: PlatformAccessory<UnknownContext>[],
): void

Parameters

Returns void

unregisterPlatformAccessories

unregisterPlatformAccessories(
pluginIdentifier: string,
platformName: string,
accessories: PlatformAccessory<UnknownContext>[],
): void

Parameters

Returns void

updatePlatformAccessories

updatePlatformAccessories(
accessories: PlatformAccessory<UnknownContext>[],
): void

Parameters

Returns void

versionGreaterOrEqual

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

Parameters

  • version: string

Returns boolean

Settings

Member Visibility

  • Inherited

ThemeOSLightDark

On This Page

Properties haphapLegacyTypesplatformAccessoryserverVersionuserversion Methods onpublishCameraAccessoriespublishExternalAccessoriesregisterAccessoryregisterPlatformregisterPlatformAccessoriesunregisterPlatformAccessoriesupdatePlatformAccessoriesversionGreaterOrEqual