homebridge 2.0.0-alpha.4 → 2.0.0-alpha.5

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 (70) hide show
  1. package/bin/homebridge +1 -1
  2. package/dist/api.d.ts +193 -0
  3. package/dist/api.d.ts.map +1 -0
  4. package/dist/api.js +129 -0
  5. package/dist/api.js.map +1 -0
  6. package/dist/bridgeService.d.ts +106 -0
  7. package/dist/bridgeService.d.ts.map +1 -0
  8. package/dist/bridgeService.js +390 -0
  9. package/dist/bridgeService.js.map +1 -0
  10. package/dist/childBridgeFork.d.ts +38 -0
  11. package/dist/childBridgeFork.d.ts.map +1 -0
  12. package/dist/childBridgeFork.js +241 -2
  13. package/dist/childBridgeFork.js.map +1 -7
  14. package/dist/childBridgeService.d.ts +200 -0
  15. package/dist/childBridgeService.d.ts.map +1 -0
  16. package/dist/childBridgeService.js +427 -0
  17. package/dist/childBridgeService.js.map +1 -0
  18. package/dist/cli.d.ts +3 -0
  19. package/dist/cli.d.ts.map +1 -0
  20. package/dist/cli.js +89 -2
  21. package/dist/cli.js.map +1 -7
  22. package/dist/externalPortService.d.ts +33 -0
  23. package/dist/externalPortService.d.ts.map +1 -0
  24. package/dist/externalPortService.js +59 -0
  25. package/dist/externalPortService.js.map +1 -0
  26. package/dist/index.d.ts +76 -1099
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +19 -2
  29. package/dist/index.js.map +1 -7
  30. package/dist/ipcService.d.ts +30 -0
  31. package/dist/ipcService.d.ts.map +1 -0
  32. package/dist/ipcService.js +49 -0
  33. package/dist/ipcService.js.map +1 -0
  34. package/dist/logger.d.ts +78 -0
  35. package/dist/logger.d.ts.map +1 -0
  36. package/dist/logger.js +138 -0
  37. package/dist/logger.js.map +1 -0
  38. package/dist/platformAccessory.d.ts +55 -0
  39. package/dist/platformAccessory.d.ts.map +1 -0
  40. package/dist/platformAccessory.js +98 -0
  41. package/dist/platformAccessory.js.map +1 -0
  42. package/dist/plugin.d.ts +31 -0
  43. package/dist/plugin.d.ts.map +1 -0
  44. package/dist/plugin.js +185 -0
  45. package/dist/plugin.js.map +1 -0
  46. package/dist/pluginManager.d.ts +77 -0
  47. package/dist/pluginManager.d.ts.map +1 -0
  48. package/dist/pluginManager.js +374 -0
  49. package/dist/pluginManager.js.map +1 -0
  50. package/dist/server.d.ts +58 -0
  51. package/dist/server.d.ts.map +1 -0
  52. package/dist/server.js +430 -0
  53. package/dist/server.js.map +1 -0
  54. package/dist/storageService.d.ts +13 -0
  55. package/dist/storageService.d.ts.map +1 -0
  56. package/dist/storageService.js +41 -0
  57. package/dist/storageService.js.map +1 -0
  58. package/dist/user.d.ts +13 -0
  59. package/dist/user.d.ts.map +1 -0
  60. package/dist/user.js +29 -0
  61. package/dist/user.js.map +1 -0
  62. package/dist/util/mac.d.ts +5 -0
  63. package/dist/util/mac.d.ts.map +1 -0
  64. package/dist/util/mac.js +14 -0
  65. package/dist/util/mac.js.map +1 -0
  66. package/dist/version.d.ts +3 -0
  67. package/dist/version.d.ts.map +1 -0
  68. package/dist/version.js +16 -0
  69. package/dist/version.js.map +1 -0
  70. package/package.json +7 -10
package/bin/homebridge CHANGED
@@ -16,4 +16,4 @@ const __filename = fileURLToPath(import.meta.url)
16
16
  const lib = join(dirname(realpathSync(__filename)), '../dist')
17
17
 
18
18
  // Run HomeBridge
19
- import(`${lib}/cli.js`).then(module => module.default())
19
+ import(`${lib}/cli.js`).then(({ default: run }) => run())
package/dist/api.d.ts ADDED
@@ -0,0 +1,193 @@
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
+ export type HAP = typeof hapNodeJs;
9
+ export type HAPLegacyTypes = typeof hapNodeJs.LegacyTypes;
10
+ export type PluginIdentifier = PluginName | ScopedPluginName;
11
+ export type PluginName = string;
12
+ export type ScopedPluginName = string;
13
+ export type AccessoryName = string;
14
+ export type PlatformName = string;
15
+ export type AccessoryIdentifier = string;
16
+ export type PlatformIdentifier = string;
17
+ export declare const enum PluginType {
18
+ ACCESSORY = "accessory",
19
+ PLATFORM = "platform"
20
+ }
21
+ /**
22
+ * The {PluginInitializer} is a method which must be the default export for every homebridge plugin.
23
+ * It is called once the plugin is loaded from disk.
24
+ */
25
+ export interface PluginInitializer {
26
+ /**
27
+ * When the initializer is called the plugin must use the provided api instance and call the appropriate
28
+ * register methods - {@link API.registerAccessory} or {@link API.registerPlatform} - in order to
29
+ * correctly register for the following startup sequence.
30
+ *
31
+ * @param {API} api
32
+ */
33
+ (api: API): void | Promise<void>;
34
+ }
35
+ export interface AccessoryPluginConstructor {
36
+ new (logger: Logging, config: AccessoryConfig, api: API): AccessoryPlugin;
37
+ }
38
+ export interface AccessoryPlugin {
39
+ /**
40
+ * Optional method which will be called if an 'identify' of an Accessory is requested by HomeKit.
41
+ */
42
+ identify?: () => void;
43
+ /**
44
+ * This method will be called once on startup, to query all services to be exposed by the Accessory.
45
+ * All event handlers for characteristics should be set up before the array is returned.
46
+ *
47
+ * @returns {Service[]} services - returned services will be added to the Accessory
48
+ */
49
+ getServices: () => Service[];
50
+ /**
51
+ * This method will be called once on startup, to query all controllers to be exposed by the Accessory.
52
+ * It is optional to implement.
53
+ *
54
+ * This includes controllers like the RemoteController or the CameraController.
55
+ * Any necessary controller specific setup should have been done when returning the array.
56
+ * In most cases the plugin will only return an array of the size 1.
57
+ *
58
+ * In the case that the Plugin does not add any additional services (returned by {@link getServices}) the
59
+ * method {@link getServices} must be defined in any way and should just return an empty array.
60
+ *
61
+ * @returns {Controller[]} controllers - returned controllers will be configured for the Accessory
62
+ */
63
+ getControllers?: () => Controller[];
64
+ }
65
+ export interface PlatformPluginConstructor<Config extends PlatformConfig = PlatformConfig> {
66
+ new (logger: Logging, config: Config, api: API): DynamicPlatformPlugin | StaticPlatformPlugin | IndependentPlatformPlugin;
67
+ }
68
+ export interface PlatformPlugin {
69
+ }
70
+ /**
71
+ * Platform that is able to dynamically add or remove accessories.
72
+ * All configured accessories are stored to disk and recreated on startup.
73
+ * Accessories can be added or removed by using {@link API.registerPlatformAccessories} or {@link API.unregisterPlatformAccessories}.
74
+ */
75
+ export interface DynamicPlatformPlugin extends PlatformPlugin {
76
+ /**
77
+ * This method is called for every PlatformAccessory, which is recreated from disk on startup.
78
+ * It should be used to properly initialize the Accessory and setup all event handlers for
79
+ * all services and their characteristics.
80
+ *
81
+ * @param {PlatformAccessory} accessory which needs to be configured
82
+ */
83
+ configureAccessory: (accessory: PlatformAccessory) => void;
84
+ }
85
+ /**
86
+ * Platform that exposes all available characteristics at the start of the plugin.
87
+ * The set of accessories can not change at runtime.
88
+ * The bridge waits for all callbacks to return before it is published and accessible by HomeKit controllers.
89
+ */
90
+ export interface StaticPlatformPlugin extends PlatformPlugin {
91
+ /**
92
+ * This method is called once at startup. The Platform should pass all accessories which need to be created
93
+ * to the callback in form of a {@link AccessoryPlugin}.
94
+ * The Platform must respond in a timely manner as otherwise the startup of the bridge would be unnecessarily delayed.
95
+ *
96
+ * @param {(foundAccessories: AccessoryPlugin[]) => void} callback
97
+ */
98
+ accessories: (callback: (foundAccessories: AccessoryPlugin[]) => void) => void;
99
+ }
100
+ /**
101
+ * Platform that does not aim to add any accessories to the main bridge accessory.
102
+ * This platform should be used if for example a plugin aims to only expose external accessories.
103
+ * It should also be used when the platform doesn't intend to expose any accessories at all, like plugins
104
+ * providing a UI for homebridge.
105
+ */
106
+ export interface IndependentPlatformPlugin extends PlatformPlugin {
107
+ }
108
+ export declare const enum APIEvent {
109
+ /**
110
+ * Event is fired once homebridge has finished with booting up and initializing all components and plugins.
111
+ * When this event is fired it is possible that the Bridge accessory isn't published yet, if homebridge still needs
112
+ * to wait for some {@see StaticPlatformPlugin | StaticPlatformPlugins} to finish accessory creation.
113
+ */
114
+ DID_FINISH_LAUNCHING = "didFinishLaunching",
115
+ /**
116
+ * This event is fired when homebridge gets shutdown. This could be a regular shutdown or an unexpected crash.
117
+ * At this stage all Accessories are already unpublished and all PlatformAccessories are already saved to disk!
118
+ */
119
+ SHUTDOWN = "shutdown"
120
+ }
121
+ export declare const enum InternalAPIEvent {
122
+ REGISTER_ACCESSORY = "registerAccessory",
123
+ REGISTER_PLATFORM = "registerPlatform",
124
+ PUBLISH_EXTERNAL_ACCESSORIES = "publishExternalAccessories",
125
+ REGISTER_PLATFORM_ACCESSORIES = "registerPlatformAccessories",
126
+ UPDATE_PLATFORM_ACCESSORIES = "updatePlatformAccessories",
127
+ UNREGISTER_PLATFORM_ACCESSORIES = "unregisterPlatformAccessories"
128
+ }
129
+ export interface API {
130
+ /**
131
+ * The homebridge API version as a floating point number.
132
+ */
133
+ readonly version: number;
134
+ /**
135
+ * The current homebridge semver version.
136
+ */
137
+ readonly serverVersion: string;
138
+ readonly user: typeof User;
139
+ readonly hap: HAP;
140
+ readonly hapLegacyTypes: HAPLegacyTypes;
141
+ readonly platformAccessory: typeof PlatformAccessory;
142
+ /**
143
+ * Returns true if the current running homebridge version is greater or equal to the
144
+ * passed version string.
145
+ *
146
+ * Example:
147
+ *
148
+ * We assume the homebridge version 1.3.0-beta.12 ({@link serverVersion}) and the following example calls below
149
+ * ```
150
+ * versionGreaterOrEqual("1.2.0"); // will return true
151
+ * versionGreaterOrEqual("1.3.0"); // will return false (the RELEASE version 1.3.0 is bigger than the BETA version 1.3.0-beta.12)
152
+ * versionGreaterOrEqual("1.3.0-beta.8); // will return true
153
+ * ```
154
+ *
155
+ * @param version
156
+ */
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);
165
+ }
166
+ export declare interface HomebridgeAPI {
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);
169
+ }
170
+ export declare class HomebridgeAPI extends EventEmitter implements API {
171
+ readonly version = 2.7;
172
+ readonly serverVersion: string;
173
+ readonly user: typeof User;
174
+ readonly hap: typeof hapNodeJs;
175
+ readonly hapLegacyTypes: typeof hapNodeJs.LegacyTypes;
176
+ readonly platformAccessory: typeof PlatformAccessory;
177
+ constructor();
178
+ versionGreaterOrEqual(version: string): boolean;
179
+ static isDynamicPlatformPlugin(platformPlugin: PlatformPlugin): platformPlugin is DynamicPlatformPlugin;
180
+ static isStaticPlatformPlugin(platformPlugin: PlatformPlugin): platformPlugin is StaticPlatformPlugin;
181
+ signalFinished(): void;
182
+ signalShutdown(): void;
183
+ registerAccessory(accessoryName: AccessoryName, constructor: AccessoryPluginConstructor): void;
184
+ registerAccessory(pluginIdentifier: PluginIdentifier, accessoryName: AccessoryName, constructor: AccessoryPluginConstructor): void;
185
+ registerPlatform(platformName: PlatformName, constructor: PlatformPluginConstructor): void;
186
+ registerPlatform(pluginIdentifier: PluginIdentifier, platformName: PlatformName, constructor: PlatformPluginConstructor): void;
187
+ publishCameraAccessories(pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]): void;
188
+ publishExternalAccessories(pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]): void;
189
+ registerPlatformAccessories(pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]): void;
190
+ updatePlatformAccessories(accessories: PlatformAccessory[]): void;
191
+ unregisterPlatformAccessories(pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]): void;
192
+ }
193
+ //# sourceMappingURL=api.d.ts.map
@@ -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,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAKhC,MAAM,MAAM,GAAG,GAAG,OAAO,SAAS,CAAA;AAClC,MAAM,MAAM,cAAc,GAAG,OAAO,SAAS,CAAC,WAAW,CAAA;AAEzD,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,gBAAgB,CAAA;AAC5D,MAAM,MAAM,UAAU,GAAG,MAAM,CAAA;AAC/B,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAA;AACrC,MAAM,MAAM,aAAa,GAAG,MAAM,CAAA;AAClC,MAAM,MAAM,YAAY,GAAG,MAAM,CAAA;AAEjC,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAA;AACxC,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAGvC,0BAAkB,UAAU;IAC1B,SAAS,cAAc;IACvB,QAAQ,aAAa;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAEhC;;;;;;OAMG;IACH,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAEjC;AAED,MA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s 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;
12
+ (function (PluginType) {
13
+ PluginType["ACCESSORY"] = "accessory";
14
+ PluginType["PLATFORM"] = "platform";
15
+ })(PluginType || (PluginType = {}));
16
+ // eslint-disable-next-line no-restricted-syntax
17
+ export var APIEvent;
18
+ (function (APIEvent) {
19
+ /**
20
+ * Event is fired once homebridge has finished with booting up and initializing all components and plugins.
21
+ * When this event is fired it is possible that the Bridge accessory isn't published yet, if homebridge still needs
22
+ * to wait for some {@see StaticPlatformPlugin | StaticPlatformPlugins} to finish accessory creation.
23
+ */
24
+ APIEvent["DID_FINISH_LAUNCHING"] = "didFinishLaunching";
25
+ /**
26
+ * This event is fired when homebridge gets shutdown. This could be a regular shutdown or an unexpected crash.
27
+ * At this stage all Accessories are already unpublished and all PlatformAccessories are already saved to disk!
28
+ */
29
+ APIEvent["SHUTDOWN"] = "shutdown";
30
+ })(APIEvent || (APIEvent = {}));
31
+ // eslint-disable-next-line no-restricted-syntax
32
+ export var InternalAPIEvent;
33
+ (function (InternalAPIEvent) {
34
+ InternalAPIEvent["REGISTER_ACCESSORY"] = "registerAccessory";
35
+ InternalAPIEvent["REGISTER_PLATFORM"] = "registerPlatform";
36
+ InternalAPIEvent["PUBLISH_EXTERNAL_ACCESSORIES"] = "publishExternalAccessories";
37
+ InternalAPIEvent["REGISTER_PLATFORM_ACCESSORIES"] = "registerPlatformAccessories";
38
+ InternalAPIEvent["UPDATE_PLATFORM_ACCESSORIES"] = "updatePlatformAccessories";
39
+ InternalAPIEvent["UNREGISTER_PLATFORM_ACCESSORIES"] = "unregisterPlatformAccessories";
40
+ })(InternalAPIEvent || (InternalAPIEvent = {}));
41
+ // eslint-disable-next-line ts/no-unsafe-declaration-merging
42
+ export class HomebridgeAPI extends EventEmitter {
43
+ version = 2.7; // homebridge API version
44
+ serverVersion = getVersion(); // homebridge node module version
45
+ // ------------------ LEGACY EXPORTS FOR PRE TYPESCRIPT ------------------
46
+ user = User;
47
+ hap = hapNodeJs;
48
+ hapLegacyTypes = hapNodeJs.LegacyTypes; // used for older accessories/platforms
49
+ platformAccessory = PlatformAccessory;
50
+ // ------------------------------------------------------------------------
51
+ constructor() {
52
+ super();
53
+ }
54
+ versionGreaterOrEqual(version) {
55
+ return semver.gte(this.serverVersion, version);
56
+ }
57
+ static isDynamicPlatformPlugin(platformPlugin) {
58
+ return 'configureAccessory' in platformPlugin;
59
+ }
60
+ static isStaticPlatformPlugin(platformPlugin) {
61
+ return 'accessories' in platformPlugin;
62
+ }
63
+ signalFinished() {
64
+ this.emit("didFinishLaunching" /* APIEvent.DID_FINISH_LAUNCHING */);
65
+ }
66
+ signalShutdown() {
67
+ this.emit("shutdown" /* APIEvent.SHUTDOWN */);
68
+ }
69
+ registerAccessory(pluginIdentifier, accessoryName, constructor) {
70
+ if (typeof accessoryName === 'function') {
71
+ constructor = accessoryName;
72
+ accessoryName = pluginIdentifier;
73
+ this.emit("registerAccessory" /* InternalAPIEvent.REGISTER_ACCESSORY */, accessoryName, constructor);
74
+ }
75
+ else {
76
+ this.emit("registerAccessory" /* InternalAPIEvent.REGISTER_ACCESSORY */, accessoryName, constructor, pluginIdentifier);
77
+ }
78
+ }
79
+ registerPlatform(pluginIdentifier, platformName, constructor) {
80
+ if (typeof platformName === 'function') {
81
+ constructor = platformName;
82
+ platformName = pluginIdentifier;
83
+ this.emit("registerPlatform" /* InternalAPIEvent.REGISTER_PLATFORM */, platformName, constructor);
84
+ }
85
+ else {
86
+ this.emit("registerPlatform" /* InternalAPIEvent.REGISTER_PLATFORM */, platformName, constructor, pluginIdentifier);
87
+ }
88
+ }
89
+ publishCameraAccessories(pluginIdentifier, accessories) {
90
+ this.publishExternalAccessories(pluginIdentifier, accessories);
91
+ }
92
+ publishExternalAccessories(pluginIdentifier, accessories) {
93
+ if (!PluginManager.isQualifiedPluginIdentifier(pluginIdentifier)) {
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!`);
95
+ }
96
+ accessories.forEach((accessory) => {
97
+ // noinspection SuspiciousTypeOfGuard
98
+ if (!(accessory instanceof PlatformAccessory)) {
99
+ throw new TypeError(`${pluginIdentifier} attempt to register an accessory that isn't PlatformAccessory!`);
100
+ }
101
+ accessory._associatedPlugin = pluginIdentifier;
102
+ });
103
+ this.emit("publishExternalAccessories" /* InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES */, accessories);
104
+ }
105
+ registerPlatformAccessories(pluginIdentifier, platformName, accessories) {
106
+ accessories.forEach((accessory) => {
107
+ // noinspection SuspiciousTypeOfGuard
108
+ if (!(accessory instanceof PlatformAccessory)) {
109
+ throw new TypeError(`${pluginIdentifier} - ${platformName} attempt to register an accessory that isn't PlatformAccessory!`);
110
+ }
111
+ accessory._associatedPlugin = pluginIdentifier;
112
+ accessory._associatedPlatform = platformName;
113
+ });
114
+ this.emit("registerPlatformAccessories" /* InternalAPIEvent.REGISTER_PLATFORM_ACCESSORIES */, accessories);
115
+ }
116
+ updatePlatformAccessories(accessories) {
117
+ this.emit("updatePlatformAccessories" /* InternalAPIEvent.UPDATE_PLATFORM_ACCESSORIES */, accessories);
118
+ }
119
+ unregisterPlatformAccessories(pluginIdentifier, platformName, accessories) {
120
+ accessories.forEach((accessory) => {
121
+ // noinspection SuspiciousTypeOfGuard
122
+ if (!(accessory instanceof PlatformAccessory)) {
123
+ throw new TypeError(`${pluginIdentifier} - ${platformName} attempt to unregister an accessory that isn't PlatformAccessory!`);
124
+ }
125
+ });
126
+ this.emit("unregisterPlatformAccessories" /* InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES */, accessories);
127
+ }
128
+ }
129
+ //# sourceMappingURL=api.js.map
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BAAyB,CAAC,WAAgC;QACxD,IAAI,CAAC,IAAI,iFAA+C,WAAW,CAAC,CAAA;IACtE,CAAC;IAED,6BAA6B,CAAC,gBAAkC,EAAE,YAA0B,EAAE,WAAgC;QAC5H,WAAW,CAAC,OAAO,CAAC,CAAC,SAAS,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"}
@@ -0,0 +1,106 @@
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';
10
+ export interface BridgeConfiguration {
11
+ name: string;
12
+ username: MacAddress;
13
+ pin: string;
14
+ advertiser?: MDNSAdvertiser;
15
+ port?: number;
16
+ bind?: (InterfaceName | IPAddress) | (InterfaceName | IPAddress)[];
17
+ setupID?: string[4];
18
+ manufacturer?: string;
19
+ model?: string;
20
+ disableIpc?: boolean;
21
+ firmwareRevision?: string;
22
+ env?: {
23
+ DEBUG?: string;
24
+ NODE_OPTIONS?: string;
25
+ };
26
+ }
27
+ export interface AccessoryConfig extends Record<string, any> {
28
+ accessory: AccessoryName | AccessoryIdentifier;
29
+ name: string;
30
+ uuid_base?: string;
31
+ _bridge?: BridgeConfiguration;
32
+ }
33
+ export interface PlatformConfig extends Record<string, any> {
34
+ platform: PlatformName | PlatformIdentifier;
35
+ name?: string;
36
+ _bridge?: BridgeConfiguration;
37
+ }
38
+ export interface HomebridgeConfig {
39
+ bridge: BridgeConfiguration;
40
+ accessories: AccessoryConfig[];
41
+ platforms: PlatformConfig[];
42
+ plugins?: PluginIdentifier[];
43
+ /**
44
+ * Array of disabled plugins.
45
+ * Unlike the plugins[] config which prevents plugins from being initialised at all, disabled plugins still have their alias loaded, so
46
+ * we can match config blocks of disabled plugins and show an appropriate message in the logs.
47
+ */
48
+ disabledPlugins?: PluginIdentifier[];
49
+ ports?: ExternalPortsConfiguration;
50
+ }
51
+ export interface BridgeOptions extends HomebridgeOptions {
52
+ cachedAccessoriesDir: string;
53
+ cachedAccessoriesItemName: string;
54
+ }
55
+ export interface CharacteristicWarningOpts {
56
+ ignoreSlow?: boolean;
57
+ }
58
+ export declare class BridgeService {
59
+ private api;
60
+ private pluginManager;
61
+ private externalPortService;
62
+ private bridgeOptions;
63
+ private bridgeConfig;
64
+ private config;
65
+ bridge: Bridge;
66
+ private storageService;
67
+ private readonly allowInsecureAccess;
68
+ private cachedPlatformAccessories;
69
+ private cachedAccessoriesFileLoaded;
70
+ private readonly publishedExternalAccessories;
71
+ constructor(api: HomebridgeAPI, pluginManager: PluginManager, externalPortService: ExternalPortService, bridgeOptions: BridgeOptions, bridgeConfig: BridgeConfiguration, config: HomebridgeConfig);
72
+ static printCharacteristicWriteWarning(plugin: Plugin, accessory: Accessory, opts: CharacteristicWarningOpts, warning: CharacteristicWarning): void;
73
+ publishBridge(): void;
74
+ /**
75
+ * Attempt to load the cached accessories from disk.
76
+ */
77
+ loadCachedPlatformAccessoriesFromDisk(): Promise<void>;
78
+ /**
79
+ * Return the name of the backup cache file
80
+ */
81
+ private get backupCacheFileName();
82
+ /**
83
+ * Create a backup of the cached file
84
+ * This is used if we ever have trouble reading the main cache file
85
+ */
86
+ private createCachedAccessoriesBackup;
87
+ /**
88
+ * Restore a cached accessories backup
89
+ * This is used if the main cache file has a JSON syntax error / is corrupted
90
+ */
91
+ private restoreCachedAccessoriesBackup;
92
+ restoreCachedPlatformAccessories(): void;
93
+ /**
94
+ * Save the cached accessories back to disk.
95
+ */
96
+ saveCachedPlatformAccessoriesOnDisk(): void;
97
+ handleRegisterPlatformAccessories(accessories: PlatformAccessory[]): void;
98
+ handleUpdatePlatformAccessories(): void;
99
+ handleUnregisterPlatformAccessories(accessories: PlatformAccessory[]): void;
100
+ handlePublishExternalAccessories(accessories: PlatformAccessory[]): Promise<void>;
101
+ createHAPAccessory(plugin: Plugin, accessoryInstance: AccessoryPlugin, displayName: string, accessoryType: AccessoryName | AccessoryIdentifier, uuidBase?: string): Accessory | undefined;
102
+ loadPlatformAccessories(plugin: Plugin, platformInstance: StaticPlatformPlugin, platformType: PlatformName | PlatformIdentifier, logger: Logging): Promise<void>;
103
+ teardown(): void;
104
+ private static strippingPinCode;
105
+ }
106
+ //# sourceMappingURL=bridgeService.d.ts.map
@@ -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,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