https://github.com/homebridge/HAP-NodeJS
Node.js implementation of the HomeKit Accessory Protocol (HAP)
https://github.com/homebridge/HAP-NodeJS
hap hap-nodejs hap-server homekit homekit-accessory homekit-accessory-protocol homekit-device homekit-protocol homekit-server homekit-support siri
Last synced: 11 months ago
JSON representation
Node.js implementation of the HomeKit Accessory Protocol (HAP)
- Host: GitHub
- URL: https://github.com/homebridge/HAP-NodeJS
- Owner: homebridge
- License: apache-2.0
- Created: 2014-10-08T15:42:23.000Z (over 11 years ago)
- Default Branch: latest
- Last Pushed: 2025-03-23T08:58:29.000Z (11 months ago)
- Last Synced: 2025-03-29T18:38:49.783Z (11 months ago)
- Topics: hap, hap-nodejs, hap-server, homekit, homekit-accessory, homekit-accessory-protocol, homekit-device, homekit-protocol, homekit-server, homekit-support, siri
- Language: TypeScript
- Homepage:
- Size: 31.9 MB
- Stars: 2,698
- Watchers: 154
- Forks: 628
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- StarryDivineSky - homebridge/HAP-NodeJS - NodeJS是HomeKit配件协议(HAP)的Node.js实现,专为开发者提供在非苹果设备上构建HomeKit兼容配件的工具。该项目通过JavaScript语言实现苹果HomeKit协议的核心功能,允许开发者使用Node.js开发支持IP网络通信的智能设备,如灯泡、传感器等,并能与HomeKit中枢(如iPhone、HomePod)实现加密通信与认证流程。其核心功能包括HAP协议的完整实现,如配对加密、设备信息交互、服务端点管理等,同时支持模块化设计,便于开发者扩展自定义配件功能。 项目通过Node.js实现HAP协议的通信机制,使配件能通过HTTP/HTTPS与HomeKit中枢建立安全连接,支持动态生成设备证书、配对密钥等关键流程。开发者可基于项目提供的模板快速创建配件,例如通过定义服务(如Lightbulb)和特性(如On/Off)实现设备控制逻辑。项目特色包括兼容HomeKit 1.0+版本、支持多种平台(如Linux、macOS)、提供丰富的测试用例及示例代码,且支持通过HTTP API实现设备调试。 HAP-NodeJS的工作原理基于HAP协议的分层架构,包含运输层(通过IP通信)、加密层(使用AES-CCM加密数据)和配对层(基于零配置网络的配对流程)。项目要求依赖Node.js环境,开发者可通过npm安装包后,基于提供的代码模板实现设备逻辑,并通过HomeKit配置工具完成设备注册。此项目适合物联网开发者、HomeKit爱好者及希望用JavaScript开发智能家居配件的用户,是连接非苹果设备与HomeKit生态的重要工具。 (硬件_其他 / 资源传输下载)
README
# HAP-NodeJS

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-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][wiki], especially have a look at the
[Important HomeKit Terminology][hk-terminology] used in this project.
There is also a pretty detailed guide on [how to start developing with HAP-NodeJS][dev-guide].
Or you may just have a look at our [examples][examples-repo] repository
(or some of the old [accessory examples][example-accessories]).
The documentation (WIP) can be found [here](https://developers.homebridge.io/HAP-NodeJS/modules.html).
See the FAQ on how to enable [debug output][faq-debug] for HAP-NodeJS.
If you wish to do a contribution please read through our [CONTRIBUTING][contributing] guide.
## Projects based on HAP-NodeJS
- [Homebridge][project-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][project-openhab-homekit-bridge] - OpenHAB HomeKit Bridge bridges openHAB items to
Apples HomeKit Accessory Protocol.
- [homekit2mqtt][project-homekit2mqtt] - HomeKit to MQTT bridge.
- [pimatic-hap][project-pimatic-hap] - Pimatic homekit bridge.
- [node-red-contrib-homekit][project-node-red-contrib-homekit] - Node-RED nodes to simulate Apple HomeKit devices.
- [ioBroker.homekit][project-ioBroker-homekit] - connect ioBroker to HomeKit.
- [AccessoryServer][project-accessoryserver] - HomeKit integration for IR/RF/IP-devices
## Notes
Special thanks to [Alex Skalozub][link-alex-skalozub], who reverse-engineered the server side HAP.
~~You can find his research [here][link-homekit-research].~~
(Sadly, on Nov 4 2014, Apple sent the [DMCA][link-apple-dmca] request to GitHub to remove the research.)
[There](https://www.instagram.com/p/t4cPlcDksQ/) is a video demo running this project on Intel Edison.
If you are interested in HAP over BTLE, you might want to check [this][link-hap-over-btle].
[wiki]: https://github.com/homebridge/HAP-NodeJS/wiki
[hk-terminology]: https://github.com/homebridge/HAP-NodeJS/wiki/HomeKit-Terminology
[dev-guide]: https://github.com/homebridge/HAP-NodeJS/wiki/Using-HAP-NodeJS-as-a-library
[faq-debug]: https://github.com/homebridge/HAP-NodeJS/wiki/FAQ#debug-mode
[contributing]: https://github.com/homebridge/HAP-NodeJS/blob/master/CONTRIBUTING.md
[examples-repo]: https://github.com/homebridge/HAP-NodeJS-examples
[example-accessories]: https://github.com/homebridge/HAP-NodeJS/tree/master/src/accessories
[project-homebridge]: https://github.com/homebridge/homebridge
[project-openhab-homekit-bridge]: https://github.com/htreu/OpenHAB-HomeKit-Bridge
[project-homekit2mqtt]: https://github.com/hobbyquaker/homekit2mqtt
[project-pimatic-hap]: https://github.com/michbeck100/pimatic-hap
[project-node-red-contrib-homekit]: https://github.com/NRCHKB/node-red-contrib-homekit-bridged
[project-ioBroker-homekit]: https://github.com/ioBroker/ioBroker.homekit2
[project-accessoryserver]: https://github.com/Appyx/AccessoryServer
[link-alex-skalozub]: https://twitter.com/pieceofsummer
[link-homekit-research]: https://gist.github.com/pieceofsummer/13272bf76ac1d6b58a30
[link-apple-dmca]: https://github.com/github/dmca/blob/master/2014/2014-11-04-Apple.md
[link-hap-over-btle]: https://gist.github.com/KhaosT/6ff09ba71d306d4c1079
