import { EventEmitter } from "events" ; import { Accessory , AccessoryEventTypes , CameraController , Categories , Controller , ControllerConstructor , LegacyCameraSource , SerializedAccessory , Service , VoidCallback , WithUUID , } from "hap-nodejs" ; import { PlatformName , PluginIdentifier , PluginName } from "./api" ; export type UnknownContext = Record < string , any > ; export interface SerializedPlatformAccessory < T extends UnknownContext = UnknownContext > extends SerializedAccessory { plugin : PluginName ; platform : PlatformName ; context : T ; } export const enum PlatformAccessoryEvent { IDENTIFY = "identify" } export declare interface PlatformAccessory { on ( event , listener ) : this ; emit ( event ) : boolean ; } export class PlatformAccessory < T extends UnknownContext = UnknownContext > extends EventEmitter { private static injectedAccessory ? : Accessory ; _associatedPlugin ? : PluginIdentifier ; _associatedPlatform ? : PlatformName ; _associatedHAPAccessory : Accessory ; displayName : string ; UUID : string ; category : Categories ; services : Service [ ] = [ ] ; deprecated reachable = false ; /**
     * This is a way for Plugin developers to store custom data with their accessory
     */ public context : T = { } as T ; constructor ( displayName , uuid , category ? ) { super ( ) ; this . _associatedHAPAccessory = PlatformAccessory . injectedAccessory ? PlatformAccessory . injectedAccessory : new Accessory ( displayName , uuid ) ; if ( category ) { this . _associatedHAPAccessory . category = category ; } this . displayName = this . _associatedHAPAccessory . displayName ; this . UUID = this . _associatedHAPAccessory . UUID ; this . category = category || Categories . OTHER ; this . services = this . _associatedHAPAccessory . services ; this . _associatedHAPAccessory . on ( AccessoryEventTypes . IDENTIFY , ( paired , callback ) => { this . emit ( PlatformAccessoryEvent . IDENTIFY , paired , ( ) => { } ) ; callback ( ) ; } ) ; } public addService ( service , ... constructorArgs ) { return this . _associatedHAPAccessory . addService ( service , ... constructorArgs ) ; } public removeService ( service ) { this . _associatedHAPAccessory . removeService ( service ) ; } public getService < T extends WithUUID < typeof Service > > ( name ) { return this . _associatedHAPAccessory . getService ( name ) ; } param uuid param subType deprecated use  getServiceById directly
      public getServiceByUUIDAndSubType < T extends WithUUID < typeof Service > > ( uuid , subType ) { return this . getServiceById ( uuid , subType ) ; } public getServiceById < T extends WithUUID < typeof Service > > ( uuid , subType ) { return this . _associatedHAPAccessory . getServiceById ( uuid , subType ) ; } param reachable deprecated public updateReachability ( reachable ) { this . reachable = reachable ; } param cameraSource deprecated see  https public configureCameraSource ( cameraSource ) { return this . _associatedHAPAccessory . configureCameraSource ( cameraSource ) ; } /**
     * Configures a new controller for the given accessory.
     * See  https .
     *
     *  param controller public configureController ( controller ) { this . _associatedHAPAccessory . configureController ( controller ) ; } /**
     * Removes a configured controller from the given accessory.
     * See  https .
     *
     *  param controller public removeController ( controller ) { this . _associatedHAPAccessory . removeController ( controller ) ; } static serialize ( accessory ) { return { plugin : accessory . _associatedPlugin ! , platform : accessory . _associatedPlatform ! , context : accessory . context , ... Accessory . serialize ( accessory . _associatedHAPAccessory ) , } ; } static deserialize ( json ) { const accessory = Accessory . deserialize ( json ) ; PlatformAccessory . injectedAccessory = accessory ; const platformAccessory = new PlatformAccessory ( accessory . displayName , accessory . UUID ) ; PlatformAccessory . injectedAccessory = undefined ; platformAccessory . _associatedPlugin = json . plugin ; platformAccessory . _associatedPlatform = json . platform ; platformAccessory . context = json . context ; platformAccessory . category = json . category ; return platformAccessory ; } }