homebridge 2.0.0-alpha.4 → 2.0.0-alpha.41

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 (124) hide show
  1. package/README.md +1 -1
  2. package/bin/homebridge.js +22 -0
  3. package/dist/api.d.ts +210 -0
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/api.js +140 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/bridgeService.d.ts +122 -0
  8. package/dist/bridgeService.d.ts.map +1 -0
  9. package/dist/bridgeService.js +396 -0
  10. package/dist/bridgeService.js.map +1 -0
  11. package/dist/childBridgeFork.d.ts +38 -0
  12. package/dist/childBridgeFork.d.ts.map +1 -0
  13. package/dist/childBridgeFork.js +241 -2
  14. package/dist/childBridgeFork.js.map +1 -7
  15. package/dist/childBridgeService.d.ts +204 -0
  16. package/dist/childBridgeService.d.ts.map +1 -0
  17. package/dist/childBridgeService.js +452 -0
  18. package/dist/childBridgeService.js.map +1 -0
  19. package/dist/childMatterBridgeFork.d.ts +108 -0
  20. package/dist/childMatterBridgeFork.d.ts.map +1 -0
  21. package/dist/childMatterBridgeFork.js +330 -0
  22. package/dist/childMatterBridgeFork.js.map +1 -0
  23. package/dist/childMatterBridgeService.d.ts +166 -0
  24. package/dist/childMatterBridgeService.d.ts.map +1 -0
  25. package/dist/childMatterBridgeService.js +623 -0
  26. package/dist/childMatterBridgeService.js.map +1 -0
  27. package/dist/cli.d.ts +3 -0
  28. package/dist/cli.d.ts.map +1 -0
  29. package/dist/cli.js +90 -2
  30. package/dist/cli.js.map +1 -7
  31. package/dist/externalPortService.d.ts +33 -0
  32. package/dist/externalPortService.d.ts.map +1 -0
  33. package/dist/externalPortService.js +59 -0
  34. package/dist/externalPortService.js.map +1 -0
  35. package/dist/index.d.ts +90 -1099
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +21 -2
  38. package/dist/index.js.map +1 -7
  39. package/dist/ipcService.d.ts +46 -0
  40. package/dist/ipcService.d.ts.map +1 -0
  41. package/dist/ipcService.js +62 -0
  42. package/dist/ipcService.js.map +1 -0
  43. package/dist/logger.d.ts +78 -0
  44. package/dist/logger.d.ts.map +1 -0
  45. package/dist/logger.js +138 -0
  46. package/dist/logger.js.map +1 -0
  47. package/dist/matter/index.d.ts +13 -0
  48. package/dist/matter/index.d.ts.map +1 -0
  49. package/dist/matter/index.js +12 -0
  50. package/dist/matter/index.js.map +1 -0
  51. package/dist/matter/matterBridge.d.ts +64 -0
  52. package/dist/matter/matterBridge.d.ts.map +1 -0
  53. package/dist/matter/matterBridge.js +154 -0
  54. package/dist/matter/matterBridge.js.map +1 -0
  55. package/dist/matter/matterConfigValidator.d.ts +27 -0
  56. package/dist/matter/matterConfigValidator.d.ts.map +1 -0
  57. package/dist/matter/matterConfigValidator.js +162 -0
  58. package/dist/matter/matterConfigValidator.js.map +1 -0
  59. package/dist/matter/matterDevice.d.ts +107 -0
  60. package/dist/matter/matterDevice.d.ts.map +1 -0
  61. package/dist/matter/matterDevice.js +913 -0
  62. package/dist/matter/matterDevice.js.map +1 -0
  63. package/dist/matter/matterDiagnostics.d.ts +121 -0
  64. package/dist/matter/matterDiagnostics.d.ts.map +1 -0
  65. package/dist/matter/matterDiagnostics.js +323 -0
  66. package/dist/matter/matterDiagnostics.js.map +1 -0
  67. package/dist/matter/matterErrorHandler.d.ts +113 -0
  68. package/dist/matter/matterErrorHandler.d.ts.map +1 -0
  69. package/dist/matter/matterErrorHandler.js +482 -0
  70. package/dist/matter/matterErrorHandler.js.map +1 -0
  71. package/dist/matter/matterNetworkMonitor.d.ts +65 -0
  72. package/dist/matter/matterNetworkMonitor.d.ts.map +1 -0
  73. package/dist/matter/matterNetworkMonitor.js +227 -0
  74. package/dist/matter/matterNetworkMonitor.js.map +1 -0
  75. package/dist/matter/matterServer.d.ts +110 -0
  76. package/dist/matter/matterServer.d.ts.map +1 -0
  77. package/dist/matter/matterServer.js +584 -0
  78. package/dist/matter/matterServer.js.map +1 -0
  79. package/dist/matter/matterSharedTypes.d.ts +167 -0
  80. package/dist/matter/matterSharedTypes.d.ts.map +1 -0
  81. package/dist/matter/matterSharedTypes.js +55 -0
  82. package/dist/matter/matterSharedTypes.js.map +1 -0
  83. package/dist/matter/matterTypes.d.ts +35 -0
  84. package/dist/matter/matterTypes.d.ts.map +1 -0
  85. package/dist/matter/matterTypes.js +278 -0
  86. package/dist/matter/matterTypes.js.map +1 -0
  87. package/dist/matter/portAllocator.d.ts +85 -0
  88. package/dist/matter/portAllocator.d.ts.map +1 -0
  89. package/dist/matter/portAllocator.js +296 -0
  90. package/dist/matter/portAllocator.js.map +1 -0
  91. package/dist/platformAccessory.d.ts +56 -0
  92. package/dist/platformAccessory.d.ts.map +1 -0
  93. package/dist/platformAccessory.js +105 -0
  94. package/dist/platformAccessory.js.map +1 -0
  95. package/dist/plugin.d.ts +30 -0
  96. package/dist/plugin.d.ts.map +1 -0
  97. package/dist/plugin.js +182 -0
  98. package/dist/plugin.js.map +1 -0
  99. package/dist/pluginManager.d.ts +77 -0
  100. package/dist/pluginManager.d.ts.map +1 -0
  101. package/dist/pluginManager.js +375 -0
  102. package/dist/pluginManager.js.map +1 -0
  103. package/dist/server.d.ts +67 -0
  104. package/dist/server.d.ts.map +1 -0
  105. package/dist/server.js +799 -0
  106. package/dist/server.js.map +1 -0
  107. package/dist/storageService.d.ts +13 -0
  108. package/dist/storageService.d.ts.map +1 -0
  109. package/dist/storageService.js +41 -0
  110. package/dist/storageService.js.map +1 -0
  111. package/dist/user.d.ts +13 -0
  112. package/dist/user.d.ts.map +1 -0
  113. package/dist/user.js +29 -0
  114. package/dist/user.js.map +1 -0
  115. package/dist/util/mac.d.ts +5 -0
  116. package/dist/util/mac.d.ts.map +1 -0
  117. package/dist/util/mac.js +14 -0
  118. package/dist/util/mac.js.map +1 -0
  119. package/dist/version.d.ts +3 -0
  120. package/dist/version.d.ts.map +1 -0
  121. package/dist/version.js +16 -0
  122. package/dist/version.js.map +1 -0
  123. package/package.json +31 -34
  124. package/bin/homebridge +0 -19
package/README.md CHANGED
@@ -16,7 +16,7 @@
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
 
@@ -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())
package/dist/api.d.ts ADDED
@@ -0,0 +1,210 @@
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 { getMatterClustersForHAPService, getMatterDeviceTypeForHAPService, HAPToMatterClusterMapping, HAPToMatterDeviceMapping, MatterClusters, MatterDeviceTypes } from './matter/index.js';
7
+ import { PlatformAccessory } from './platformAccessory.js';
8
+ import { User } from './user.js';
9
+ export type HAP = typeof hapNodeJs;
10
+ export type HAPLegacyTypes = typeof hapNodeJs.LegacyTypes;
11
+ export type PluginIdentifier = PluginName | ScopedPluginName;
12
+ export type PluginName = string;
13
+ export type ScopedPluginName = string;
14
+ export type AccessoryName = string;
15
+ export type PlatformName = string;
16
+ export type AccessoryIdentifier = string;
17
+ export type PlatformIdentifier = string;
18
+ export declare const enum PluginType {
19
+ ACCESSORY = "accessory",
20
+ PLATFORM = "platform"
21
+ }
22
+ /**
23
+ * The {PluginInitializer} is a method which must be the default export for every homebridge plugin.
24
+ * It is called once the plugin is loaded from disk.
25
+ */
26
+ export interface PluginInitializer {
27
+ /**
28
+ * When the initializer is called the plugin must use the provided api instance and call the appropriate
29
+ * register methods - {@link API.registerAccessory} or {@link API.registerPlatform} - in order to
30
+ * correctly register for the following startup sequence.
31
+ *
32
+ * @param {API} api
33
+ */
34
+ (api: API): void | Promise<void>;
35
+ }
36
+ export interface AccessoryPluginConstructor {
37
+ new (logger: Logging, config: AccessoryConfig, api: API): AccessoryPlugin;
38
+ }
39
+ export interface AccessoryPlugin {
40
+ /**
41
+ * Optional method which will be called if an 'identify' of an Accessory is requested by HomeKit.
42
+ */
43
+ identify?: () => void;
44
+ /**
45
+ * This method will be called once on startup, to query all services to be exposed by the Accessory.
46
+ * All event handlers for characteristics should be set up before the array is returned.
47
+ *
48
+ * @returns {Service[]} services - returned services will be added to the Accessory
49
+ */
50
+ getServices: () => Service[];
51
+ /**
52
+ * This method will be called once on startup, to query all controllers to be exposed by the Accessory.
53
+ * It is optional to implement.
54
+ *
55
+ * This includes controllers like the RemoteController or the CameraController.
56
+ * Any necessary controller specific setup should have been done when returning the array.
57
+ * In most cases the plugin will only return an array of the size 1.
58
+ *
59
+ * In the case that the Plugin does not add any additional services (returned by {@link getServices}) the
60
+ * method {@link getServices} must be defined in any way and should just return an empty array.
61
+ *
62
+ * @returns {Controller[]} controllers - returned controllers will be configured for the Accessory
63
+ */
64
+ getControllers?: () => Controller[];
65
+ }
66
+ export interface PlatformPluginConstructor<Config extends PlatformConfig = PlatformConfig> {
67
+ new (logger: Logging, config: Config, api: API): DynamicPlatformPlugin | StaticPlatformPlugin | IndependentPlatformPlugin;
68
+ }
69
+ export interface PlatformPlugin {
70
+ }
71
+ /**
72
+ * Platform that is able to dynamically add or remove accessories.
73
+ * All configured accessories are stored to disk and recreated on startup.
74
+ * Accessories can be added or removed by using {@link API.registerPlatformAccessories} or {@link API.unregisterPlatformAccessories}.
75
+ */
76
+ export interface DynamicPlatformPlugin extends PlatformPlugin {
77
+ /**
78
+ * This method is called for every PlatformAccessory, which is recreated from disk on startup.
79
+ * It should be used to properly initialize the Accessory and setup all event handlers for
80
+ * all services and their characteristics.
81
+ *
82
+ * @param {PlatformAccessory} accessory which needs to be configured
83
+ */
84
+ configureAccessory: (accessory: PlatformAccessory) => void;
85
+ }
86
+ /**
87
+ * Platform that exposes all available characteristics at the start of the plugin.
88
+ * The set of accessories can not change at runtime.
89
+ * The bridge waits for all callbacks to return before it is published and accessible by HomeKit controllers.
90
+ */
91
+ export interface StaticPlatformPlugin extends PlatformPlugin {
92
+ /**
93
+ * This method is called once at startup. The Platform should pass all accessories which need to be created
94
+ * to the callback in form of a {@link AccessoryPlugin}.
95
+ * The Platform must respond in a timely manner as otherwise the startup of the bridge would be unnecessarily delayed.
96
+ *
97
+ * @param {(foundAccessories: AccessoryPlugin[]) => void} callback
98
+ */
99
+ accessories: (callback: (foundAccessories: AccessoryPlugin[]) => void) => void;
100
+ }
101
+ /**
102
+ * Platform that does not aim to add any accessories to the main bridge accessory.
103
+ * This platform should be used if for example a plugin aims to only expose external accessories.
104
+ * It should also be used when the platform doesn't intend to expose any accessories at all, like plugins
105
+ * providing a UI for homebridge.
106
+ */
107
+ export interface IndependentPlatformPlugin extends PlatformPlugin {
108
+ }
109
+ export declare const enum APIEvent {
110
+ /**
111
+ * Event is fired once homebridge has finished with booting up and initializing all components and plugins.
112
+ * When this event is fired it is possible that the Bridge accessory isn't published yet, if homebridge still needs
113
+ * to wait for some {@see StaticPlatformPlugin | StaticPlatformPlugins} to finish accessory creation.
114
+ */
115
+ DID_FINISH_LAUNCHING = "didFinishLaunching",
116
+ /**
117
+ * This event is fired when homebridge gets shutdown. This could be a regular shutdown or an unexpected crash.
118
+ * At this stage all Accessories are already unpublished and all PlatformAccessories are already saved to disk!
119
+ */
120
+ SHUTDOWN = "shutdown"
121
+ }
122
+ export declare const enum InternalAPIEvent {
123
+ REGISTER_ACCESSORY = "registerAccessory",
124
+ REGISTER_PLATFORM = "registerPlatform",
125
+ PUBLISH_EXTERNAL_ACCESSORIES = "publishExternalAccessories",
126
+ REGISTER_PLATFORM_ACCESSORIES = "registerPlatformAccessories",
127
+ UPDATE_PLATFORM_ACCESSORIES = "updatePlatformAccessories",
128
+ UNREGISTER_PLATFORM_ACCESSORIES = "unregisterPlatformAccessories"
129
+ }
130
+ export interface API {
131
+ /**
132
+ * The homebridge API version as a floating point number.
133
+ */
134
+ readonly version: number;
135
+ /**
136
+ * The current homebridge semver version.
137
+ */
138
+ readonly serverVersion: string;
139
+ readonly user: typeof User;
140
+ readonly hap: HAP;
141
+ readonly hapLegacyTypes: HAPLegacyTypes;
142
+ readonly platformAccessory: typeof PlatformAccessory;
143
+ readonly matter: {
144
+ readonly clusters: typeof MatterClusters;
145
+ readonly deviceTypes: typeof MatterDeviceTypes;
146
+ readonly hapToMatterClusterMapping: typeof HAPToMatterClusterMapping;
147
+ readonly hapToMatterDeviceMapping: typeof HAPToMatterDeviceMapping;
148
+ readonly getMatterDeviceTypeForHAPService: typeof getMatterDeviceTypeForHAPService;
149
+ readonly getMatterClustersForHAPService: typeof getMatterClustersForHAPService;
150
+ };
151
+ /**
152
+ * Returns true if the current running homebridge version is greater or equal to the
153
+ * passed version string.
154
+ *
155
+ * Example:
156
+ *
157
+ * We assume the homebridge version 1.3.0-beta.12 ({@link serverVersion}) and the following example calls below
158
+ * ```
159
+ * versionGreaterOrEqual("1.2.0"); // will return true
160
+ * versionGreaterOrEqual("1.3.0"); // will return false (the RELEASE version 1.3.0 is bigger than the BETA version 1.3.0-beta.12)
161
+ * versionGreaterOrEqual("1.3.0-beta.8); // will return true
162
+ * ```
163
+ *
164
+ * @param version
165
+ */
166
+ versionGreaterOrEqual: (version: string) => boolean;
167
+ registerAccessory: ((accessoryName: AccessoryName, constructor: AccessoryPluginConstructor) => void) & ((pluginIdentifier: PluginIdentifier, accessoryName: AccessoryName, constructor: AccessoryPluginConstructor) => void);
168
+ registerPlatform: (<Config extends PlatformConfig>(platformName: PlatformName, constructor: PlatformPluginConstructor<Config>) => void) & (<Config extends PlatformConfig>(pluginIdentifier: PluginIdentifier, platformName: PlatformName, constructor: PlatformPluginConstructor<Config>) => void);
169
+ registerPlatformAccessories: (pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]) => void;
170
+ updatePlatformAccessories: (accessories: PlatformAccessory[]) => void;
171
+ unregisterPlatformAccessories: (pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]) => void;
172
+ publishExternalAccessories: (pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]) => void;
173
+ on: ((event: 'didFinishLaunching', listener: () => void) => this) & ((event: 'shutdown', listener: () => void) => this);
174
+ }
175
+ export declare interface HomebridgeAPI {
176
+ 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);
177
+ 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);
178
+ }
179
+ export declare class HomebridgeAPI extends EventEmitter implements API {
180
+ readonly version = 2.7;
181
+ readonly serverVersion: string;
182
+ readonly user: typeof User;
183
+ readonly hap: typeof hapNodeJs;
184
+ readonly hapLegacyTypes: typeof hapNodeJs.LegacyTypes;
185
+ readonly platformAccessory: typeof PlatformAccessory;
186
+ readonly matter: {
187
+ clusters: Record<string, unknown>;
188
+ deviceTypes: Record<string, unknown>;
189
+ hapToMatterClusterMapping: Record<string, string[]>;
190
+ hapToMatterDeviceMapping: Record<string, string>;
191
+ getMatterDeviceTypeForHAPService: typeof getMatterDeviceTypeForHAPService;
192
+ getMatterClustersForHAPService: typeof getMatterClustersForHAPService;
193
+ };
194
+ constructor();
195
+ versionGreaterOrEqual(version: string): boolean;
196
+ static isDynamicPlatformPlugin(platformPlugin: PlatformPlugin): platformPlugin is DynamicPlatformPlugin;
197
+ static isStaticPlatformPlugin(platformPlugin: PlatformPlugin): platformPlugin is StaticPlatformPlugin;
198
+ signalFinished(): void;
199
+ signalShutdown(): void;
200
+ registerAccessory(accessoryName: AccessoryName, constructor: AccessoryPluginConstructor): void;
201
+ registerAccessory(pluginIdentifier: PluginIdentifier, accessoryName: AccessoryName, constructor: AccessoryPluginConstructor): void;
202
+ registerPlatform(platformName: PlatformName, constructor: PlatformPluginConstructor): void;
203
+ registerPlatform(pluginIdentifier: PluginIdentifier, platformName: PlatformName, constructor: PlatformPluginConstructor): void;
204
+ publishCameraAccessories(pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]): void;
205
+ publishExternalAccessories(pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]): void;
206
+ registerPlatformAccessories(pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]): void;
207
+ updatePlatformAccessories(accessories: PlatformAccessory[]): void;
208
+ unregisterPlatformAccessories(pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]): void;
209
+ }
210
+ //# 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,EACL,8BAA8B,EAC9B,gCAAgC,EAChC,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,EACd,iBAAiB,EAClB,MAAM,mBAAmB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Od;;IAOM,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;WAIxC,uBAAuB,CAAC,cAAc,EAAE,cAAc,GAAG,cAAc,IAAI,qBAAqB;WAIhG,sBAAsB,CAAC,cAAc,EAAE,cAAc,GAAG,cAAc,IAAI,oBAAoB;IAI5G,cAAc,IAAI,IAAI;IAItB,cAAc,IAAI,IAAI;IAItB,iBAAiB,CAAC,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,0BAA0B,GAAG,IAAI;IAC9F,iBAAiB,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,0BAA0B,GAAG,IAAI;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"}
package/dist/api.js ADDED
@@ -0,0 +1,140 @@
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 { getMatterClustersForHAPService, getMatterDeviceTypeForHAPService, HAPToMatterClusterMapping, HAPToMatterDeviceMapping, MatterClusters, MatterDeviceTypes, } from './matter/index.js';
6
+ import { PlatformAccessory } from './platformAccessory.js';
7
+ import { PluginManager } from './pluginManager.js';
8
+ import { User } from './user.js';
9
+ import getVersion from './version.js';
10
+ const log = Logger.internal;
11
+ // eslint-disable-next-line no-restricted-syntax
12
+ export var PluginType;
13
+ (function (PluginType) {
14
+ PluginType["ACCESSORY"] = "accessory";
15
+ PluginType["PLATFORM"] = "platform";
16
+ })(PluginType || (PluginType = {}));
17
+ // eslint-disable-next-line no-restricted-syntax
18
+ export var APIEvent;
19
+ (function (APIEvent) {
20
+ /**
21
+ * Event is fired once homebridge has finished with booting up and initializing all components and plugins.
22
+ * When this event is fired it is possible that the Bridge accessory isn't published yet, if homebridge still needs
23
+ * to wait for some {@see StaticPlatformPlugin | StaticPlatformPlugins} to finish accessory creation.
24
+ */
25
+ APIEvent["DID_FINISH_LAUNCHING"] = "didFinishLaunching";
26
+ /**
27
+ * This event is fired when homebridge gets shutdown. This could be a regular shutdown or an unexpected crash.
28
+ * At this stage all Accessories are already unpublished and all PlatformAccessories are already saved to disk!
29
+ */
30
+ APIEvent["SHUTDOWN"] = "shutdown";
31
+ })(APIEvent || (APIEvent = {}));
32
+ // eslint-disable-next-line no-restricted-syntax
33
+ export var InternalAPIEvent;
34
+ (function (InternalAPIEvent) {
35
+ InternalAPIEvent["REGISTER_ACCESSORY"] = "registerAccessory";
36
+ InternalAPIEvent["REGISTER_PLATFORM"] = "registerPlatform";
37
+ InternalAPIEvent["PUBLISH_EXTERNAL_ACCESSORIES"] = "publishExternalAccessories";
38
+ InternalAPIEvent["REGISTER_PLATFORM_ACCESSORIES"] = "registerPlatformAccessories";
39
+ InternalAPIEvent["UPDATE_PLATFORM_ACCESSORIES"] = "updatePlatformAccessories";
40
+ InternalAPIEvent["UNREGISTER_PLATFORM_ACCESSORIES"] = "unregisterPlatformAccessories";
41
+ })(InternalAPIEvent || (InternalAPIEvent = {}));
42
+ // eslint-disable-next-line ts/no-unsafe-declaration-merging
43
+ export class HomebridgeAPI extends EventEmitter {
44
+ version = 2.7; // homebridge API version
45
+ serverVersion = getVersion(); // homebridge node module version
46
+ // ------------------ LEGACY EXPORTS FOR PRE TYPESCRIPT ------------------
47
+ user = User;
48
+ hap = hapNodeJs;
49
+ hapLegacyTypes = hapNodeJs.LegacyTypes; // used for older accessories/platforms
50
+ platformAccessory = PlatformAccessory;
51
+ // ------------------------------------------------------------------------
52
+ // ------------------ MATTER EXPORTS ------------------
53
+ matter = {
54
+ clusters: MatterClusters,
55
+ deviceTypes: MatterDeviceTypes,
56
+ hapToMatterClusterMapping: HAPToMatterClusterMapping,
57
+ hapToMatterDeviceMapping: HAPToMatterDeviceMapping,
58
+ getMatterDeviceTypeForHAPService,
59
+ getMatterClustersForHAPService,
60
+ };
61
+ // ------------------------------------------------------------------------
62
+ constructor() {
63
+ super();
64
+ }
65
+ versionGreaterOrEqual(version) {
66
+ return semver.gte(this.serverVersion, version);
67
+ }
68
+ static isDynamicPlatformPlugin(platformPlugin) {
69
+ return 'configureAccessory' in platformPlugin;
70
+ }
71
+ static isStaticPlatformPlugin(platformPlugin) {
72
+ return 'accessories' in platformPlugin;
73
+ }
74
+ signalFinished() {
75
+ this.emit("didFinishLaunching" /* APIEvent.DID_FINISH_LAUNCHING */);
76
+ }
77
+ signalShutdown() {
78
+ this.emit("shutdown" /* APIEvent.SHUTDOWN */);
79
+ }
80
+ registerAccessory(pluginIdentifier, accessoryName, constructor) {
81
+ if (typeof accessoryName === 'function') {
82
+ constructor = accessoryName;
83
+ accessoryName = pluginIdentifier;
84
+ this.emit("registerAccessory" /* InternalAPIEvent.REGISTER_ACCESSORY */, accessoryName, constructor);
85
+ }
86
+ else {
87
+ this.emit("registerAccessory" /* InternalAPIEvent.REGISTER_ACCESSORY */, accessoryName, constructor, pluginIdentifier);
88
+ }
89
+ }
90
+ registerPlatform(pluginIdentifier, platformName, constructor) {
91
+ if (typeof platformName === 'function') {
92
+ constructor = platformName;
93
+ platformName = pluginIdentifier;
94
+ this.emit("registerPlatform" /* InternalAPIEvent.REGISTER_PLATFORM */, platformName, constructor);
95
+ }
96
+ else {
97
+ this.emit("registerPlatform" /* InternalAPIEvent.REGISTER_PLATFORM */, platformName, constructor, pluginIdentifier);
98
+ }
99
+ }
100
+ publishCameraAccessories(pluginIdentifier, accessories) {
101
+ this.publishExternalAccessories(pluginIdentifier, accessories);
102
+ }
103
+ publishExternalAccessories(pluginIdentifier, accessories) {
104
+ if (!PluginManager.isQualifiedPluginIdentifier(pluginIdentifier)) {
105
+ 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!`);
106
+ }
107
+ accessories.forEach((accessory) => {
108
+ // noinspection SuspiciousTypeOfGuard
109
+ if (!(accessory instanceof PlatformAccessory)) {
110
+ throw new TypeError(`${pluginIdentifier} attempt to register an accessory that isn't PlatformAccessory!`);
111
+ }
112
+ accessory._associatedPlugin = pluginIdentifier;
113
+ });
114
+ this.emit("publishExternalAccessories" /* InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES */, accessories);
115
+ }
116
+ registerPlatformAccessories(pluginIdentifier, platformName, accessories) {
117
+ accessories.forEach((accessory) => {
118
+ // noinspection SuspiciousTypeOfGuard
119
+ if (!(accessory instanceof PlatformAccessory)) {
120
+ throw new TypeError(`${pluginIdentifier} - ${platformName} attempt to register an accessory that isn't PlatformAccessory!`);
121
+ }
122
+ accessory._associatedPlugin = pluginIdentifier;
123
+ accessory._associatedPlatform = platformName;
124
+ });
125
+ this.emit("registerPlatformAccessories" /* InternalAPIEvent.REGISTER_PLATFORM_ACCESSORIES */, accessories);
126
+ }
127
+ updatePlatformAccessories(accessories) {
128
+ this.emit("updatePlatformAccessories" /* InternalAPIEvent.UPDATE_PLATFORM_ACCESSORIES */, accessories);
129
+ }
130
+ unregisterPlatformAccessories(pluginIdentifier, platformName, accessories) {
131
+ accessories.forEach((accessory) => {
132
+ // noinspection SuspiciousTypeOfGuard
133
+ if (!(accessory instanceof PlatformAccessory)) {
134
+ throw new TypeError(`${pluginIdentifier} - ${platformName} attempt to unregister an accessory that isn't PlatformAccessory!`);
135
+ }
136
+ });
137
+ this.emit("unregisterPlatformAccessories" /* InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES */, accessories);
138
+ }
139
+ }
140
+ //# 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,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EACL,8BAA8B,EAC9B,gCAAgC,EAChC,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,EACd,iBAAiB,GAClB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,UAAU,MAAM,cAAc,CAAA;AAErC,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAA;AAc3B,gDAAgD;AAChD,MAAM,CAAN,IAAkB,UAGjB;AAHD,WAAkB,UAAU;IAC1B,qCAAuB,CAAA;IACvB,mCAAqB,CAAA;AACvB,CAAC,EAHiB,UAAU,KAAV,UAAU,QAG3B;AAmGD,gDAAgD;AAChD,MAAM,CAAN,IAAkB,QAajB;AAbD,WAAkB,QAAQ;IACxB;;;;OAIG;IACH,uDAA2C,CAAA;IAE3C;;;OAGG;IACH,iCAAqB,CAAA;AACvB,CAAC,EAbiB,QAAQ,KAAR,QAAQ,QAazB;AA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C;YAED,SAAS,CAAC,iBAAiB,GAAG,gBAAgB,CAAA;QAChD,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,IAAI,mFAAgD,WAAW,CAAC,CAAA;IACvE,CAAC;IAED,2BAA2B,CAAC,gBAAkC,EAAE,YAA0B,EAAE,WAAgC;QAC1H,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,iEAAiE,CAAC,CAAA;YAC7H,CAAC;YAED,SAAS,CAAC,iBAAiB,GAAG,gBAAgB,CAAA;YAC9C,SAAS,CAAC,mBAAmB,GAAG,YAAY,CAAA;QAC9C,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,IAAI,qFAAiD,WAAW,CAAC,CAAA;IACxE,CAAC;IAED,yBAAyB,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,122 @@
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
+ serialNumber?: string;
23
+ debugModeEnabled?: boolean;
24
+ env?: {
25
+ DEBUG?: string;
26
+ NODE_OPTIONS?: string;
27
+ };
28
+ }
29
+ export interface AccessoryConfig extends Record<string, any> {
30
+ accessory: AccessoryName | AccessoryIdentifier;
31
+ name: string;
32
+ uuid_base?: string;
33
+ _bridge?: BridgeConfiguration;
34
+ _matter?: {
35
+ name?: string;
36
+ port?: number;
37
+ debug?: boolean;
38
+ };
39
+ }
40
+ export interface PlatformConfig extends Record<string, any> {
41
+ platform: PlatformName | PlatformIdentifier;
42
+ name?: string;
43
+ _bridge?: BridgeConfiguration;
44
+ _matter?: {
45
+ name?: string;
46
+ port?: number;
47
+ debug?: boolean;
48
+ };
49
+ }
50
+ export interface HomebridgeConfig {
51
+ bridge: BridgeConfiguration;
52
+ /**
53
+ * @deprecated
54
+ */
55
+ mdns?: any;
56
+ accessories: AccessoryConfig[];
57
+ platforms: PlatformConfig[];
58
+ plugins?: PluginIdentifier[];
59
+ /**
60
+ * Array of disabled plugins.
61
+ * Unlike the plugins[] config which prevents plugins from being initialised at all, disabled plugins still have their alias loaded, so
62
+ * we can match config blocks of disabled plugins and show an appropriate message in the logs.
63
+ */
64
+ disabledPlugins?: PluginIdentifier[];
65
+ ports?: ExternalPortsConfiguration;
66
+ }
67
+ export interface BridgeOptions extends HomebridgeOptions {
68
+ cachedAccessoriesDir: string;
69
+ cachedAccessoriesItemName: string;
70
+ }
71
+ export interface CharacteristicWarningOpts {
72
+ ignoreSlow?: boolean;
73
+ }
74
+ export declare class BridgeService {
75
+ private api;
76
+ private pluginManager;
77
+ private externalPortService;
78
+ private bridgeOptions;
79
+ private bridgeConfig;
80
+ private _config;
81
+ bridge: Bridge;
82
+ private storageService;
83
+ private readonly allowInsecureAccess;
84
+ private cachedPlatformAccessories;
85
+ private cachedAccessoriesFileLoaded;
86
+ private readonly publishedExternalAccessories;
87
+ constructor(api: HomebridgeAPI, pluginManager: PluginManager, externalPortService: ExternalPortService, bridgeOptions: BridgeOptions, bridgeConfig: BridgeConfiguration, _config: HomebridgeConfig);
88
+ static printCharacteristicWriteWarning(plugin: Plugin, accessory: Accessory, opts: CharacteristicWarningOpts, warning: CharacteristicWarning): void;
89
+ publishBridge(): void;
90
+ /**
91
+ * Attempt to load the cached accessories from disk.
92
+ */
93
+ loadCachedPlatformAccessoriesFromDisk(): Promise<void>;
94
+ /**
95
+ * Return the name of the backup cache file
96
+ */
97
+ private get backupCacheFileName();
98
+ /**
99
+ * Create a backup of the cached file
100
+ * This is used if we ever have trouble reading the main cache file
101
+ */
102
+ private createCachedAccessoriesBackup;
103
+ /**
104
+ * Restore a cached accessories backup
105
+ * This is used if the main cache file has a JSON syntax error / is corrupted
106
+ */
107
+ private restoreCachedAccessoriesBackup;
108
+ restoreCachedPlatformAccessories(): void;
109
+ /**
110
+ * Save the cached accessories back to disk.
111
+ */
112
+ saveCachedPlatformAccessoriesOnDisk(): void;
113
+ handleRegisterPlatformAccessories(accessories: PlatformAccessory[]): void;
114
+ handleUpdatePlatformAccessories(accessories: PlatformAccessory[]): void;
115
+ handleUnregisterPlatformAccessories(accessories: PlatformAccessory[]): void;
116
+ handlePublishExternalAccessories(accessories: PlatformAccessory[]): Promise<void>;
117
+ createHAPAccessory(plugin: Plugin, accessoryInstance: AccessoryPlugin, displayName: string, accessoryType: AccessoryName | AccessoryIdentifier, uuidBase?: string): Accessory | undefined;
118
+ loadPlatformAccessories(plugin: Plugin, platformInstance: StaticPlatformPlugin, platformType: PlatformName | PlatformIdentifier, logger: Logging): Promise<void>;
119
+ teardown(): void;
120
+ private static strippingPinCode;
121
+ }
122
+ //# 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,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,QAAQ,EAAE,UAAU,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,CAAC,EAAE,cAAc,CAAA;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,CAAC,aAA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