API Reference

Note

This is a summary of the most commonly used API methods you will need when creating plugins. It is by no means comprehensive.

API.version

API.version: number

Returns the current Homebridge API version. Note that this is different from the Homebridge package version.

API.on

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

When this event is fired it means Homebridge has restored all cached accessories from disk. Dynamic Platform plugins should only register new accessories after this event has fired in order to ensure they weren't already added to Homebridge. This event can also be used to start discovery of new accessories.

API.user.storagePath

User.storagePath(): string

Returns the path to the Homebridge storage folder.

class ExamplePlatformPlugin {
  constructor(log, config, api) {
    const storagePath = api.user.storagePath();
  }
}

API.user.configPath

User.configPath(): string

Returns the path to the Homebridge config.json file.

class ExamplePlatformPlugin {
  constructor(log, config, api) {
    const configPath = api.user.configPath();
  }
}