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";
|
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 |
|
23 |
|
24 |
|
25 | export interface PluginInitializer {
|
26 | |
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
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 |
|
41 |
|
42 | identify?(): void;
|
43 | |
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | getServices(): Service[];
|
50 | |
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 |
|
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 |
|
72 |
|
73 |
|
74 |
|
75 | export interface DynamicPlatformPlugin extends PlatformPlugin {
|
76 | |
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 | configureAccessory(accessory: PlatformAccessory): void;
|
84 | }
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 | export interface StaticPlatformPlugin extends PlatformPlugin {
|
91 | |
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 | accessories(callback: (foundAccessories: AccessoryPlugin[]) => void): void;
|
99 | }
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 | export interface IndependentPlatformPlugin extends PlatformPlugin {
|
107 | }
|
108 | export declare const enum APIEvent {
|
109 | |
110 |
|
111 |
|
112 |
|
113 |
|
114 | DID_FINISH_LAUNCHING = "didFinishLaunching",
|
115 | |
116 |
|
117 |
|
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 |
|
132 |
|
133 | readonly version: number;
|
134 | |
135 |
|
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 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
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 | /**
|
166 | * @deprecated use {@link publishExternalAccessories} directly to publish a standalone Accessory
|
167 | */
|
168 | publishCameraAccessories(pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]): void;
|
169 | publishExternalAccessories(pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]): void;
|
170 | on(event: "didFinishLaunching", listener: () => void): this;
|
171 | on(event: "shutdown", listener: () => void): this;
|
172 | }
|
173 | export declare interface HomebridgeAPI {
|
174 | on(event: "didFinishLaunching", listener: () => void): this;
|
175 | on(event: "shutdown", listener: () => void): this;
|
176 | on(event: InternalAPIEvent.REGISTER_ACCESSORY, listener: (accessoryName: AccessoryName, accessoryConstructor: AccessoryPluginConstructor, pluginIdentifier?: PluginIdentifier) => void): this;
|
177 | on(event: InternalAPIEvent.REGISTER_PLATFORM, listener: (platformName: PlatformName, platformConstructor: PlatformPluginConstructor, pluginIdentifier?: PluginIdentifier) => void): this;
|
178 | on(event: InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void): this;
|
179 | on(event: InternalAPIEvent.REGISTER_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void): this;
|
180 | on(event: InternalAPIEvent.UPDATE_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void): this;
|
181 | on(event: InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES, listener: (accessories: PlatformAccessory[]) => void): this;
|
182 | emit(event: "didFinishLaunching"): boolean;
|
183 | emit(event: "shutdown"): boolean;
|
184 | emit(event: InternalAPIEvent.REGISTER_ACCESSORY, accessoryName: AccessoryName, accessoryConstructor: AccessoryPluginConstructor, pluginIdentifier?: PluginIdentifier): boolean;
|
185 | emit(event: InternalAPIEvent.REGISTER_PLATFORM, platformName: PlatformName, platformConstructor: PlatformPluginConstructor, pluginIdentifier?: PluginIdentifier): boolean;
|
186 | emit(event: InternalAPIEvent.PUBLISH_EXTERNAL_ACCESSORIES, accessories: PlatformAccessory[]): boolean;
|
187 | emit(event: InternalAPIEvent.REGISTER_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]): boolean;
|
188 | emit(event: InternalAPIEvent.UPDATE_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]): boolean;
|
189 | emit(event: InternalAPIEvent.UNREGISTER_PLATFORM_ACCESSORIES, accessories: PlatformAccessory[]): boolean;
|
190 | }
|
191 | export declare class HomebridgeAPI extends EventEmitter implements API {
|
192 | readonly version = 2.7;
|
193 | readonly serverVersion: string;
|
194 | readonly user: typeof User;
|
195 | readonly hap: typeof hapNodeJs;
|
196 | readonly hapLegacyTypes: typeof hapNodeJs.LegacyTypes;
|
197 | readonly platformAccessory: typeof PlatformAccessory;
|
198 | constructor();
|
199 | versionGreaterOrEqual(version: string): boolean;
|
200 | static isDynamicPlatformPlugin(platformPlugin: PlatformPlugin): platformPlugin is DynamicPlatformPlugin;
|
201 | static isStaticPlatformPlugin(platformPlugin: PlatformPlugin): platformPlugin is StaticPlatformPlugin;
|
202 | signalFinished(): void;
|
203 | signalShutdown(): void;
|
204 | registerAccessory(accessoryName: AccessoryName, constructor: AccessoryPluginConstructor): void;
|
205 | registerAccessory(pluginIdentifier: PluginIdentifier, accessoryName: AccessoryName, constructor: AccessoryPluginConstructor): void;
|
206 | registerPlatform(platformName: PlatformName, constructor: PlatformPluginConstructor): void;
|
207 | registerPlatform(pluginIdentifier: PluginIdentifier, platformName: PlatformName, constructor: PlatformPluginConstructor): void;
|
208 | publishCameraAccessories(pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]): void;
|
209 | publishExternalAccessories(pluginIdentifier: PluginIdentifier, accessories: PlatformAccessory[]): void;
|
210 | registerPlatformAccessories(pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]): void;
|
211 | updatePlatformAccessories(accessories: PlatformAccessory[]): void;
|
212 | unregisterPlatformAccessories(pluginIdentifier: PluginIdentifier, platformName: PlatformName, accessories: PlatformAccessory[]): void;
|
213 | }
|
214 | //# sourceMappingURL=api.d.ts.map |
\ | No newline at end of file |