UNPKG

homebridge-tsvesync

Version:

Homebridge plugin for VeSync devices including Levoit air purifiers, humidifiers, and Etekcity smart outlets

82 lines 3.11 kB
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'; import { TSVESyncPlatform } from '../platform'; import { DeviceCapabilities, VeSyncDeviceWithPower } from '../types/device.types'; export declare abstract class BaseAccessory { protected service: Service; protected readonly platform: TSVESyncPlatform; protected readonly accessory: PlatformAccessory; protected readonly device: VeSyncDeviceWithPower; private readonly retryManager; private readonly logger; private needsRetry; private isInitialized; private initializationPromise; private initializationResolver; private isInitializing; constructor(platform: TSVESyncPlatform, accessory: PlatformAccessory, device: VeSyncDeviceWithPower); /** * Get base context for logging */ private getLogContext; /** * Set up the device-specific service */ protected abstract setupService(): void; /** * Update device-specific states */ protected abstract updateDeviceSpecificStates(details: any): Promise<void>; /** * Get device capabilities */ protected abstract getDeviceCapabilities(): DeviceCapabilities; /** * Get the device type for polling configuration */ protected getDeviceType(): string; /** * Set up the accessory services */ private setupAccessory; /** * Initialize the accessory */ initialize(): Promise<void>; private deviceDetailsCache; private lastDetailsFetch; private readonly CACHE_TTL; /** * Update the underlying device instance with the latest state from the VeSync client. * * The `tsvesync` library recreates device instances on each `client.update()`. Homebridge * accessories must keep stable handler instances, so we merge the latest device properties * into the existing instance and prime the cache so `syncDeviceState()` won't immediately * refetch details. */ applyUpdatedDeviceState(updatedDevice: VeSyncDeviceWithPower): void; /** * Sync the device state with VeSync */ syncDeviceState(): Promise<void>; /** * Helper method to convert air quality values to HomeKit format */ protected convertAirQualityToHomeKit(pm25: number): number; /** * Helper method to set up a characteristic with get/set handlers */ protected setupCharacteristic(characteristic: any, onGet?: () => Promise<CharacteristicValue>, onSet?: (value: CharacteristicValue) => Promise<void>, props?: Record<string, any>, service?: Service): void; /** * Helper method to update a characteristic value */ protected updateCharacteristicValue(characteristic: any, value: CharacteristicValue): void; /** * Persist device state to accessory context */ protected persistDeviceState(key: string, value: unknown): Promise<void>; /** * Handle device errors with appropriate recovery actions */ protected handleDeviceError(message: string, error: Error | any): Promise<void>; } //# sourceMappingURL=base.accessory.d.ts.map