Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@homebridge/hap-client

homebridge20.9kMIT3.1.0TypeScript support: included

A client for HAP-NodeJS.

hap, homebridge, api

readme

HAP Client

npm npm Discord Donate

A client for an insecure HAP-NodeJS instance. Provides a Typescript based interface based on the homekit accessory protocol, allowing the creation of clients able to connect to and control Homebridge devices.

API

const { HapClient } = require('@homebridge/hap-client');

this.hapClient = new HapClient({
  config: { debug: true },
  pin: config.username,
  logger: this.log,
});

this.monitor = await this.hapClient.monitorCharacteristics(services?: ServiceType[]);  // Creates event monitors for all event capabable Homebridge services.  If a list of services is, this list is used rather than all

hap-client Events

this.hapClient.on('instance-discovered', this.instanceDiscovered(instance: HapInstance));  // Emitted during discovery for each HB instance discovered

this.hapClient.on('instance-configuration-changed', this.instanceChanged(instance: HapInstance));  // Emitted during discovery for each HB instance change

this.hapClient.on('discovery-terminated', this.discoveryTerminated());  // Instance discovery was terminated

this.hapClient.on('discovery-ended', this.discoveryEnded());  // Emitted when discovery has ended ( 60 Seconds )

this.monitor.on('service-update', this.serviceUpdate(services)); // Emitted when a characteristic change is received from a homebridge service

this.monitor.on('monitor-close', this.monitorClose(instance, hadError)); // Emitted when the connection to a homebridge service is closed ( likely a restart )

this.monitor.on('monitor-error', this.monitorError(instance, error)); // Emitted when the connection to a homebridge service has an error ( likely a restart )

this.monitor.on('monitor-refresh', this.monitorRefresh(instance, error)); // Emitted when the connection to a homebridge instance has been refreshed ( Triggered when an instance is discovered and its port, configuration number or name has changed)

Dependant Applications

  • homebridge-config-ui-x
  • homebridge-gsh
  • node-red-contrib-homebridge-automation

  • NPM Dependants

Credits

  • HAP Client was originally created by oznu.

changelog

Change Log

All notable changes to @homebridge/hap-client will be documented in this file. This project tries to adhere to Semantic Versioning.

v3.1.0 (2025-06-19)

Changed

  • export an enums constant in the hap-types file

Homebridge Dependencies

  • @homebridge/hap-nodejs @ v2.0.0

v3.0.0 (2025-06-18)

Changed

  • update @homebridge/hap-nodejs to v2
  • modernise tsconfig.json file
  • update jest to v30 and required migration steps
  • update eslint to v9 and required migration steps
  • update axios, regenerate lock file

Homebridge Dependencies

  • @homebridge/hap-nodejs @ v2.0.0

v2.2.0 (2025-05-26)

Changed

  • Updated dependencies
  • Return validValues in characteristic structure

v2.1.0 (2025-04-22)

Changed

v2.0.6 (2025-03-22)

Changed

  • updated dependencies

v2.0.5 (2024-12-04)

Changed

  • updated dependencies
  • Added refresh of 'values' field when refreshServiceCharacteristics or getCharacteristic is used
  • Added new setCharacteristic option, setCharacteristicByType which finds characteristic by type for setting.
  • Added new getResource request to retrieve snapshot images from camera's
  • Minor tweak to serviceName, and if the name is blank, use the name value from Accessory Information
  • Fixed issue of error handler triggering an error when attempting to connect to a homebridge instance that is down
  • Added restart of monitor when client connections close
  • Added console logging if a logger is not provided

v2.0.4 (2024-11-07)

Changed

  • Added public method destroy, to be used for testing
  • Update public method monitorCharacteristics to allow passing of a filtered services array.

v2.0.2 (2024-08-31)

Changed

  • updated dependencies

v2.0.1 (2024-07-22)

Changed

  • updated dev dependencies

v2.0.0 (2024-07-13)

Breaking Changes

  • HAP-NodeJS v1.0.0 is included in this release. In v1.0.0 we have removed old deprecated code.

Changed

  • update dependencies (axios)
  • update dev dependencies
  • update dependencies (hap-nodejs)

v1.10.2 (2024-04-19)

Changed

  • update dev dependencies

v1.10.1 (2024-04-03)

Other Changes

  • create CHANGELOG file
  • update LICENSE to standardise with other hb repos
  • update README to standardise with other hb repos
  • update dependencies

v1.10.0 (2024-03-31)

Other Changes

  • Publish as @homebridge/hap-client (#9)