UNPKG

3.38 kBTypeScriptView Raw
1import { EventEmitter } from "events";
2import { Accessory, CameraController, Categories, Controller, ControllerConstructor, LegacyCameraSource, SerializedAccessory, Service, WithUUID } from "hap-nodejs";
3import { ConstructorArgs } from "hap-nodejs/dist/types";
4import { PlatformName, PluginIdentifier, PluginName } from "./api";
5export type UnknownContext = Record<string, any>;
6export interface SerializedPlatformAccessory<T extends UnknownContext = UnknownContext> extends SerializedAccessory {
7 plugin: PluginName;
8 platform: PlatformName;
9 context: T;
10}
11export declare const enum PlatformAccessoryEvent {
12 IDENTIFY = "identify"
13}
14export declare interface PlatformAccessory {
15 on(event: "identify", listener: () => void): this;
16 emit(event: "identify"): boolean;
17}
18export declare class PlatformAccessory<T extends UnknownContext = UnknownContext> extends EventEmitter {
19 private static injectedAccessory?;
20 _associatedPlugin?: PluginIdentifier;
21 _associatedPlatform?: PlatformName;
22 _associatedHAPAccessory: Accessory;
23 displayName: string;
24 UUID: string;
25 category: Categories;
26 services: Service[];
27 /**
28 * @deprecated reachability has no effect and isn't supported anymore
29 */
30 reachable: boolean;
31 /**
32 * This is a way for Plugin developers to store custom data with their accessory
33 */
34 context: T;
35 constructor(displayName: string, uuid: string, category?: Categories);
36 addService(service: Service): Service;
37 addService<S extends typeof Service>(serviceConstructor: S, ...constructorArgs: ConstructorArgs<S>): Service;
38 removeService(service: Service): void;
39 getService<T extends WithUUID<typeof Service>>(name: string | T): Service | undefined;
40 /**
41 *
42 * @param uuid
43 * @param subType
44 * @deprecated use {@link getServiceById} directly
45 */
46 getServiceByUUIDAndSubType<T extends WithUUID<typeof Service>>(uuid: string | T, subType: string): Service | undefined;
47 getServiceById<T extends WithUUID<typeof Service>>(uuid: string | T, subType: string): Service | undefined;
48 /**
49 *
50 * @param reachable
51 * @deprecated reachability has no effect and isn't supported anymore
52 */
53 updateReachability(reachable: boolean): void;
54 /**
55 *
56 * @param cameraSource
57 * @deprecated see {@link https://developers.homebridge.io/HAP-NodeJS/classes/accessory.html#configurecamerasource | Accessory.configureCameraSource}
58 */
59 configureCameraSource(cameraSource: LegacyCameraSource): CameraController;
60 /**
61 * Configures a new controller for the given accessory.
62 * See {@link https://developers.homebridge.io/HAP-NodeJS/classes/accessory.html#configurecontroller | Accessory.configureController}.
63 *
64 * @param controller
65 */
66 configureController(controller: Controller | ControllerConstructor): void;
67 /**
68 * Removes a configured controller from the given accessory.
69 * See {@link https://developers.homebridge.io/HAP-NodeJS/classes/accessory.html#removecontroller | Accessory.removeController}.
70 *
71 * @param controller
72 */
73 removeController(controller: Controller): void;
74 static serialize(accessory: PlatformAccessory): SerializedPlatformAccessory;
75 static deserialize(json: SerializedPlatformAccessory): PlatformAccessory;
76}
77//# sourceMappingURL=platformAccessory.d.ts.map
\No newline at end of file