HAP-NodeJS is a free, open source internet of things (iot) project written in TypeScript and released under Apache-2.0. It has 2,722 GitHub stars, 619 forks and 6 open issues, and was last pushed 1 months ago. On this registry it ranks #15 of 45 tracked projects in Internet of Things (IoT), with 5 head-to-head comparisons available.

What is HAP-NodeJS?

HAP-NodeJS is a TypeScript implementation of the server side of Apple's HomeKit Accessory Protocol (HAP), published under the Apache-2.0 licence as a library for developers who want to build their own HomeKit accessories on Raspberry Pi, Intel Edison, or any other platform that can run Node.js.

What it is

HAP-NodeJS implements the HomeKit Accessory Server as specified in the HomeKit Accessory Protocol, which Apple defines as part of the HomeKit Framework. It is delivered as a library rather than a finished application, so its output is not a consumer smart-home product but the protocol foundation on which a developer builds an accessory that HomeKit clients, including Siri, can discover and control. The project lives in the Node.js ecosystem, is written in TypeScript, carries the Apache-2.0 licence, and has accumulated roughly 2,700 stars and 619 forks.

The concrete problem it solves is the absence of a HAP server for non-HomeKit hardware. Rather than reverse-engineering or re-implementing Apple's accessory server, a developer depends on HAP-NodeJS and supplies only the device-specific logic. The README is explicit that the implementation tries to follow the HAP specification as closely as it can but may differ in some cases, and that it is not an Apple certified HAP implementation, since certification is available only to members of the MFi program.

Key capabilities

  • Implements the HomeKit Accessory Server side of the HomeKit Accessory Protocol, covering the role described by the hap-server and homekit-accessory-protocol topics.
  • Distributed as a library for building a custom HomeKit accessory, not as a pluggable bridge or end-user application.
  • Runs on Raspberry Pi, Intel Edison, or any other platform capable of running Node.js, and is written in TypeScript.
  • Provides a documented debug output mode, described in the project FAQ, for troubleshooting accessory behaviour.
  • Acts as the internal protocol engine of Homebridge, whose plugin ecosystem includes Pilight, Telldus TDtool, Savant, Netatmo, Open Pixel Control, HomeWizard, Fritz!Box, LG WebOS TV, Home Assistant, and HomeMatic.
  • Supported by a separate HAP-NodeJS-examples repository, legacy accessory examples under src/accessories, and generated module documentation hosted at developers.homebridge.io.
  • Introduces HomeKit terminology, pairing, and library usage through the project Wiki and a dedicated development guide.

Who uses it and how

  • Developers building a bespoke accessory for a device that does not speak HomeKit, running the library on a Raspberry Pi or Intel Edison in a home network.
  • Users of Homebridge, the pluggable bridge that consumes HAP-NodeJS internally to expose third-party devices to HomeKit through community plugins.
  • Integration projects such as OpenHAB-HomeKit-Bridge, homekit2mqtt, pimatic-hap, node-red-contrib-homekit, ioBroker.homekit, and AccessoryServer, which use it to bridge openHAB items, MQTT topics, Pimatic, Node-RED flows, ioBroker, and IR/RF/IP devices respectively.
  • Makers and small teams who need a maintained protocol layer rather than a full application, and who are comfortable working from a Wiki, an examples repository, and work-in-progress API documentation.

Getting started

Getting started means using HAP-NodeJS as a library: the README directs new users to the project Wiki, the guide on using HAP-NodeJS as a library, and the HAP-NodeJS-examples repository, with API reference material published at developers.homebridge.io/HAP-NodeJS.

How it compares

No list of paid products replaced by this project is provided, but the README names the tools it sits alongside. Homebridge is the pluggable bridge aimed at users who want ready-made community plugins and uses HAP-NodeJS internally, while OpenHAB-HomeKit-Bridge, homekit2mqtt, pimatic-hap, node-red-contrib-homekit, ioBroker.homekit, and AccessoryServer are bridges and integrations listed as projects based on HAP-NodeJS. HAP-NodeJS therefore occupies the layer beneath them, supplying the protocol implementation that those bridges expose to HomeKit.

When to use it — and when not to

Choose HAP-NodeJS when the goal is a custom accessory or a bridge of your own and the operational burden of hosting Node.js and maintaining accessory logic is acceptable; the facts mention no database, message broker, or mail service that a self-hoster must run alongside it. Avoid it if a ready-made, plugin-driven bridge such as Homebridge already covers the devices involved, or if Apple MFi certification is a requirement, because this project is not certified and its README states that behaviour may differ from the specification in some cases. Prospective users should also weigh the documentation being marked work in progress and the project's history, which includes Apple's 2014 DMCA request that removed the reverse-engineered HAP research the project originally referenced.

project readme (upstream, from github) — read inline

HAP-NodeJS


Coverage Status

HAP-NodeJS is an implementation of the HomeKit Accessory Server as specified in the HomeKit Accessory Protocol (HAP), which is defined by Apple as part of the HomeKit Framework.

HAP-NodeJS is intended to be used as a library to easily create your own HomeKit Accessory on a Raspberry Pi, Intel Edison, or any other platform that can run Node.js :)
If you are searching for a pluggable HomeKit bridge with over a thousand community driven plugins to bring HomeKit support to devices which do not support HomeKit out of the box, you may want to look at the homebridge project (which also uses HAP-NodeJS internally).

The implementation tries to follow the HAP specification as close as it can, but may differ in some cases. HAP-NodeJS is not an Apple certified HAP implementation, as this is only available to members of the MFi program.

Getting started

You may start by having a look at our Wiki, especially have a look at the Important HomeKit Terminology used in this project.

There is also a pretty detailed guide on how to start developing with HAP-NodeJS. Or you may just have a look at our examples repository (or some of the old accessory examples).

The documentation (WIP) can be found here.

See the FAQ on how to enable debug output for HAP-NodeJS.

Projects based on HAP-NodeJS

  • Homebridge - HomeKit support for the impatient - Pluggable HomeKit Bridge.
    Plugins available for e.g. Pilight, Telldus TDtool, Savant, Netatmo, Open Pixel Control, HomeWizard, Fritz!Box, LG WebOS TV, Home Assistant, HomeMatic and many more.
  • OpenHAB-HomeKit-Bridge - OpenHAB HomeKit Bridge bridges openHAB items to Apples HomeKit Accessory Protocol.
  • homekit2mqtt - HomeKit to MQTT bridge.
  • pimatic-hap - Pimatic homekit bridge.
  • node-red-contrib-homekit - Node-RED nodes to simulate Apple HomeKit devices.
  • ioBroker.homekit - connect ioBroker to HomeKit.
  • AccessoryServer - HomeKit integration for IR/RF/IP-devices

Notes

Special thanks to Alex Skalozub, who reverse-engineered the server side HAP. You can find his research here. (Sadly, on Nov 4 2014, Apple sent the DMCA request to GitHub to remove the research.)

There is a video demo running this project on Intel Edison.

If you are interested in HAP over BTLE, you might want to check this.

Frequently asked questions

Is HAP-NodeJS free to use?

HAP-NodeJS is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does HAP-NodeJS do?

Node.js implementation of the HomeKit Accessory Protocol (HAP)

What is HAP-NodeJS written in?

HAP-NodeJS is primarily written in TypeScript. Its source is publicly available at https://github.com/homebridge/HAP-NodeJS, and it has 2,722 GitHub stars.