Class Accessory

Accessory is a virtual HomeKit device. It can publish an associated HAP server for iOS devices to communicate with - or it can run behind another "Bridge" Accessory server.

Bridged Accessories in this implementation must have a UUID that is unique among all other Accessories that are hosted by the Bridge. This UUID must be "stable" and unchanging, even when the server is restarted. This is required so that the Bridge can provide consistent "Accessory IDs" (aid) and "Instance IDs" (iid) for all Accessories, Services, and Characteristics for iOS clients to reference later.

Hierarchy (view full)

Constructors

Properties

UUID: string
_isBridge: boolean = false
aid: Nullable<number> = null
bridge?: Accessory
bridged: boolean = false
bridgedAccessories: Accessory[] = []
category: Categories = Categories.OTHER
displayName: string
lastKnownUsername?: string
reachable: boolean = true
services: Service[] = []
shouldPurgeUnusedIDs: boolean = true
Categories: typeof Categories = Categories

Deprecated

Please use the Categories const enum above.

Methods

  • Add the given service instance to the Accessory.

    Parameters

    Returns Service

    Returns the service instance passed to the method call.

  • Adds a given service by calling the provided Service constructor with the provided constructor arguments.

    Type Parameters

    Parameters

    Returns Service

    Returns the constructed service instance.

  • Method is used to configure an old style CameraSource. The CameraSource API was fully replaced by the new Controller API used by CameraController. The CameraStreamingDelegate used by the CameraController is the equivalent to the old CameraSource.

    The new Controller API is much more refined and robust way of "grouping" services together. It especially is intended to fully support serialization/deserialization to/from persistent storage. This feature is also gained when using the old style CameraSource API. The CameraStreamingDelegate improves on the overall camera API though and provides some reworked type definitions and a refined callback interface to better signal errors to the requesting HomeKit device. It is advised to update to it.

    Full backwards compatibility is currently maintained. A legacy CameraSource will be wrapped into an Adapter. All legacy StreamControllers in the "streamControllers" property will be replaced by CameraRTPManagement instances. Any services in the "services" property which are one of the following are ignored: - CameraRTPStreamManagement - CameraOperatingMode - CameraEventRecordingManagement

    Parameters

    Returns CameraController

    Deprecated

    please refer to the new CameraController API and configureController

  • This method is used to set up a new Controller for this accessory. See Controller for a more detailed explanation what a Controller is and what it is capable of.

    The controller can be passed as an instance of the class or as a constructor (without any necessary parameters) for a new Controller. Only one Controller of a given ControllerIdentifier can be configured for a given Accessory.

    When called, it will be checked if there are any services and persistent data the Controller (for the given ControllerIdentifier) can be restored from. Otherwise, the Controller will be created with new services.

    Parameters

    Returns void

  • Removes this Accessory from the local network Accessory object will no longer valid after invoking this method Trying to invoke publish() on the object will result undefined behavior

    Returns Promise<void>

  • Returns the bridging accessory if this accessory is bridged. Otherwise, returns itself.

    Returns Accessory

    the primary accessory

  • Parameters

    • event: "identify"
    • listener: ((paired, callback) => void)
        • (paired, callback): void
        • Parameters

          Returns void

    Returns this

  • Parameters

    • event: "listening"
    • listener: ((port, address) => void)
        • (port, address): void
        • Parameters

          • port: number
          • address: string

          Returns void

    Returns this

  • Parameters

    • event: "advertised"
    • listener: (() => void)
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "service-configurationChange"
    • listener: ((change) => void)

    Returns this

  • Parameters

    Returns this

  • Parameters

    • event: "paired"
    • listener: (() => void)
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "unpaired"
    • listener: (() => void)
        • (): void
        • Returns void

    Returns this

  • Parameters

    • event: "characteristic-warning"
    • listener: ((warning) => void)

    Returns this

  • Publishes this accessory on the local network for iOS clients to communicate with.

    • info.username - formatted as a MAC address, like CC:22:3D:E3:CE:F6, of this accessory. Must be globally unique from all Accessories on your local network.
    • info.pincode - the 8-digit pin code for clients to use when pairing this Accessory. Must be formatted as a string like 031-45-154.
    • info.category - one of the values of the Accessory.Category enum, like Accessory.Category.SWITCH. This is a hint to iOS clients about what "type" of Accessory this represents, so that for instance an appropriate icon can be drawn for the user while adding a new Accessory.

    Parameters

    • info: PublishInfo

      Required info for publishing.

    • Optional allowInsecureRequest: boolean

      Will allow unencrypted and unauthenticated access to the http server

    Returns Promise<void>

  • Manually purge the unused ids if you like, comes handy when you have disabled auto purge, so you can do it manually

    Returns void

  • Parameters

    • accessory: Accessory
    • deferUpdate: boolean = false

    Returns void

  • This method will remove a given Controller from this accessory. The controller object will be restored to its initial state. This also means that any event handlers setup for the controller will be removed.

    Parameters

    Returns void

  • Parameters

    • reachable: boolean

    Returns void

    Deprecated

    Not supported anymore

  • Parameters

    • username: string

    Returns void