{"id":16461642,"url":"https://github.com/marcus-j-davies/hap-router","last_synced_at":"2025-08-28T09:15:41.059Z","repository":{"id":37012928,"uuid":"355969636","full_name":"marcus-j-davies/HAP-Router","owner":"marcus-j-davies","description":"A Middleware HAP Router for bringing HomeKit functionality to your Home Automation.","archived":false,"fork":false,"pushed_at":"2022-11-19T09:19:57.000Z","size":7273,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-09T07:38:21.464Z","etag":null,"topics":["accessory","apple","automation","device","hap","hap-nodejs","home","homekit","ios","smart","virtual"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcus-j-davies.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-08T15:58:33.000Z","updated_at":"2023-01-18T09:42:42.000Z","dependencies_parsed_at":"2023-01-17T13:16:01.302Z","dependency_job_id":null,"html_url":"https://github.com/marcus-j-davies/HAP-Router","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/marcus-j-davies/HAP-Router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcus-j-davies%2FHAP-Router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcus-j-davies%2FHAP-Router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcus-j-davies%2FHAP-Router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcus-j-davies%2FHAP-Router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcus-j-davies","download_url":"https://codeload.github.com/marcus-j-davies/HAP-Router/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcus-j-davies%2FHAP-Router/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272475620,"owners_count":24940719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accessory","apple","automation","device","hap","hap-nodejs","home","homekit","ios","smart","virtual"],"created_at":"2024-10-11T11:08:55.473Z","updated_at":"2025-08-28T09:15:41.016Z","avatar_url":"https://github.com/marcus-j-davies.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# HAP Router  \n![Image](./Logo.png)  \n\n![Image](./Screenshot.png)  \n\n![NPM](https://img.shields.io/npm/l/hap-router)\n![npm](https://img.shields.io/npm/v/hap-router)\n[![Package Quality](https://packagequality.com/shield/hap-router.svg)](https://packagequality.com/#?package=hap-router)\n[![DeepScan grade](https://deepscan.io/api/teams/17652/projects/21016/branches/591318/badge/grade.svg)](https://deepscan.io/dashboard#view=project\u0026tid=17652\u0026pid=21016\u0026bid=591318)\n![GitHub issues](https://img.shields.io/github/issues-raw/marcus-j-davies/hap-router)\n![GitHub closed issues](https://img.shields.io/github/issues-closed-raw/marcus-j-davies/hap-router)\n![Libraries.io dependency status for latest release](https://img.shields.io/librariesio/release/npm/hap-router)\n\n\nA Middleware HAP Router for bringing HomeKit functionality to your Home Automation.  \n\nHAP Router is a middleware NodeJS server that allows you to take advantage of Apples HomeKit technology, and bring it in to your automation ecosystem.  \n\nThis is achieved by creating simple, software based accessories, that can be enrolled into HomeKit.  \n\nThe difference however, compared to most implementations of this kind, is that the events that occur on them are directed (or routed) to a transport of your choice.  \n\nThese transports can be a UDP broadcast, a message sent to an MQTT broker, sent to Node Red or any other automation platform.  \n\nThe accessories have also been created for you, and you simply select the type of accessory you wish to create  \nand set their associated information. \n\nTransports are the medium, in which the event is travelled. By default, the following transports (or routes) are as follows:\n\n  - HTTP\n  - UDP Broadcast\n  - File\n  - MQTT\n  - Websocket\n  - Console (Mainly for testing)\n\nWhen I say 'by default' - what I mean here, is that you can [develop your own](./RouteModule.md) route modules.  \n\nThe transport/route will receive the following JSON payload.  \nThere are 3 event types: **characteristicUpdate**, **pairStatusUpdate**, **identifyAccessory**\n\n**pairStatusUpdate**\n```javascript\n{\n  accessory: {\n    AccessoryID: '8D6497BC70A1',\n    AccessoryType: 'Fan',\n    AccessoryName: 'My Fan',\n    AccessorySerialNumber: '2ND2PB12EQO3',\n    Bridged: false\n  },\n  route: {\n    Name: 'Output To Console',\n    Type: 'Console Output'\n  },\n  eventType: 'pairStatusUpdate',\n  eventData: true\n}\n```\n\n**identifyAccessory**\n```javascript\n{\n  accessory: {\n    AccessoryID: '8D6497BC70A1',\n    AccessoryType: 'Fan',\n    AccessoryName: 'My Fan',\n    AccessorySerialNumber: '2ND2PB12EQO3',\n    Bridged: false\n  },\n  route: {\n    Name: 'Output To Console',\n    Type: 'Console Output'\n  },\n  eventType: 'identifyAccessory',\n  eventData: true\n}\n```\n\n**characteristicUpdate**\n```javascript\n{\n  accessory: {\n    AccessoryID: '8D6497BC70A1',\n    AccessoryType: 'Fan',\n    AccessoryName: 'My Fan',\n    AccessorySerialNumber: '2ND2PB12EQO3',\n    Bridged: false\n  },\n  route: {\n    Name: 'Output To Console',\n    Type: 'Console Output'\n  },\n  eventType: 'characteristicUpdate',\n  eventSource: 'iOS_DEVICE',\n  eventData: {\n    characteristic: 'RotationSpeed',\n    value: 62\n  }\n}\n```\n\nIf you're a Home Automation Enthusiast, or just a tinkerer, Hap Router allows you to explore Homekit, and build with it.\n\n## Nice! how do I get started\nThe server is managed by a gorgeous looking Web User Interface (if the above images haven't already suggested so), It is a breeze to use, and at the basic level you:\n - Create a Route (Routes can be used by more than 1 accessory)\n - Create an Accessory  \n   - Contact Sensor\n   - Air Quality Sensor\n   - Intruder Alarm\n   - Multisensor -  Combinations of:\n     - Motion\n     - Lux\n     - Temp\n     - Humidity\n   - Power Outlet\n   - Basic On/Off Switch\n   - Fan\n   - Lock\n   - Light Bulb\n   - Smart TV\n   - Garage Door Opener\n   - Thermostat\n   - Smoke Sensor\n   - Leak Sensor\n   - CCTV Camera\n - Enroll the device in HomeKit.\n - Have Fun.\n\nDevices can be 'published' in 2 ways:  \n - Attached to a bridge (HAP Router can also act as a Bridge)  \n - Exposed as a seperate device.\n\n If you have Enrolled HAP Router in your HomeKit environment as a bridge, then any accessories attached to this Bridge, will be seen when published.\n else, you enroll the accessory as a separate entity.\n\n## Manipulating accessories using non apple devices.  \nHAP Router has a web based API, as well as an MQTT client built in.  \nThe web API uses BASIC HTTP Authentication, and the login details are the same as the management UI.\n\n| Method | Address                           | Description                                             |\n| ------ | --------------------------------- | ------------------------------------------------------- |       \n| GET    | /api/accessories                  | Lists all accessories and there current characteristics |       \n| GET    | /api/accessories/{{AccessoryID}}  | Same as above but for the identified accessory          |      \n| POST   | /api/accessories/{{AccessoryID}}  | Sets characteristics for the identified accessory       |    \n\nTo turn the fan accessory on at full speed using the web API, you will:  \nSend a post request to: **http://{{IP ADDRESS}}:7989/api/accessories/8D6497BC70A1**  \nAnd include the following POST body (with a type of **application/json**)\n\n```javascript\n{\n  'On': true,\n  'RotationSpeed': 100\n}\n```\n\nIf you have enabled the MQTT client in the UI, the same message will be sent.  \nJust ensure the topic of the message ends with the Accessory ID.  \nBy default the subscribed topic is **HAPRouter/IN/+**\n\n\n\n## Command line arguments\n\n| Argument                          | Description                                      |\n| --------------------------------- | ------------------------------------------------ | \n| reset                             | Completely resets HAP Router to a default state  |      \n| installmodule {{Name}}            | Installs the specified route module from NPM     |    \n| passwd {{Username}} {{Password}}  | Set the UI and API login information             |    \n\n## Installing and Running  \nMake sure you have Node \u003e= v14.14.0 installed  \n\nSimply install via NPM ```npm install hap-router```  \nto run the server just call ```node HAPRouter.js``` \n\n## Credits\nHAP Router is based on the awesome [HAP-NodeJS](https://github.com/homebridge/HAP-NodeJS)\nlibrary, without it, projects like this one are not possible.\n\n## License\nMIT License\n\nCopyright (c) 2021 Marcus Davies\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcus-j-davies%2Fhap-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcus-j-davies%2Fhap-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcus-j-davies%2Fhap-router/lists"}