diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index f58d32a16..000000000 --- a/.eslintrc +++ /dev/null @@ -1,38 +0,0 @@ -{ - "parser": "@typescript-eslint/parser", - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", // uses the recommended rules from the @typescript-eslint/eslint-plugin - "plugin:jest/recommended" // enables eslint-plugin-jest - ], - "plugins": ["import", "import-newlines"], - "parserOptions": { - "ecmaVersion": 2018, - "sourceType": "module" - }, - "ignorePatterns": [ - "bin/", - "lib/" - ], - "rules": { - "quotes": ["error", "double"], - "indent": ["error", 2, { "SwitchCase": 1 }], - "linebreak-style": ["error", "unix"], - "semi": ["error", "always"], - - "comma-dangle": ["error", "always-multiline"], - "dot-notation": "error", - "eqeqeq": ["error", "always", {"null": "ignore"}], - "curly": ["error", "all"], - "brace-style": ["error"], - - "import/order": ["warn", { "alphabetize": { "order": "asc" }, "newlines-between": "never" }], - "import/prefer-default-export": "off", - "import-newlines/enforce": ["error", 3], - - "@typescript-eslint/no-unsafe-declaration-merging": "off", - "@typescript-eslint/no-non-null-assertion": "off", // currently disabled, hap-nodejs has some bad typing (like getCharacteristic) for this to be enabled - "@typescript-eslint/no-unused-vars": ["error", { "caughtErrors": "none" }], - } -} diff --git a/.github/homebridge-reddit.svg b/.github/homebridge-reddit.svg index 854cc1df7..95967a257 100644 --- a/.github/homebridge-reddit.svg +++ b/.github/homebridge-reddit.svg @@ -176,4 +176,4 @@ - \ No newline at end of file + diff --git a/.github/labeler.yml b/.github/labeler.yml index 98f259891..8ef4615df 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,11 +1,11 @@ # Add 'beta' label to any PR where the head branch name starts with `beta` or has a `beta` section in the name beta: - - base-branch: ['^beta', 'beta', 'beta*'] + - base-branch: [^beta, beta, 'beta*'] # Add 'alpha' label to any PR where the head branch name starts with `alpha` or has an `alpha` section in the name alpha: - - base-branch: ['^alpha', 'alpha', 'alpha*'] + - base-branch: [^alpha, alpha, 'alpha*'] # Add 'latest' label to any PR where the head branch name starts with `latest` or has a `latest` section in the name latest: - - base-branch: ['^latest', 'latest', 'latest*'] + - base-branch: [^latest, latest, 'latest*'] diff --git a/.github/workflows/alpha-release.yml b/.github/workflows/alpha-release.yml index c828339cb..9a4273715 100644 --- a/.github/workflows/alpha-release.yml +++ b/.github/workflows/alpha-release.yml @@ -8,12 +8,12 @@ on: jobs: publish: if: ${{ github.repository == 'homebridge/homebridge' }} - uses: homebridge/.github/.github/workflows/npm-publish.yml@latest + uses: homebridge/.github/.github/workflows/npm-publish-esm.yml@latest with: - tag: 'alpha' + tag: alpha dynamically_adjust_version: true - npm_version_command: 'pre' - pre_id: 'alpha' + npm_version_command: pre + pre_id: alpha secrets: npm_auth_token: ${{ secrets.npm_token }} @@ -22,9 +22,9 @@ jobs: needs: [publish] uses: homebridge/.github/.github/workflows/discord-webhooks.yml@latest with: - title: "Homebridge Alpha Release" + title: Homebridge Alpha Release description: | Version `v${{ needs.publish.outputs.NPM_VERSION }}` - url: "https://github.com/homebridge/homebridge/releases/tag/v${{ needs.publish.outputs.NPM_VERSION }}" + url: 'https://github.com/homebridge/homebridge/releases/tag/v${{ needs.publish.outputs.NPM_VERSION }}' secrets: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL_BETA }} diff --git a/.github/workflows/beta-release.yml b/.github/workflows/beta-release.yml index 4aca52288..1c309a417 100644 --- a/.github/workflows/beta-release.yml +++ b/.github/workflows/beta-release.yml @@ -21,23 +21,23 @@ jobs: if: ${{ github.repository == 'homebridge/homebridge' }} - uses: homebridge/.github/.github/workflows/npm-publish.yml@latest + uses: homebridge/.github/.github/workflows/npm-publish-esm.yml@latest with: - tag: 'beta' + tag: beta dynamically_adjust_version: true - npm_version_command: 'pre' - pre_id: 'beta' + npm_version_command: pre + pre_id: beta secrets: npm_auth_token: ${{ secrets.npm_token }} github-releases-to-discord: name: Discord Webhooks - needs: [build_and_test,publish] + needs: [build_and_test, publish] uses: homebridge/.github/.github/workflows/discord-webhooks.yml@latest with: - title: "Homebridge Beta Release" + title: Homebridge Beta Release description: | Version `v${{ needs.publish.outputs.NPM_VERSION }}` - url: "https://github.com/homebridge/homebridge/releases/tag/v${{ needs.publish.outputs.NPM_VERSION }}" + url: 'https://github.com/homebridge/homebridge/releases/tag/v${{ needs.publish.outputs.NPM_VERSION }}' secrets: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL_BETA }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index a3faf80d9..ca3f3f004 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,10 +1,10 @@ -name: "CodeQL" +name: CodeQL on: push: - branches: [ latest, beta* ] + branches: [latest, beta*] pull_request: - branches: [ latest, beta* ] + branches: [latest, beta*] schedule: - cron: '17 9 * * 2' diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index c35bc3ef5..e20474eb8 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -9,4 +9,4 @@ jobs: stale: uses: homebridge/.github/.github/workflows/labeler.yml@latest secrets: - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 698c2b986..1046cb435 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,18 +19,18 @@ jobs: if: ${{ github.repository == 'homebridge/homebridge' }} - uses: homebridge/.github/.github/workflows/npm-publish.yml@latest + uses: homebridge/.github/.github/workflows/npm-publish-esm.yml@latest secrets: npm_auth_token: ${{ secrets.npm_token }} github-releases-to-discord: name: Discord Webhooks - needs: [build_and_test,publish] + needs: [build_and_test, publish] uses: homebridge/.github/.github/workflows/discord-webhooks.yml@latest with: - title: "Homebridge Release" + title: Homebridge Release description: | Version `v${{ needs.publish.outputs.NPM_VERSION }}` - url: "https://github.com/homebridge/homebridge/releases/tag/v${{ needs.publish.outputs.NPM_VERSION }}" + url: 'https://github.com/homebridge/homebridge/releases/tag/v${{ needs.publish.outputs.NPM_VERSION }}' secrets: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL_LATEST }} diff --git a/.github/workflows/wiki-change-notification.yml b/.github/workflows/wiki-change-notification.yml index 1089f163b..aaf9b8d70 100644 --- a/.github/workflows/wiki-change-notification.yml +++ b/.github/workflows/wiki-change-notification.yml @@ -7,7 +7,7 @@ jobs: notify: runs-on: ubuntu-latest steps: - - uses: 'oznu/gh-wiki-edit-discord-notification@main' + - uses: oznu/gh-wiki-edit-discord-notification@main with: discord-webhook-url: ${{ secrets.DISCORD_WEBHOOK_WIKI_EDIT }} ignore-collaborators: true diff --git a/.gitignore b/.gitignore index 0dcf9fad0..7d85ca2bb 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ coverage/ # Ignore any extra plugins in the example directory that aren't in Git already # (this is a sandbox for the user) example-plugins -lib +dist .idea diff --git a/.vscode/settings.json b/.vscode/settings.json index db348fbda..3aa491f03 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "codeQL.githubDatabase.download": "never" -} \ No newline at end of file + "codeQL.githubDatabase.download": "never" +} diff --git a/CHANGELOG.md b/CHANGELOG.md index b83ef873b..28ab92463 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,40 @@ All notable changes to `homebridge` will be documented in this file. This project tries to adhere to [Semantic Versioning](http://semver.org/). +## v2.0.0 (Unreleased) + +### ⚠️ Breaking Changes + +- **For Users:** + - Before upgrading, you will want to ensure that the plugin(s) you are using are compatible with this new version of Homebridge. If you are unsure, see the link below or open an issue with the developer of your plugin(s) in question. + +- **For Plugin Developers:** + - The new version of Homebridge includes a major version update to HAP-Nodejs. Some old deprecated functions have been removed. See the link below for a list of changes that you may need to make to your plugin(s). + +- Please visit the following link to learn more about the changes and how to prepare: + - [Updating-To-Homebridge-v2.0](https://github.com/homebridge/homebridge/wiki/Updating-To-Homebridge-v2.0) + +### Added + +- set debug `-D` setting per child bridge + +### Changed + +- Address legacy deprecation cleanup (#3648) (@hjdhjd) +- general code modernisation: + - move from `commonjs` to `esm` modules + - use lint rules from `@antfu/eslint-config` + - migrate from `jest` to `vitest` for testing + - ⚠️ drop support for node `v18` + +### Removed + +- remove deprecated `--remove-orphans` flag + +### Homebridge Dependencies + +- `hap-nodejs` @ `v2.0.0-beta` + ## v1.10.0 (2025-06-07) ### Changed diff --git a/README.md b/README.md index 3509fd089..6f490bf72 100644 --- a/README.md +++ b/README.md @@ -16,19 +16,19 @@ Unlocking Door -**Homebridge** is a lightweight Node.js server you can run on your home network that emulates the iOS HomeKit API. It supports Plugins, which are community-contributed modules that provide a basic bridge from HomeKit to various 3rd-party APIs provided by manufacturers of "smart home" devices. +**Homebridge** is a lightweight Node.js server you can run on your home network to emulate the HomeKit Accessory Protocol (HAP). It supports plugins, which are community-contributed modules that provide a basic bridge from HomeKit to various 3rd-party APIs provided by manufacturers of "smart home" devices. Since Siri supports devices added through HomeKit, this means that with Homebridge you can ask Siri to control devices that don't have any support for HomeKit at all. For instance, using just some of the available plugins, you can say: - * _Siri, unlock the back door._ [pictured to the right] - * _Siri, open the garage door._ - * _Siri, turn on the coffee maker._ - * _Siri, turn on the living room lights._ - * _Siri, good morning!_ +- _Siri, unlock the back door._ [pictured to the right] +- _Siri, open the garage door._ +- _Siri, turn on the coffee maker._ +- _Siri, turn on the living room lights._ +- _Siri, good morning!_ You can explore all available plugins at the NPM website by [searching for the keyword `homebridge-plugin`](https://www.npmjs.com/search?q=homebridge-plugin). -## Community +## Community The official Homebridge Discord server and Reddit community are where users can discuss Homebridge and ask for help. @@ -79,7 +79,7 @@ HomeKit communities can also be found on both [Discord](https://discord.gg/RcV7f ### Docker -[Install Homebridge on Docker](https://github.com/homebridge/homebridge/wiki/Install-Homebridge-on-Docker)
[Synology](https://github.com/homebridge/docker-homebridge/wiki/Homebridge-on-Synology) | [Unraid](https://github.com/homebridge/docker-homebridge/wiki/Homebridge-on-Unraid) | [QNAP](https://github.com/homebridge/docker-homebridge/wiki/Homebridge-on-QNAP) | [TrueNAS Scale](https://github.com/homebridge/docker-homebridge/wiki/Homebridge-on-TrueNAS-Scale) +[Install Homebridge on Docker](https://github.com/homebridge/homebridge/wiki/Install-Homebridge-on-Docker)
[Synology](https://github.com/homebridge/docker-homebridge/wiki/Homebridge-on-Synology) | [Unraid](https://github.com/homebridge/docker-homebridge/wiki/Homebridge-on-Unraid) | [QNAP](https://github.com/homebridge/docker-homebridge/wiki/Homebridge-on-QNAP) | [TrueNAS Scale](https://github.com/homebridge/docker-homebridge/wiki/Homebridge-on-TrueNAS-Scale) --- @@ -97,9 +97,9 @@ HomeKit communities can also be found on both [Discord](https://discord.gg/RcV7f 1. Open the Home app on your device. 2. Tap the Home tab, then tap . -3. Tap *Add Accessory*, then scan the QR code shown in the Homebridge UI or your Homebridge logs. +3. Tap _Add Accessory_, then scan the QR code shown in the Homebridge UI or your Homebridge logs. -If the bridge does not have any accessories yet, you may receive a message saying *Additional Set-up Required*, this is ok, as you add plugins they will show up in the Home app without the need to pair again (except for Cameras and TVs). +If the bridge does not have any accessories yet, you may receive a message saying _Additional Set-up Required_, this is ok, as you add plugins they will show up in the Home app without the need to pair again (except for Cameras and TVs). Cameras and most TV devices are exposed as separate accessories and each needs to be paired separately. See [this wiki article](https://github.com/homebridge/homebridge/wiki/Connecting-Homebridge-To-HomeKit#how-to-add-homebridge-cameras--tvs) for instructions. @@ -113,18 +113,17 @@ One final thing to remember is that Siri will almost always prefer its default p The https://developers.homebridge.io website contains the Homebridge API reference, available service and characteristic types, and plugin examples. -The [Homebridge Plugin Template](https://github.com/homebridge/homebridge-plugin-template) project provides a base you can use to create your own *platform* plugin. +The [Homebridge Plugin Template](https://github.com/homebridge/homebridge-plugin-template) project provides a base you can use to create your own _platform_ plugin. There are many existing plugins you can study; you might start with the [Homebridge Example Plugins](https://github.com/homebridge/homebridge-examples) or a plugin that already implements the device type you need. When writing your plugin, you'll want Homebridge to load it from your development directory instead of publishing it to `npm` each time. Run this command inside your plugin project folder so your global installation of Homebridge can discover it: - ```shell npm link ``` -*You can undo this using the `npm unlink` command.* +_You can undo this using the `npm unlink` command._ Then start Homebridge in debug mode: @@ -150,13 +149,13 @@ To fix this, [Reset Homebridge](https://github.com/homebridge/homebridge/wiki/Co Try the following: - 1. Swap between the `Bonjour HAP` and `Ciao` mDNS Advertiser options. See [the wiki](https://github.com/homebridge/homebridge/wiki/mDNS-Options) for more details. - 2. iOS DNS cache has gone stale or gotten misconfigured. To fix this, turn airplane mode on and back off to flush the DNS cache. +1. Swap between the `Bonjour HAP` and `Ciao` mDNS Advertiser options. See [the wiki](https://github.com/homebridge/homebridge/wiki/mDNS-Options) for more details. +2. iOS DNS cache has gone stale or gotten misconfigured. To fix this, turn airplane mode on and back off to flush the DNS cache. ### Limitations - * One bridge can only expose 150 accessories due to a HomeKit limit. You can however run your plugins as a [Child Bridge](https://github.com/homebridge/homebridge/wiki/Child-Bridges) or run [Multiple Homebridge Instances](https://github.com/homebridge/homebridge-config-ui-x/wiki/Homebridge-Service-Command#multiple-instances) to get around this limitation. - * Once an accessory has been added to the Home app, changing its name via Homebridge won't be automatically reflected in iOS. You must change it via the Home app as well. +- One bridge can only expose 150 accessories due to a HomeKit limit. You can however run your plugins as a [Child Bridge](https://github.com/homebridge/homebridge/wiki/Child-Bridges) or run [Multiple Homebridge Instances](https://github.com/homebridge/homebridge-config-ui-x/wiki/Homebridge-Service-Command#multiple-instances) to get around this limitation. +- Once an accessory has been added to the Home app, changing its name via Homebridge won't be automatically reflected in iOS. You must change it via the Home app as well. ## Why Homebridge? diff --git a/bin/homebridge b/bin/homebridge deleted file mode 100755 index 56dbbaecc..000000000 --- a/bin/homebridge +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env node - -// -// This executable sets up the environment and runs the HomeBridge CLI. -// - -"use strict"; - -process.title = "homebridge"; - -// Find the HomeBridge lib -const path = require("path"); -const fs = require("fs"); -const lib = path.join(path.dirname(fs.realpathSync(__filename)), "../lib"); - -// Run HomeBridge -require(lib + '/cli')(); diff --git a/bin/homebridge.js b/bin/homebridge.js new file mode 100755 index 000000000..f71106dac --- /dev/null +++ b/bin/homebridge.js @@ -0,0 +1,22 @@ +#!/usr/bin/env node + +// +// This executable sets up the environment and runs the Homebridge CLI. +// + +import { realpathSync } from 'node:fs' +import { dirname, join } from 'node:path' +import process from 'node:process' +import { fileURLToPath, pathToFileURL } from 'node:url' + +process.title = 'homebridge' + +// Find the Homebridge lib +const __filename = fileURLToPath(import.meta.url) +const lib = join(dirname(realpathSync(__filename)), '../dist') + +// Convert the path to a file URL +const libUrl = pathToFileURL(join(lib, 'cli.js')).href + +// Run Homebridge +import(libUrl).then(({ default: run }) => run()) diff --git a/config-sample.json b/config-sample.json index a2ac12638..390ae32e3 100644 --- a/config-sample.json +++ b/config-sample.json @@ -7,7 +7,7 @@ "port": 51826, "pin": "031-45-154" }, - + "description": "This is an example configuration file with one fake accessory and one fake platform. You can use this as a template for creating your own configuration file containing devices you actually own.", "ports": { "start": 52100, @@ -23,8 +23,8 @@ "platforms": [ { - "platform" : "PhilipsHue", - "name" : "Hue" + "platform": "PhilipsHue", + "name": "Hue" } ] } diff --git a/docs/index.html b/docs/index.html index 75fb17843..842ea0d21 100644 --- a/docs/index.html +++ b/docs/index.html @@ -9,7 +9,7 @@

Homebridge

Unlocking Door -

Homebridge is a lightweight Node.js server you can run on your home network that emulates the iOS HomeKit API. It supports Plugins, which are community-contributed modules that provide a basic bridge from HomeKit to various 3rd-party APIs provided by manufacturers of "smart home" devices.

+

Homebridge is a lightweight Node.js server you can run on your home network to emulate the HomeKit Accessory Protocol (HAP). It supports plugins, which are community-contributed modules that provide a basic bridge from HomeKit to various 3rd-party APIs provided by manufacturers of "smart home" devices.

Since Siri supports devices added through HomeKit, this means that with Homebridge you can ask Siri to control devices that don't have any support for HomeKit at all. For instance, using just some of the available plugins, you can say: