import type { API, Characteristic, CharacteristicValue, Service } from 'homebridge'; import type { GoveePlatform } from '../platform.js'; import type { GoveePlatformAccessoryWithControl, DeviceCommand, ExternalUpdateParams } from '../types.js'; type HapCharacteristic = API['hap']['Characteristic']; type HapService = API['hap']['Service']; /** * Base class for all Govee device handlers. * Provides common functionality for device initialization, caching, and updates. */ export declare abstract class GoveeDeviceBase { protected readonly platform: GoveePlatform; protected readonly accessory: GoveePlatformAccessoryWithControl; protected readonly hapChar: HapCharacteristic; protected readonly hapServ: HapService; protected cacheState: 'on' | 'off'; protected initialised: boolean; protected readonly deviceConf: Record; constructor(platform: GoveePlatform, accessory: GoveePlatformAccessoryWithControl); /** * Initialize the device. Called after constructor. * Override in subclasses to set up services and characteristics. */ abstract init(): void; /** * Handle external updates from AWS/LAN/BLE/HTTP. * Override in subclasses to process device-specific updates. */ abstract externalUpdate(params: ExternalUpdateParams): void | Promise; /** * Get the primary service for this device. * Returns undefined for diagnostic/template devices that don't expose HomeKit services. */ abstract get service(): Service | undefined; /** * Clean up resources (intervals, timers, listeners) when the device is removed or the plugin shuts down. * Override in subclasses that allocate persistent resources. */ destroy(): void; /** * Log device initialization options */ protected logInitOptions(opts: Record): void; /** * Send a device update command */ protected sendDeviceUpdate(command: DeviceCommand): Promise; /** * Handle errors during internal updates. * Logs the error, reverts the characteristic after a timeout, and throws HAP error. */ protected handleUpdateError(err: unknown, characteristic: Characteristic, revertValue: CharacteristicValue, revertDelay?: number): never; /** * Remove a service if it exists */ protected removeServiceIfExists(serviceName: keyof HapService): void; /** * Remove multiple services at once */ protected removeServices(...serviceNames: (keyof HapService)[]): void; /** * Get or add a service by service type */ protected getOrAddService(ServiceClass: any): Service; /** * Add a characteristic to a service if it doesn't exist */ protected addCharacteristicIfMissing(service: Service, CharacteristicClass: any): Characteristic; /** * Add a custom characteristic with optional onSet handler * Returns the characteristic or undefined if the class doesn't exist */ protected addCustomCharacteristic(service: Service, characteristicClass: any, onSetHandler?: (value: any) => Promise): Characteristic | undefined; /** * Remove a characteristic from a service if it exists */ protected removeCharacteristicIfExists(service: Service, CharacteristicClass: any): void; /** * Update the online status of the accessory */ protected updateOnlineStatus(online: boolean): void; /** * Get control flags for this device */ protected get useAwsControl(): boolean; protected get useLanControl(): boolean; protected get useBleControl(): boolean; protected get hasAwsControl(): boolean; protected get hasLanControl(): boolean; protected get hasBleControl(): boolean; protected get isBLEOnly(): boolean; /** * Get the device model */ protected get deviceModel(): string; /** * Get the device ID */ protected get deviceId(): string; } export default GoveeDeviceBase;