homebridge-levoit-humidifiers
Version:
Homebridge plugin for Levoit Humidifiers
71 lines • 2.74 kB
TypeScript
import { Service } from 'homebridge';
import Platform, { VeSyncPlatformAccessory } from './platform';
import VeSyncFan from './api/VeSyncFan';
export type AccessoryThisType = ThisType<{
humidifierService: Service;
platform: Platform;
device: VeSyncFan;
accessory: VeSyncPlatformAccessory;
updateAllCharacteristics: () => void;
}>;
/**
* VeSyncAccessory represents a single Levoit humidifier device in HomeKit.
* It manages all services and characteristics for the device, including background
* polling to keep device state synchronized without blocking HomeKit read requests.
*/
export default class VeSyncAccessory {
private readonly platform;
private readonly accessory;
private readonly humidifierService;
private readonly humiditySensorService;
private readonly lightService;
private readonly sleepService;
private readonly displayService;
private readonly mistService;
private readonly warmMistService;
private readonly autoProService;
/**
* Background polling interval to keep device state fresh.
* Polls every 30 seconds to balance freshness with API quota limits.
* The VeSync API has daily quotas (3200 + 1500 * device count), so we
* need to be conservative with polling frequency.
*/
private pollingInterval;
private readonly POLLING_INTERVAL_MS;
get UUID(): string;
private get device();
constructor(platform: Platform, accessory: VeSyncPlatformAccessory);
private setupAccessoryInfo;
private setupHumidifierService;
/**
* Gets or creates a service, updating its name.
* Returns undefined and removes the service if the accessory config disables it.
*/
private getOrCreateService;
private setupMistService;
private setupDisplayService;
private setupHumiditySensorService;
private setupWarmMistService;
private setupSleepService;
private setupLightService;
private setupAutoProService;
/**
* Starts background polling to periodically update device state.
* This ensures characteristics always have fresh data without blocking
* HomeKit read requests, which prevents "slow to respond" warnings.
*/
private startPolling;
/**
* Stops background polling.
* Should be called when the accessory is removed to clean up resources.
*/
stopPolling(): void;
/**
* Updates all HomeKit characteristics to match current device state.
* Call this after any device command to immediately reflect changes in HomeKit.
*/
updateAllCharacteristics(): void;
private updateHumidifierCharacteristics;
private updateOptionalServiceCharacteristics;
}
//# sourceMappingURL=VeSyncAccessory.d.ts.map