homebridge

  • Version 1.8.4
  • Published
  • 339 kB
  • 7 dependencies
  • Apache-2.0 license

Install

npm i homebridge
yarn add homebridge
pnpm add homebridge

Overview

HomeKit support for the impatient

Index

Classes

Interfaces

Enums

Type Aliases

Classes

class Logger

class Logger {}
  • Logger class

constructor

constructor(prefix?: string);

    property internal

    static readonly internal: Logger;

      property prefix

      readonly prefix?: string;

        method debug

        debug: (message: string, ...parameters: any[]) => void;

          method error

          error: (message: string, ...parameters: any[]) => void;

            method forceColor

            static forceColor: () => void;
            • Forces color in logging output, even if it seems like color is unsupported.

            method info

            info: (message: string, ...parameters: any[]) => void;

              method log

              log: (level: LogLevel, message: string, ...parameters: any[]) => void;

                method setDebugEnabled

                static setDebugEnabled: (enabled?: boolean) => void;
                • Turns on debug level logging. Off by default.

                  Parameter enabled

                method setTimestampEnabled

                static setTimestampEnabled: (enabled?: boolean) => void;
                • Turns on inclusion of timestamps in log messages. On by default.

                  Parameter enabled

                method success

                success: (message: string, ...parameters: any[]) => void;

                  method warn

                  warn: (message: string, ...parameters: any[]) => void;

                    method withPrefix

                    static withPrefix: (prefix: string) => Logging;
                    • Creates a new Logging device with a specified prefix.

                      Parameter prefix

                      the prefix of the logger

                    class PlatformAccessory

                    class PlatformAccessory<
                    T extends UnknownContext = UnknownContext
                    > extends EventEmitter {}

                      constructor

                      constructor(displayName: string, uuid: string, category?: Categories);

                        property category

                        category: Categories;

                          property context

                          context: UnknownContext;
                          • This is a way for Plugin developers to store custom data with their accessory

                          property displayName

                          displayName: string;

                            property reachable

                            reachable: boolean;
                            • Deprecated

                              reachability has no effect and isn't supported anymore

                            property services

                            services: Service[];

                              property UUID

                              UUID: string;

                                method addService

                                addService: {
                                (service: Service): Service;
                                <S extends any>(
                                serviceConstructor: S,
                                ...constructorArgs: ConstructorArgs<S>
                                ): Service;
                                };

                                  method configureCameraSource

                                  configureCameraSource: (cameraSource: LegacyCameraSource) => CameraController;

                                  method configureController

                                  configureController: (controller: Controller | ControllerConstructor) => void;

                                  method deserialize

                                  static deserialize: (json: SerializedPlatformAccessory) => PlatformAccessory;

                                    method getService

                                    getService: <T extends WithUUID<any>>(name: string | T) => Service | undefined;

                                      method getServiceById

                                      getServiceById: <T extends WithUUID<any>>(
                                      uuid: string | T,
                                      subType: string
                                      ) => Service | undefined;

                                        method getServiceByUUIDAndSubType

                                        getServiceByUUIDAndSubType: <T extends WithUUID<any>>(
                                        uuid: string | T,
                                        subType: string
                                        ) => Service | undefined;

                                        method removeController

                                        removeController: (controller: Controller) => void;

                                        method removeService

                                        removeService: (service: Service) => void;

                                          method serialize

                                          static serialize: (accessory: PlatformAccessory) => SerializedPlatformAccessory;

                                            method updateReachability

                                            updateReachability: (reachable: boolean) => void;
                                            • Parameter reachable

                                              Deprecated

                                              reachability has no effect and isn't supported anymore

                                            class User

                                            class User {}
                                            • Manages user settings and storage locations.

                                            method cachedAccessoryPath

                                            static cachedAccessoryPath: () => string;

                                              method configPath

                                              static configPath: () => string;

                                                method persistPath

                                                static persistPath: () => string;

                                                  method setStoragePath

                                                  static setStoragePath: (...storagePathSegments: string[]) => void;

                                                    method storagePath

                                                    static storagePath: () => string;

                                                      Interfaces

                                                      interface AccessoryConfig

                                                      interface AccessoryConfig extends Record<string, any> {}

                                                        property accessory

                                                        accessory: AccessoryName | AccessoryIdentifier;

                                                          property name

                                                          name: string;

                                                            property uuid_base

                                                            uuid_base?: string;

                                                              interface AccessoryPlugin

                                                              interface AccessoryPlugin {}

                                                                method getControllers

                                                                getControllers: () => Controller[];
                                                                • This method will be called once on startup, to query all controllers to be exposed by the Accessory. It is optional to implement.

                                                                  This includes controllers like the RemoteController or the CameraController. Any necessary controller specific setup should have been done when returning the array. In most cases the plugin will only return an array of the size 1.

                                                                  In the case that the Plugin does not add any additional services (returned by getServices) the method getServices must be defined in any way and should just return an empty array.

                                                                  Returns

                                                                  {Controller[]} controllers - returned controllers will be configured for the Accessory

                                                                method getServices

                                                                getServices: () => Service[];
                                                                • This method will be called once on startup, to query all services to be exposed by the Accessory. All event handlers for characteristics should be set up before the array is returned.

                                                                  Returns

                                                                  {Service[]} services - returned services will be added to the Accessory

                                                                method identify

                                                                identify: () => void;
                                                                • Optional method which will be called if a 'identify' of an Accessory is requested by HomeKit.

                                                                interface AccessoryPluginConstructor

                                                                interface AccessoryPluginConstructor {}

                                                                  construct signature

                                                                  new (logger: Logging, config: AccessoryConfig, api: API): AccessoryPlugin;

                                                                    interface API

                                                                    interface API {}

                                                                      property hap

                                                                      readonly hap: HAP;

                                                                        property hapLegacyTypes

                                                                        readonly hapLegacyTypes: HAPLegacyTypes;

                                                                          property platformAccessory

                                                                          readonly platformAccessory: typeof PlatformAccessory;

                                                                            property serverVersion

                                                                            readonly serverVersion: string;
                                                                            • The current homebridge semver version.

                                                                            property user

                                                                            readonly user: typeof User;

                                                                              property version

                                                                              readonly version: number;
                                                                              • The homebridge API version as a floating point number.

                                                                              method on

                                                                              on: {
                                                                              (event: 'didFinishLaunching', listener: () => void): this;
                                                                              (event: 'shutdown', listener: () => void): this;
                                                                              };

                                                                                method publishCameraAccessories

                                                                                publishCameraAccessories: (
                                                                                pluginIdentifier: PluginIdentifier,
                                                                                accessories: PlatformAccessory[]
                                                                                ) => void;

                                                                                method publishExternalAccessories

                                                                                publishExternalAccessories: (
                                                                                pluginIdentifier: PluginIdentifier,
                                                                                accessories: PlatformAccessory[]
                                                                                ) => void;

                                                                                  method registerAccessory

                                                                                  registerAccessory: {
                                                                                  (
                                                                                  accessoryName: AccessoryName,
                                                                                  constructor: AccessoryPluginConstructor
                                                                                  ): void;
                                                                                  (
                                                                                  pluginIdentifier: string,
                                                                                  accessoryName: string,
                                                                                  constructor: AccessoryPluginConstructor
                                                                                  ): void;
                                                                                  };

                                                                                    method registerPlatform

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

                                                                                      method registerPlatformAccessories

                                                                                      registerPlatformAccessories: (
                                                                                      pluginIdentifier: PluginIdentifier,
                                                                                      platformName: PlatformName,
                                                                                      accessories: PlatformAccessory[]
                                                                                      ) => void;

                                                                                        method unregisterPlatformAccessories

                                                                                        unregisterPlatformAccessories: (
                                                                                        pluginIdentifier: PluginIdentifier,
                                                                                        platformName: PlatformName,
                                                                                        accessories: PlatformAccessory[]
                                                                                        ) => void;

                                                                                          method updatePlatformAccessories

                                                                                          updatePlatformAccessories: (accessories: PlatformAccessory[]) => void;

                                                                                            method 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 true

                                                                                              Parameter version

                                                                                            interface BridgeConfiguration

                                                                                            interface BridgeConfiguration {}

                                                                                              property advertiser

                                                                                              advertiser?: MDNSAdvertiser;

                                                                                                property bind

                                                                                                bind?: (InterfaceName | IPAddress) | (InterfaceName | IPAddress)[];

                                                                                                  property disableIpc

                                                                                                  disableIpc?: boolean;

                                                                                                    property env

                                                                                                    env?: {
                                                                                                    DEBUG?: string;
                                                                                                    NODE_OPTIONS?: string;
                                                                                                    };

                                                                                                      property firmwareRevision

                                                                                                      firmwareRevision?: string;

                                                                                                        property manufacturer

                                                                                                        manufacturer?: string;

                                                                                                          property model

                                                                                                          model?: string;

                                                                                                            property name

                                                                                                            name: string;

                                                                                                              property pin

                                                                                                              pin: string;

                                                                                                                property port

                                                                                                                port?: number;

                                                                                                                  property setupID

                                                                                                                  setupID?: string[4];

                                                                                                                    property username

                                                                                                                    username: MacAddress;

                                                                                                                      interface DynamicPlatformPlugin

                                                                                                                      interface DynamicPlatformPlugin extends PlatformPlugin {}

                                                                                                                      method configureAccessory

                                                                                                                      configureAccessory: (accessory: PlatformAccessory) => void;
                                                                                                                      • This method is called for every PlatformAccessory, which is recreated from disk on startup. It should be used to properly initialize the Accessory and setup all event handlers for all services and their characteristics.

                                                                                                                        Parameter accessory

                                                                                                                        which needs to be configured

                                                                                                                      interface ExternalPortsConfiguration

                                                                                                                      interface ExternalPortsConfiguration {}

                                                                                                                        property end

                                                                                                                        end: number;

                                                                                                                          property start

                                                                                                                          start: number;

                                                                                                                            interface HomebridgeConfig

                                                                                                                            interface HomebridgeConfig {}

                                                                                                                              property accessories

                                                                                                                              accessories: AccessoryConfig[];

                                                                                                                                property bridge

                                                                                                                                bridge: BridgeConfiguration;

                                                                                                                                  property disabledPlugins

                                                                                                                                  disabledPlugins?: PluginIdentifier[];
                                                                                                                                  • Array of disabled plugins. Unlike the plugins[] config which prevents plugins from being initialised at all, disabled plugins still have their alias loaded, so we can match config blocks of disabled plugins and show an appropriate message in the logs.

                                                                                                                                  property mdns

                                                                                                                                  mdns?: any;
                                                                                                                                  • Deprecated

                                                                                                                                  property platforms

                                                                                                                                  platforms: PlatformConfig[];

                                                                                                                                    property plugins

                                                                                                                                    plugins?: PluginIdentifier[];

                                                                                                                                      property ports

                                                                                                                                      ports?: ExternalPortsConfiguration;

                                                                                                                                        interface HomebridgeOptions

                                                                                                                                        interface HomebridgeOptions {}

                                                                                                                                          property customPluginPath

                                                                                                                                          customPluginPath?: string;

                                                                                                                                            property customStoragePath

                                                                                                                                            customStoragePath?: string;

                                                                                                                                              property debugModeEnabled

                                                                                                                                              debugModeEnabled?: boolean;

                                                                                                                                                property forceColourLogging

                                                                                                                                                forceColourLogging?: boolean;

                                                                                                                                                  property hideQRCode

                                                                                                                                                  hideQRCode?: boolean;

                                                                                                                                                    property insecureAccess

                                                                                                                                                    insecureAccess?: boolean;

                                                                                                                                                      property keepOrphanedCachedAccessories

                                                                                                                                                      keepOrphanedCachedAccessories?: boolean;

                                                                                                                                                        property noLogTimestamps

                                                                                                                                                        noLogTimestamps?: boolean;

                                                                                                                                                          property strictPluginResolution

                                                                                                                                                          strictPluginResolution?: boolean;

                                                                                                                                                            interface IndependentPlatformPlugin

                                                                                                                                                            interface IndependentPlatformPlugin extends PlatformPlugin {}
                                                                                                                                                            • Platform that does not aim to add any accessories to the main bridge accessory. This platform should be used if for example a plugin aims to only expose external accessories. It should also be used when the platform doesn't intend to expose any accessories at all, like plugins providing a UI for homebridge.

                                                                                                                                                            interface Logging

                                                                                                                                                            interface Logging {}
                                                                                                                                                            • Represents a logging device which can be used directly as a function (for INFO logging) but also has dedicated logging functions for respective logging levels.

                                                                                                                                                            property prefix

                                                                                                                                                            prefix: string;

                                                                                                                                                              method debug

                                                                                                                                                              debug: (message: string, ...parameters: any[]) => void;

                                                                                                                                                                method error

                                                                                                                                                                error: (message: string, ...parameters: any[]) => void;

                                                                                                                                                                  method info

                                                                                                                                                                  info: (message: string, ...parameters: any[]) => void;

                                                                                                                                                                    method log

                                                                                                                                                                    log: (level: LogLevel, message: string, ...parameters: any[]) => void;

                                                                                                                                                                      method success

                                                                                                                                                                      success: (message: string, ...parameters: any[]) => void;

                                                                                                                                                                        method warn

                                                                                                                                                                        warn: (message: string, ...parameters: any[]) => void;

                                                                                                                                                                          call signature

                                                                                                                                                                          (message: string, ...parameters: any[]): void;

                                                                                                                                                                            interface PlatformAccessory

                                                                                                                                                                            interface PlatformAccessory {}

                                                                                                                                                                              method emit

                                                                                                                                                                              emit: (event: 'identify') => boolean;

                                                                                                                                                                                method on

                                                                                                                                                                                on: (event: 'identify', listener: () => void) => this;

                                                                                                                                                                                  interface PlatformConfig

                                                                                                                                                                                  interface PlatformConfig extends Record<string, any> {}

                                                                                                                                                                                    property name

                                                                                                                                                                                    name?: string;

                                                                                                                                                                                      property platform

                                                                                                                                                                                      platform: PlatformName | PlatformIdentifier;

                                                                                                                                                                                        interface PlatformPluginConstructor

                                                                                                                                                                                        interface PlatformPluginConstructor<
                                                                                                                                                                                        Config extends PlatformConfig = PlatformConfig
                                                                                                                                                                                        > {}

                                                                                                                                                                                          construct signature

                                                                                                                                                                                          new (logger: Logging, config: Config, api: API):
                                                                                                                                                                                          | DynamicPlatformPlugin
                                                                                                                                                                                          | StaticPlatformPlugin
                                                                                                                                                                                          | IndependentPlatformPlugin;

                                                                                                                                                                                            interface PluginInitializer

                                                                                                                                                                                            interface PluginInitializer {}
                                                                                                                                                                                            • The {PluginInitializer} is a method which must be the default export for every homebridge plugin. It is called once the plugin is loaded from disk.

                                                                                                                                                                                            call signature

                                                                                                                                                                                            (api: API): void | Promise<void>;
                                                                                                                                                                                            • When the initializer is called the plugin must use the provided api instance and call the appropriate register methods - API.registerAccessory or API.registerPlatform - in order to correctly register for the following startup sequence.

                                                                                                                                                                                              Parameter api

                                                                                                                                                                                            interface StaticPlatformPlugin

                                                                                                                                                                                            interface StaticPlatformPlugin extends PlatformPlugin {}
                                                                                                                                                                                            • Platform that exposes all available characteristics at the start of the plugin. The set of accessories can not change at runtime. The bridge waits for all callbacks to return before it is published and accessible by HomeKit controllers.

                                                                                                                                                                                            method accessories

                                                                                                                                                                                            accessories: (callback: (foundAccessories: AccessoryPlugin[]) => void) => void;
                                                                                                                                                                                            • This method is called once at startup. The Platform should pass all accessories which need to be created to the callback in form of a AccessoryPlugin. The Platform must respond in a timely manner as otherwise the startup of the bridge would be unnecessarily delayed.

                                                                                                                                                                                              Parameter callback

                                                                                                                                                                                            Enums

                                                                                                                                                                                            enum APIEvent

                                                                                                                                                                                            const enum APIEvent {
                                                                                                                                                                                            DID_FINISH_LAUNCHING = 'didFinishLaunching',
                                                                                                                                                                                            SHUTDOWN = 'shutdown',
                                                                                                                                                                                            }

                                                                                                                                                                                              member DID_FINISH_LAUNCHING

                                                                                                                                                                                              DID_FINISH_LAUNCHING = 'didFinishLaunching'
                                                                                                                                                                                              • Event is fired once homebridge has finished with booting up and initializing all components and plugins. When this event is fired it is possible that the Bridge accessory isn't published yet, if homebridge still needs to wait for some to finish accessory creation.

                                                                                                                                                                                              member SHUTDOWN

                                                                                                                                                                                              SHUTDOWN = 'shutdown'
                                                                                                                                                                                              • This event is fired when homebridge gets shutdown. This could be a regular shutdown or an unexpected crash. At this stage all Accessories are already unpublished and all PlatformAccessories are already saved to disk!

                                                                                                                                                                                              enum LogLevel

                                                                                                                                                                                              const enum LogLevel {
                                                                                                                                                                                              INFO = 'info',
                                                                                                                                                                                              SUCCESS = 'success',
                                                                                                                                                                                              WARN = 'warn',
                                                                                                                                                                                              ERROR = 'error',
                                                                                                                                                                                              DEBUG = 'debug',
                                                                                                                                                                                              }
                                                                                                                                                                                              • Log levels to indicate importance of the logged message. Every level corresponds to a certain color.

                                                                                                                                                                                                - INFO: no color - SUCCESS: green - WARN: yellow - ERROR: red - DEBUG: gray

                                                                                                                                                                                                Messages with DEBUG level are only displayed if explicitly enabled.

                                                                                                                                                                                              member DEBUG

                                                                                                                                                                                              DEBUG = 'debug'

                                                                                                                                                                                                member ERROR

                                                                                                                                                                                                ERROR = 'error'

                                                                                                                                                                                                  member INFO

                                                                                                                                                                                                  INFO = 'info'

                                                                                                                                                                                                    member SUCCESS

                                                                                                                                                                                                    SUCCESS = 'success'

                                                                                                                                                                                                      member WARN

                                                                                                                                                                                                      WARN = 'warn'

                                                                                                                                                                                                        enum PlatformAccessoryEvent

                                                                                                                                                                                                        const enum PlatformAccessoryEvent {
                                                                                                                                                                                                        IDENTIFY = 'identify',
                                                                                                                                                                                                        }

                                                                                                                                                                                                          member IDENTIFY

                                                                                                                                                                                                          IDENTIFY = 'identify'

                                                                                                                                                                                                            enum PluginType

                                                                                                                                                                                                            const enum PluginType {
                                                                                                                                                                                                            ACCESSORY = 'accessory',
                                                                                                                                                                                                            PLATFORM = 'platform',
                                                                                                                                                                                                            }

                                                                                                                                                                                                              member ACCESSORY

                                                                                                                                                                                                              ACCESSORY = 'accessory'

                                                                                                                                                                                                                member PLATFORM

                                                                                                                                                                                                                PLATFORM = 'platform'

                                                                                                                                                                                                                  Type Aliases

                                                                                                                                                                                                                  type AccessoryIdentifier

                                                                                                                                                                                                                  type AccessoryIdentifier = string;

                                                                                                                                                                                                                    type AccessoryName

                                                                                                                                                                                                                    type AccessoryName = string;

                                                                                                                                                                                                                      type HAP

                                                                                                                                                                                                                      type HAP = API['hap'];

                                                                                                                                                                                                                        type PlatformIdentifier

                                                                                                                                                                                                                        type PlatformIdentifier = string;

                                                                                                                                                                                                                          type PlatformName

                                                                                                                                                                                                                          type PlatformName = string;

                                                                                                                                                                                                                            type PluginIdentifier

                                                                                                                                                                                                                            type PluginIdentifier = PluginName | ScopedPluginName;

                                                                                                                                                                                                                              type PluginName

                                                                                                                                                                                                                              type PluginName = string;

                                                                                                                                                                                                                                type ScopedPluginName

                                                                                                                                                                                                                                type ScopedPluginName = string;

                                                                                                                                                                                                                                  type UnknownContext

                                                                                                                                                                                                                                  type UnknownContext = Record<string, any>;

                                                                                                                                                                                                                                    Package Files (8)

                                                                                                                                                                                                                                    Dependencies (7)

                                                                                                                                                                                                                                    Dev Dependencies (19)

                                                                                                                                                                                                                                    Peer Dependencies (0)

                                                                                                                                                                                                                                    No peer dependencies.

                                                                                                                                                                                                                                    Badge

                                                                                                                                                                                                                                    To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                    You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/homebridge.

                                                                                                                                                                                                                                    • Markdown
                                                                                                                                                                                                                                      [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/homebridge)
                                                                                                                                                                                                                                    • HTML
                                                                                                                                                                                                                                      <a href="https://www.jsdocs.io/package/homebridge"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>