UNPKG

homebridge-framework

Version:
67 lines (66 loc) 2.32 kB
import { Service as HapService, Characteristic as HapCharacteristic, CharacteristicValue } from 'hap-nodejs'; import { Accessory } from './accessory'; import { Characteristic } from './characteristic'; /** * Represents a wrapper around HAP services with with support for auto-removal of unused characteristics. */ export declare class Service { /** * Initializes a new Service instance. * @param accessory The parent accessory. * @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. */ constructor(accessory: Accessory, type: typeof HapService, name: string, subType?: string); /** * Contains the parent accessory. */ private _accessory; /** * Contains the HAP service. */ private _hapService; /** * Contains the type of the service. */ private _type; /** * Gets the type of the service. */ get type(): typeof HapService; /** * 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 sub type of the service. May be omitted if the type is already unique. */ private _subType; /** * Gets the sub type of the service. May be omitted if the type is already unique. */ get subType(): string | null; /** * Contains the characteristics. */ private _characteristics; /** * Gets the characteristics. */ get characteristics(): Array<Characteristic<CharacteristicValue>>; /** * Defines a characteristic for usage with the service. When defining a characteristic, it is marked as used and thus not removed from HomeKit after the initialization. * @param type The type of the characteristic. * @param value The initial value. If omitted, the cached value is used. */ useCharacteristic<TValue extends CharacteristicValue>(type: typeof HapCharacteristic, value?: TValue): Characteristic<TValue>; /** * Removes all cached characteristics that have not been defined for usage. */ removeUnusedCharacteristics(): void; }