homebridge-framework
Version:
Framework for easy creation of homebridge plugins.
88 lines (87 loc) • 3.32 kB
TypeScript
import { HomebridgePlatform } from './homebridge-platform';
import { Service } from './service';
import { Categories as Category, Service as HapService } from 'hap-nodejs';
import { AccessoryInformation } from './accessory-information';
/**
* Represents a wrapper around HAP accessories with with support for auto-removal of unused services.
*/
export declare class Accessory {
/**
* Initializes a new Accessory instance.
* @param platform The homebridge platform.
* @param name The name that should be displayed in HomeKit.
* @param id The identifier of the accessory.
* @param subType The sub type of the accessory. May be omitted if the ID is already unique.
* @param category The category of the accessory, which determines the icon in the Apple Home app.
* @param isExternal Determines whether the accessory is an external accessory (in contrast to bridged accessories).
*/
constructor(platform: HomebridgePlatform<any>, name: string, id: string, subType?: string, category?: Category, isExternal?: boolean);
/**
* Contains the parent platform.
*/
private _platform;
/**
* Contains the platform accessory.
*/
private _platformAccessory;
/**
* Contains the name that should be displayed in HomeKit.
*/
private _name;
/**
* Gets the name that should be displayed in HomeKit.
*/
get name(): string;
/**
* Contains the identifier of the accessory. Is unique in combination with the sub type.
*/
private _id;
/**
* Gets the identifier of the accessory. Is unique in combination with the sub type.
*/
get id(): string;
/**
* Contains the sub type of the accessory. Is unique in combination with the ID.
*/
private _subType;
/**
* Gets the sub type of the accessory. Is unique in combination with the ID.
*/
get subType(): string | null;
/**
* Contains a value that determines whether the accessory is an external accessory (in contrast to bridged accessories).
*/
private _isExternal;
/**
* Gets a value that determines whether the accessory is an external accessory (in contrast to bridged accessories).
*/
get isExternal(): boolean;
/**
* Gets the unique identifier of the accessory, which is made up from the ID and the sub type.
*/
get uniqueId(): string;
/**
* Updates the accessory information service.
* @param information The accessory information.
*/
setInformation(information: AccessoryInformation): void;
/**
* Contains the services.
*/
private _services;
/**
* Gets the services.
*/
get services(): Array<Service>;
/**
* Defines a service for usage with the accessory. When defining a service, it is marked as used and thus not removed from HomeKit after the initialization.
* @param type The type of the service.
* @param name The name that should be displayed in HomeKit.
* @param subType The sub type of the service. May be omitted if the type is already unique.
*/
useService(type: typeof HapService, name: string, subType?: string): Service;
/**
* Removes all cached services that have not been defined for usage.
*/
removeUnusedServices(): void;
}