homebridge-framework
Version:
Framework for easy creation of homebridge plugins.
80 lines (79 loc) • 3.22 kB
TypeScript
import { Logger } from 'homebridge';
import { Accessory } from './accessory';
import { Categories as Category } from 'hap-nodejs';
/**
* Represents the base class for a platform on homebridge. It exposes the homebridge API, logging, configuration and lifecycle events.
*/
export declare abstract class HomebridgePlatform<TConfiguration> {
/**
* Is called when the platform is registered and cached accessories are loaded. Overwrite this function to add new accessories.
* @returns Returns either void or a promise if you want to intialize accessories asynchronously.
*/
initialize(): Promise<void> | void;
/**
* Is called when the platform is destroyed and homebridge is shut down. Overwrite this function to close open connections.
* @returns Returns either void or a promise if you want to close connections asynchronously.
*/
destroy(): Promise<void> | void;
/**
* Gets the name of the plugin. This should be the same name as the NPM package.
*/
abstract get pluginName(): string;
/**
* Gets the name of the platform. This name is used in the config.json file to identify the platform.
*/
abstract get platformName(): string;
/**
* Contains the homebridge API.
*/
private _api;
/**
* Contains the logger.
*/
private _logger;
/**
* Gets the logger.
*/
get logger(): Logger;
/**
* Contains the platform configuration.
*/
private _configuration;
/**
* Gets the platform configuration.
*/
get configuration(): TConfiguration;
/**
* Contains the cached accessories.
*/
private _cachedPlatformAccessories;
/**
* Contains the accessories.
*/
private _accessories;
/**
* Gets the accessories.
*/
get accessories(): Array<Accessory>;
/**
* Defines an accessory for usage with the platform. When defining an accessory, it is marked as used and thus not removed from HomeKit after the initialization.
* @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).
*/
useAccessory(name: string, id: string, subType?: string, category?: Category, isExternal?: boolean): Accessory;
/**
* Defines an external accessory for usage with the 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.
*/
useExternalAccessory(name: string, id: string, subType?: string, category?: Category): Accessory;
/**
* Unregisters all cached accessories that have not been defined for usage.
*/
removeUnusedAccessories(): void;
}