homebridge 2.0.0-beta.2 → 2.0.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +16 -17
  2. package/bin/homebridge.js +22 -0
  3. package/config-sample.json +3 -3
  4. package/{lib → dist}/api.d.ts +23 -40
  5. package/dist/api.d.ts.map +1 -0
  6. package/{lib → dist}/api.js +38 -64
  7. package/dist/api.js.map +1 -0
  8. package/{lib → dist}/bridgeService.d.ts +11 -9
  9. package/dist/bridgeService.d.ts.map +1 -0
  10. package/{lib → dist}/bridgeService.js +79 -115
  11. package/dist/bridgeService.js.map +1 -0
  12. package/{lib → dist}/childBridgeFork.d.ts +4 -3
  13. package/dist/childBridgeFork.d.ts.map +1 -0
  14. package/{lib → dist}/childBridgeFork.js +38 -41
  15. package/dist/childBridgeFork.js.map +1 -0
  16. package/{lib → dist}/childBridgeService.d.ts +10 -7
  17. package/dist/childBridgeService.d.ts.map +1 -0
  18. package/{lib → dist}/childBridgeService.js +87 -66
  19. package/dist/childBridgeService.js.map +1 -0
  20. package/dist/cli.d.ts +3 -0
  21. package/dist/cli.d.ts.map +1 -0
  22. package/dist/cli.js +89 -0
  23. package/dist/cli.js.map +1 -0
  24. package/{lib → dist}/externalPortService.d.ts +2 -2
  25. package/{lib → dist}/externalPortService.d.ts.map +1 -1
  26. package/{lib → dist}/externalPortService.js +4 -9
  27. package/dist/externalPortService.js.map +1 -0
  28. package/{lib → dist}/index.d.ts +29 -29
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +19 -0
  31. package/dist/index.js.map +1 -0
  32. package/{lib → dist}/ipcService.d.ts +2 -5
  33. package/dist/ipcService.d.ts.map +1 -0
  34. package/{lib → dist}/ipcService.js +12 -12
  35. package/dist/ipcService.js.map +1 -0
  36. package/{lib → dist}/logger.d.ts +6 -6
  37. package/dist/logger.d.ts.map +1 -0
  38. package/{lib → dist}/logger.js +19 -28
  39. package/dist/logger.js.map +1 -0
  40. package/{lib → dist}/platformAccessory.d.ts +7 -6
  41. package/dist/platformAccessory.d.ts.map +1 -0
  42. package/{lib → dist}/platformAccessory.js +12 -16
  43. package/dist/platformAccessory.js.map +1 -0
  44. package/{lib → dist}/plugin.d.ts +2 -3
  45. package/dist/plugin.d.ts.map +1 -0
  46. package/{lib → dist}/plugin.js +39 -51
  47. package/dist/plugin.js.map +1 -0
  48. package/{lib → dist}/pluginManager.d.ts +3 -3
  49. package/dist/pluginManager.d.ts.map +1 -0
  50. package/{lib → dist}/pluginManager.js +76 -81
  51. package/dist/pluginManager.js.map +1 -0
  52. package/dist/server.d.ts.map +1 -0
  53. package/{lib → dist}/server.js +92 -116
  54. package/dist/server.js.map +1 -0
  55. package/{lib → dist}/storageService.d.ts.map +1 -1
  56. package/dist/storageService.js +41 -0
  57. package/dist/storageService.js.map +1 -0
  58. package/{lib → dist}/user.d.ts.map +1 -1
  59. package/dist/user.js +29 -0
  60. package/dist/user.js.map +1 -0
  61. package/{lib → dist}/util/mac.d.ts +1 -0
  62. package/dist/util/mac.d.ts.map +1 -0
  63. package/dist/util/mac.js +14 -0
  64. package/dist/util/mac.js.map +1 -0
  65. package/dist/version.d.ts.map +1 -0
  66. package/dist/version.js +16 -0
  67. package/dist/version.js.map +1 -0
  68. package/package.json +41 -43
  69. package/bin/homebridge +0 -17
  70. package/lib/api.d.ts.map +0 -1
  71. package/lib/api.js.map +0 -1
  72. package/lib/bridgeService.d.ts.map +0 -1
  73. package/lib/bridgeService.js.map +0 -1
  74. package/lib/childBridgeFork.d.ts.map +0 -1
  75. package/lib/childBridgeFork.js.map +0 -1
  76. package/lib/childBridgeService.d.ts.map +0 -1
  77. package/lib/childBridgeService.js.map +0 -1
  78. package/lib/cli.d.ts +0 -4
  79. package/lib/cli.d.ts.map +0 -1
  80. package/lib/cli.js +0 -111
  81. package/lib/cli.js.map +0 -1
  82. package/lib/externalPortService.js.map +0 -1
  83. package/lib/index.d.ts.map +0 -1
  84. package/lib/index.js +0 -72
  85. package/lib/index.js.map +0 -1
  86. package/lib/ipcService.d.ts.map +0 -1
  87. package/lib/ipcService.js.map +0 -1
  88. package/lib/logger.d.ts.map +0 -1
  89. package/lib/logger.js.map +0 -1
  90. package/lib/platformAccessory.d.ts.map +0 -1
  91. package/lib/platformAccessory.js.map +0 -1
  92. package/lib/plugin.d.ts.map +0 -1
  93. package/lib/plugin.js.map +0 -1
  94. package/lib/pluginManager.d.ts.map +0 -1
  95. package/lib/pluginManager.js.map +0 -1
  96. package/lib/server.d.ts.map +0 -1
  97. package/lib/server.js.map +0 -1
  98. package/lib/storageService.js +0 -70
  99. package/lib/storageService.js.map +0 -1
  100. package/lib/user.js +0 -36
  101. package/lib/user.js.map +0 -1
  102. package/lib/util/mac.d.ts.map +0 -1
  103. package/lib/util/mac.js +0 -20
  104. package/lib/util/mac.js.map +0 -1
  105. package/lib/version.d.ts.map +0 -1
  106. package/lib/version.js +0 -21
  107. package/lib/version.js.map +0 -1
  108. /package/{lib → dist}/server.d.ts +0 -0
  109. /package/{lib → dist}/storageService.d.ts +0 -0
  110. /package/{lib → dist}/user.d.ts +0 -0
  111. /package/{lib → dist}/version.d.ts +0 -0
package/README.md CHANGED
@@ -16,19 +16,19 @@
16
16
 
17
17
  <img src="https://media.giphy.com/media/10l79ICohTu4iQ/giphy.gif" align="right" alt="Unlocking Door">
18
18
 
19
- **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.
19
+ **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.
20
20
 
21
21
  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:
22
22
 
23
- * _Siri, unlock the back door._ [pictured to the right]
24
- * _Siri, open the garage door._
25
- * _Siri, turn on the coffee maker._
26
- * _Siri, turn on the living room lights._
27
- * _Siri, good morning!_
23
+ - _Siri, unlock the back door._ [pictured to the right]
24
+ - _Siri, open the garage door._
25
+ - _Siri, turn on the coffee maker._
26
+ - _Siri, turn on the living room lights._
27
+ - _Siri, good morning!_
28
28
 
29
29
  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).
30
30
 
31
- ## Community
31
+ ## Community
32
32
 
33
33
  The official Homebridge Discord server and Reddit community are where users can discuss Homebridge and ask for help.
34
34
 
@@ -79,7 +79,7 @@ HomeKit communities can also be found on both [Discord](https://discord.gg/RcV7f
79
79
 
80
80
  ### Docker
81
81
 
82
- [Install Homebridge on Docker](https://github.com/homebridge/homebridge/wiki/Install-Homebridge-on-Docker) <br> [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)
82
+ [Install Homebridge on Docker](https://github.com/homebridge/homebridge/wiki/Install-Homebridge-on-Docker) <br> [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)
83
83
 
84
84
  ---
85
85
 
@@ -97,9 +97,9 @@ HomeKit communities can also be found on both [Discord](https://discord.gg/RcV7f
97
97
 
98
98
  1. Open the Home <img src="https://user-images.githubusercontent.com/3979615/78010622-4ea1d380-738e-11ea-8a17-e6a465eeec35.png" height="16.42px"> app on your device.
99
99
  2. Tap the Home tab, then tap <img src="https://user-images.githubusercontent.com/3979615/78010869-9aed1380-738e-11ea-9644-9f46b3633026.png" height="16.42px">.
100
- 3. Tap *Add Accessory*, then scan the QR code shown in the Homebridge UI or your Homebridge logs.
100
+ 3. Tap _Add Accessory_, then scan the QR code shown in the Homebridge UI or your Homebridge logs.
101
101
 
102
- 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).
102
+ 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).
103
103
 
104
104
  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.
105
105
 
@@ -113,18 +113,17 @@ One final thing to remember is that Siri will almost always prefer its default p
113
113
 
114
114
  The https://developers.homebridge.io website contains the Homebridge API reference, available service and characteristic types, and plugin examples.
115
115
 
116
- The [Homebridge Plugin Template](https://github.com/homebridge/homebridge-plugin-template) project provides a base you can use to create your own *platform* plugin.
116
+ The [Homebridge Plugin Template](https://github.com/homebridge/homebridge-plugin-template) project provides a base you can use to create your own _platform_ plugin.
117
117
 
118
118
  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.
119
119
 
120
120
  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:
121
121
 
122
-
123
122
  ```shell
124
123
  npm link
125
124
  ```
126
125
 
127
- *You can undo this using the `npm unlink` command.*
126
+ _You can undo this using the `npm unlink` command._
128
127
 
129
128
  Then start Homebridge in debug mode:
130
129
 
@@ -150,13 +149,13 @@ To fix this, [Reset Homebridge](https://github.com/homebridge/homebridge/wiki/Co
150
149
 
151
150
  Try the following:
152
151
 
153
- 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.
154
- 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.
152
+ 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.
153
+ 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.
155
154
 
156
155
  ### Limitations
157
156
 
158
- * 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.
159
- * 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.
157
+ - 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.
158
+ - 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.
160
159
 
161
160
  ## Why Homebridge?
162
161
 
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+
3
+ //
4
+ // This executable sets up the environment and runs the Homebridge CLI.
5
+ //
6
+
7
+ import { realpathSync } from 'node:fs'
8
+ import { dirname, join } from 'node:path'
9
+ import process from 'node:process'
10
+ import { fileURLToPath, pathToFileURL } from 'node:url'
11
+
12
+ process.title = 'homebridge'
13
+
14
+ // Find the Homebridge lib
15
+ const __filename = fileURLToPath(import.meta.url)
16
+ const lib = join(dirname(realpathSync(__filename)), '../dist')
17
+
18
+ // Convert the path to a file URL
19
+ const libUrl = pathToFileURL(join(lib, 'cli.js')).href
20
+
21
+ // Run Homebridge
22
+ import(libUrl).then(({ default: run }) => run())
@@ -7,7 +7,7 @@
7
7
  "port": 51826,
8
8
  "pin": "031-45-154"
9
9
  },
10
-
10
+
11
11
  "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.",
12
12
  "ports": {
13
13
  "start": 52100,
@@ -23,8 +23,8 @@
23
23
 
24
24
  "platforms": [
25
25
  {
26
- "platform" : "PhilipsHue",
27
- "name" : "Hue"
26
+ "platform": "PhilipsHue",
27
+ "name": "Hue"
28
28
  }
29
29
  ]
30
30
  }
@@ -1,10 +1,10 @@
1
- import { EventEmitter } from "events";
2
- import * as hapNodeJs from "hap-nodejs";
3
- import { Controller, Service } from "hap-nodejs";
4
- import { AccessoryConfig, PlatformConfig } from "./bridgeService";
5
- import { Logging } from "./logger";
6
- import { PlatformAccessory } from "./platformAccessory";
7
- import { User } from "./user";
1
+ import type { Controller, Service } from 'hap-nodejs';
2
+ import type { AccessoryConfig, PlatformConfig } from './bridgeService.js';
3
+ import type { Logging } from './logger.js';
4
+ import { EventEmitter } from 'node:events';
5
+ import hapNodeJs from 'hap-nodejs';
6
+ import { PlatformAccessory } from './platformAccessory.js';
7
+ import { User } from './user.js';
8
8
  export type HAP = typeof hapNodeJs;
9
9
  export type HAPLegacyTypes = typeof hapNodeJs.LegacyTypes;
10
10
  export type PluginIdentifier = PluginName | ScopedPluginName;
@@ -37,16 +37,16 @@ export interface AccessoryPluginConstructor {
37
37
  }
38
38
  export interface AccessoryPlugin {
39
39
  /**
40
- * Optional method which will be called if a 'identify' of an Accessory is requested by HomeKit.
40
+ * Optional method which will be called if an 'identify' of an Accessory is requested by HomeKit.
41
41
  */
42
- identify?(): void;
42
+ identify?: () => void;
43
43
  /**
44
44
  * This method will be called once on startup, to query all services to be exposed by the Accessory.
45
45
  * All event handlers for characteristics should be set up before the array is returned.
46
46
  *
47
47
  * @returns {Service[]} services - returned services will be added to the Accessory
48
48
  */
49
- getServices(): Service[];
49
+ getServices: () => Service[];
50
50
  /**
51
51
  * This method will be called once on startup, to query all controllers to be exposed by the Accessory.
52
52
  * It is optional to implement.
@@ -60,7 +60,7 @@ export interface AccessoryPlugin {
60
60
  *
61
61
  * @returns {Controller[]} controllers - returned controllers will be configured for the Accessory
62
62
  */
63
- getControllers?(): Controller[];
63
+ getControllers?: () => Controller[];
64
64
  }
65
65
  export interface PlatformPluginConstructor<Config extends PlatformConfig = PlatformConfig> {
66
66
  new (logger: Logging, config: Config, api: API): DynamicPlatformPlugin | StaticPlatformPlugin | IndependentPlatformPlugin;
@@ -80,7 +80,7 @@ export interface DynamicPlatformPlugin extends PlatformPlugin {
80
80
  *
81
81
  * @param {PlatformAccessory} accessory which needs to be configured
82
82
  */
83
- configureAccessory(accessory: PlatformAccessory): void;
83
+ configureAccessory: (accessory: PlatformAccessory) => void;
84
84
  }
85
85
  /**
86
86
  * Platform that exposes all available characteristics at the start of the plugin.
@@ -95,7 +95,7 @@ export interface StaticPlatformPlugin extends PlatformPlugin {
95
95
  *
96
96
  * @param {(foundAccessories: AccessoryPlugin[]) => void} callback
97
97
  */
98
- accessories(callback: (foundAccessories: AccessoryPlugin[]) => void): void;
98
+ accessories: (callback: (foundAccessories: AccessoryPlugin[]) => void) => void;
99
99
  }
100
100
  /**
101
101
  * Platform that does not aim to add any accessories to the main bridge accessory.
@@ -154,35 +154,18 @@ export interface API {
154
154
  *
155
155
  * @param version
156
156
  */
157
- versionGreaterOrEqual(version: string): boolean;
158
- registerAccessory(accessoryName: AccessoryName, constructor: AccessoryPluginConstructor): void;
159
- registerAccessory(pluginIdentifier: PluginIdentifier, accessoryName: AccessoryName, constructor: AccessoryPluginConstructor): void;
160
- registerPlatform<Config extends PlatformConfig>(platformName: PlatformName, constructor: PlatformPluginConstructor<Config>): void;
161
- registerPlatform<Config extends PlatformConfig>(pluginIdentifier: PluginIdentifier, platformName: PlatformName, constructor: PlatformPluginConstructor<Config>): void;
162
- registerPlatformAccessories(pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]): void;
163
- updatePlatformAccessories(accessories: PlatformAccessory[]): void;
164
- unregisterPlatformAccessories(pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]): void;
165
- publishExternalAccessories(pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]): void;
166
- on(event: "didFinishLaunching", listener: () => void): this;
167
- on(event: "shutdown", listener: () => void): this;
157
+ versionGreaterOrEqual: (version: string) => boolean;
158
+ registerAccessory: ((accessoryName: AccessoryName, constructor: AccessoryPluginConstructor) => void) & ((pluginIdentifier: PluginIdentifier, accessoryName: AccessoryName, constructor: AccessoryPluginConstructor) => void);
159
+ registerPlatform: (<Config extends PlatformConfig>(platformName: PlatformName, constructor: PlatformPluginConstructor<Config>) => void) & (<Config extends PlatformConfig>(pluginIdentifier: PluginIdentifier, platformName: PlatformName, constructor: PlatformPluginConstructor<Config>) => void);
160
+ registerPlatformAccessories: (pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]) => void;
161
+ updatePlatformAccessories: (accessories: PlatformAccessory[]) => void;
162
+ unregisterPlatformAccessories: (pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]) => void;
163
+ publishExternalAccessories: (pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]) => void;
164
+ on: ((event: 'didFinishLaunching', listener: () => void) => this) & ((event: 'shutdown', listener: () => void) => this);
168
165
  }
169
166
  export declare interface HomebridgeAPI {
170
- on(event: "didFinishLaunching", listener: () => void): this;
171
- on(event: "shutdown", listener: () => void): this;
172
- on(event: InternalAPIEvent.REGISTER_ACCESSORY, listener: (accessoryName: AccessoryName, accessoryConstructor: AccessoryPluginConstructor, pluginIdentifier?: PluginIdentifier) => void): this;
173
- on(event: InternalAPIEvent.REGISTER_PLATFORM, listener: (platformName: PlatformName, platformConstructor: PlatformPluginConstructor, pluginIdentifier?: PluginIdentifier) => void): this;
174
- on(event: InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void): this;
175
- on(event: InternalAPIEvent.REGISTER_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void): this;
176
- on(event: InternalAPIEvent.UPDATE_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void): this;
177
- on(event: InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void): this;
178
- emit(event: "didFinishLaunching"): boolean;
179
- emit(event: "shutdown"): boolean;
180
- emit(event: InternalAPIEvent.REGISTER_ACCESSORY, accessoryName: AccessoryName, accessoryConstructor: AccessoryPluginConstructor, pluginIdentifier?: PluginIdentifier): boolean;
181
- emit(event: InternalAPIEvent.REGISTER_PLATFORM, platformName: PlatformName, platformConstructor: PlatformPluginConstructor, pluginIdentifier?: PluginIdentifier): boolean;
182
- emit(event: InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES, accessories: PlatformAccessory[]): boolean;
183
- emit(event: InternalAPIEvent.REGISTER_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]): boolean;
184
- emit(event: InternalAPIEvent.UPDATE_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]): boolean;
185
- emit(event: InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]): boolean;
167
+ on: ((event: 'didFinishLaunching', listener: () => void) => this) & ((event: 'shutdown', listener: () => void) => this) & ((event: InternalAPIEvent.REGISTER_ACCESSORY, listener: (accessoryName: AccessoryName, accessoryConstructor: AccessoryPluginConstructor, pluginIdentifier?: PluginIdentifier) => void) => this) & ((event: InternalAPIEvent.REGISTER_PLATFORM, listener: (platformName: PlatformName, platformConstructor: PlatformPluginConstructor, pluginIdentifier?: PluginIdentifier) => void) => this) & ((event: InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void) => this) & ((event: InternalAPIEvent.REGISTER_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void) => this) & ((event: InternalAPIEvent.UPDATE_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void) => this) & ((event: InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void) => this);
168
+ emit: ((event: 'didFinishLaunching') => boolean) & ((event: 'shutdown') => boolean) & ((event: InternalAPIEvent.REGISTER_ACCESSORY, accessoryName: AccessoryName, accessoryConstructor: AccessoryPluginConstructor, pluginIdentifier?: PluginIdentifier) => boolean) & ((event: InternalAPIEvent.REGISTER_PLATFORM, platformName: PlatformName, platformConstructor: PlatformPluginConstructor, pluginIdentifier?: PluginIdentifier) => boolean) & ((event: InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES, accessories: PlatformAccessory[]) => boolean) & ((event: InternalAPIEvent.REGISTER_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]) => boolean) & ((event: InternalAPIEvent.UPDATE_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]) => boolean) & ((event: InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]) => boolean);
186
169
  }
187
170
  export declare class HomebridgeAPI extends EventEmitter implements API {
188
171
  readonly version = 2.7;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,SAAS,MAAM,YAAY,CAAA;AAIlC,O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AI;IAWlI,gBAAgB,CAAC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,yBAAyB,GAAG,IAAI;IAC1F,gBAAgB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,yBAAyB,GAAG,IAAI;IAW9H,wBAAwB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,IAAI;IAIpG,0BAA0B,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,IAAI;IAiBtG,2BAA2B,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,IAAI;IAcnI,yBAAyB,CAAC,WAAW,EAAE,iBAAiB,EAAE,GAAG,IAAI;IAIjE,6BAA6B,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,IAAI;CAUtI"}
@@ -1,47 +1,20 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.HomebridgeAPI = exports.InternalAPIEvent = exports.APIEvent = exports.PluginType = void 0;
30
- const events_1 = require("events");
31
- const hapNodeJs = __importStar(require("hap-nodejs"));
32
- const semver_1 = __importDefault(require("semver"));
33
- const logger_1 = require("./logger");
34
- const platformAccessory_1 = require("./platformAccessory");
35
- const pluginManager_1 = require("./pluginManager");
36
- const user_1 = require("./user");
37
- const version_1 = __importDefault(require("./version"));
38
- const log = logger_1.Logger.internal;
39
- var PluginType;
1
+ import { EventEmitter } from 'node:events';
2
+ import hapNodeJs from 'hap-nodejs';
3
+ import semver from 'semver';
4
+ import { Logger } from './logger.js';
5
+ import { PlatformAccessory } from './platformAccessory.js';
6
+ import { PluginManager } from './pluginManager.js';
7
+ import { User } from './user.js';
8
+ import getVersion from './version.js';
9
+ const log = Logger.internal;
10
+ // eslint-disable-next-line no-restricted-syntax
11
+ export var PluginType;
40
12
  (function (PluginType) {
41
13
  PluginType["ACCESSORY"] = "accessory";
42
14
  PluginType["PLATFORM"] = "platform";
43
- })(PluginType || (exports.PluginType = PluginType = {}));
44
- var APIEvent;
15
+ })(PluginType || (PluginType = {}));
16
+ // eslint-disable-next-line no-restricted-syntax
17
+ export var APIEvent;
45
18
  (function (APIEvent) {
46
19
  /**
47
20
  * Event is fired once homebridge has finished with booting up and initializing all components and plugins.
@@ -54,8 +27,9 @@ var APIEvent;
54
27
  * At this stage all Accessories are already unpublished and all PlatformAccessories are already saved to disk!
55
28
  */
56
29
  APIEvent["SHUTDOWN"] = "shutdown";
57
- })(APIEvent || (exports.APIEvent = APIEvent = {}));
58
- var InternalAPIEvent;
30
+ })(APIEvent || (APIEvent = {}));
31
+ // eslint-disable-next-line no-restricted-syntax
32
+ export var InternalAPIEvent;
59
33
  (function (InternalAPIEvent) {
60
34
  InternalAPIEvent["REGISTER_ACCESSORY"] = "registerAccessory";
61
35
  InternalAPIEvent["REGISTER_PLATFORM"] = "registerPlatform";
@@ -63,27 +37,28 @@ var InternalAPIEvent;
63
37
  InternalAPIEvent["REGISTER_PLATFORM_ACCESSORIES"] = "registerPlatformAccessories";
64
38
  InternalAPIEvent["UPDATE_PLATFORM_ACCESSORIES"] = "updatePlatformAccessories";
65
39
  InternalAPIEvent["UNREGISTER_PLATFORM_ACCESSORIES"] = "unregisterPlatformAccessories";
66
- })(InternalAPIEvent || (exports.InternalAPIEvent = InternalAPIEvent = {}));
67
- class HomebridgeAPI extends events_1.EventEmitter {
40
+ })(InternalAPIEvent || (InternalAPIEvent = {}));
41
+ // eslint-disable-next-line ts/no-unsafe-declaration-merging
42
+ export class HomebridgeAPI extends EventEmitter {
68
43
  version = 2.7; // homebridge API version
69
- serverVersion = (0, version_1.default)(); // homebridge node module version
44
+ serverVersion = getVersion(); // homebridge node module version
70
45
  // ------------------ LEGACY EXPORTS FOR PRE TYPESCRIPT ------------------
71
- user = user_1.User;
46
+ user = User;
72
47
  hap = hapNodeJs;
73
48
  hapLegacyTypes = hapNodeJs.LegacyTypes; // used for older accessories/platforms
74
- platformAccessory = platformAccessory_1.PlatformAccessory;
49
+ platformAccessory = PlatformAccessory;
75
50
  // ------------------------------------------------------------------------
76
51
  constructor() {
77
52
  super();
78
53
  }
79
54
  versionGreaterOrEqual(version) {
80
- return semver_1.default.gte(this.serverVersion, version);
55
+ return semver.gte(this.serverVersion, version);
81
56
  }
82
57
  static isDynamicPlatformPlugin(platformPlugin) {
83
- return "configureAccessory" in platformPlugin;
58
+ return 'configureAccessory' in platformPlugin;
84
59
  }
85
60
  static isStaticPlatformPlugin(platformPlugin) {
86
- return "accessories" in platformPlugin;
61
+ return 'accessories' in platformPlugin;
87
62
  }
88
63
  signalFinished() {
89
64
  this.emit("didFinishLaunching" /* APIEvent.DID_FINISH_LAUNCHING */);
@@ -92,7 +67,7 @@ class HomebridgeAPI extends events_1.EventEmitter {
92
67
  this.emit("shutdown" /* APIEvent.SHUTDOWN */);
93
68
  }
94
69
  registerAccessory(pluginIdentifier, accessoryName, constructor) {
95
- if (typeof accessoryName === "function") {
70
+ if (typeof accessoryName === 'function') {
96
71
  constructor = accessoryName;
97
72
  accessoryName = pluginIdentifier;
98
73
  this.emit("registerAccessory" /* InternalAPIEvent.REGISTER_ACCESSORY */, accessoryName, constructor);
@@ -102,7 +77,7 @@ class HomebridgeAPI extends events_1.EventEmitter {
102
77
  }
103
78
  }
104
79
  registerPlatform(pluginIdentifier, platformName, constructor) {
105
- if (typeof platformName === "function") {
80
+ if (typeof platformName === 'function') {
106
81
  constructor = platformName;
107
82
  platformName = pluginIdentifier;
108
83
  this.emit("registerPlatform" /* InternalAPIEvent.REGISTER_PLATFORM */, platformName, constructor);
@@ -115,23 +90,23 @@ class HomebridgeAPI extends events_1.EventEmitter {
115
90
  this.publishExternalAccessories(pluginIdentifier, accessories);
116
91
  }
117
92
  publishExternalAccessories(pluginIdentifier, accessories) {
118
- if (!pluginManager_1.PluginManager.isQualifiedPluginIdentifier(pluginIdentifier)) {
93
+ if (!PluginManager.isQualifiedPluginIdentifier(pluginIdentifier)) {
119
94
  log.info(`One of your plugins incorrectly registered an external accessory using the platform name (${pluginIdentifier}) and not the plugin identifier. Please report this to the developer!`);
120
95
  }
121
- accessories.forEach(accessory => {
96
+ accessories.forEach((accessory) => {
122
97
  // noinspection SuspiciousTypeOfGuard
123
- if (!(accessory instanceof platformAccessory_1.PlatformAccessory)) {
124
- throw new Error(`${pluginIdentifier} attempt to register an accessory that isn't PlatformAccessory!`);
98
+ if (!(accessory instanceof PlatformAccessory)) {
99
+ throw new TypeError(`${pluginIdentifier} attempt to register an accessory that isn't PlatformAccessory!`);
125
100
  }
126
101
  accessory._associatedPlugin = pluginIdentifier;
127
102
  });
128
103
  this.emit("publishExternalAccessories" /* InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES */, accessories);
129
104
  }
130
105
  registerPlatformAccessories(pluginIdentifier, platformName, accessories) {
131
- accessories.forEach(accessory => {
106
+ accessories.forEach((accessory) => {
132
107
  // noinspection SuspiciousTypeOfGuard
133
- if (!(accessory instanceof platformAccessory_1.PlatformAccessory)) {
134
- throw new Error(`${pluginIdentifier} - ${platformName} attempt to register an accessory that isn't PlatformAccessory!`);
108
+ if (!(accessory instanceof PlatformAccessory)) {
109
+ throw new TypeError(`${pluginIdentifier} - ${platformName} attempt to register an accessory that isn't PlatformAccessory!`);
135
110
  }
136
111
  accessory._associatedPlugin = pluginIdentifier;
137
112
  accessory._associatedPlatform = platformName;
@@ -142,14 +117,13 @@ class HomebridgeAPI extends events_1.EventEmitter {
142
117
  this.emit("updatePlatformAccessories" /* InternalAPIEvent.UPDATE_PLATFORM_ACCESSORIES */, accessories);
143
118
  }
144
119
  unregisterPlatformAccessories(pluginIdentifier, platformName, accessories) {
145
- accessories.forEach(accessory => {
120
+ accessories.forEach((accessory) => {
146
121
  // noinspection SuspiciousTypeOfGuard
147
- if (!(accessory instanceof platformAccessory_1.PlatformAccessory)) {
148
- throw new Error(`${pluginIdentifier} - ${platformName} attempt to unregister an accessory that isn't PlatformAccessory!`);
122
+ if (!(accessory instanceof PlatformAccessory)) {
123
+ throw new TypeError(`${pluginIdentifier} - ${platformName} attempt to unregister an accessory that isn't PlatformAccessory!`);
149
124
  }
150
125
  });
151
126
  this.emit("unregisterPlatformAccessories" /* InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES */, accessories);
152
127
  }
153
128
  }
154
- exports.HomebridgeAPI = HomebridgeAPI;
155
129
  //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,SAAS,MAAM,YAAY,CAAA;AAClC,OAA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S,EAAE,EAAE;YAChC,qCAAqC;YACrC,IAAI,CAAC,CAAC,SAAS,YAAY,iBAAiB,CAAC,EAAE,CAAC;gBAC9C,MAAM,IAAI,SAAS,CAAC,GAAG,gBAAgB,MAAM,YAAY,mEAAmE,CAAC,CAAA;YAC/H,CAAC;QACH,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,IAAI,yFAAmD,WAAW,CAAC,CAAA;IAC1E,CAAC;CACF"}
@@ -1,11 +1,12 @@
1
- import { Accessory, Bridge, CharacteristicWarning, InterfaceName, IPAddress, MacAddress, MDNSAdvertiser } from "hap-nodejs";
2
- import { AccessoryIdentifier, AccessoryName, AccessoryPlugin, HomebridgeAPI, PlatformIdentifier, PlatformName, PluginIdentifier, StaticPlatformPlugin } from "./api";
3
- import { ExternalPortService, ExternalPortsConfiguration } from "./externalPortService";
4
- import { Logging } from "./logger";
5
- import { PlatformAccessory } from "./platformAccessory";
6
- import { Plugin } from "./plugin";
7
- import { PluginManager } from "./pluginManager";
8
- import { HomebridgeOptions } from "./server";
1
+ import type { CharacteristicWarning, InterfaceName, IPAddress, MacAddress, MDNSAdvertiser } from 'hap-nodejs';
2
+ import type { AccessoryIdentifier, AccessoryName, AccessoryPlugin, HomebridgeAPI, PlatformIdentifier, PlatformName, PluginIdentifier, StaticPlatformPlugin } from './api.js';
3
+ import type { ExternalPortsConfiguration, ExternalPortService } from './externalPortService.js';
4
+ import type { Logging } from './logger.js';
5
+ import type { Plugin } from './plugin.js';
6
+ import type { HomebridgeOptions } from './server.js';
7
+ import { Accessory, Bridge } from 'hap-nodejs';
8
+ import { PlatformAccessory } from './platformAccessory.js';
9
+ import { PluginManager } from './pluginManager.js';
9
10
  export interface BridgeConfiguration {
10
11
  name: string;
11
12
  username: MacAddress;
@@ -18,6 +19,7 @@ export interface BridgeConfiguration {
18
19
  model?: string;
19
20
  disableIpc?: boolean;
20
21
  firmwareRevision?: string;
22
+ debugModeEnabled?: boolean;
21
23
  env?: {
22
24
  DEBUG?: string;
23
25
  NODE_OPTIONS?: string;
@@ -94,7 +96,7 @@ export declare class BridgeService {
94
96
  */
95
97
  saveCachedPlatformAccessoriesOnDisk(): void;
96
98
  handleRegisterPlatformAccessories(accessories: PlatformAccessory[]): void;
97
- handleUpdatePlatformAccessories(accessories: PlatformAccessory[]): void;
99
+ handleUpdatePlatformAccessories(): void;
98
100
  handleUnregisterPlatformAccessories(accessories: PlatformAccessory[]): void;
99
101
  handlePublishExternalAccessories(accessories: PlatformAccessory[]): Promise<void>;
100
102
  createHAPAccessory(plugin: Plugin, accessoryInstance: AccessoryPlugin, displayName: string, accessoryType: AccessoryName | AccessoryIdentifier, uuidBase?: string): Accessory | undefined;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridgeService.d.ts","sourceRoot":"","sources":["../src/bridgeService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,aAAa,EACb,SAAS,EACT,UAAU,EACV,cAAc,EAGf,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC/F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEpD,OAAO,EACL,SAAS,EAET,MAAM,EASP,MAAM,YAAY,CAAA;AAInB,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAOlD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,QAA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