UNPKG

homebridge-tsvesync

Version:

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

67 lines 1.83 kB
import { PluginLogger } from './logger'; /** * Manages API call quotas to prevent exceeding VeSync's daily limits * Based on the formula: 3200 + 1500 * (number of devices) */ export declare class QuotaManager { private readonly logger; private deviceCount; private apiCallCount; private lastResetDate; private dailyQuota; private readonly BASE_QUOTA; private readonly DEVICE_QUOTA_MULTIPLIER; private readonly QUOTA_BUFFER; private readonly HIGH_PRIORITY_METHODS; private lastQuotaLogTime; private readonly QUOTA_LOG_INTERVAL; constructor(logger: PluginLogger, deviceCount?: number, config?: { bufferPercentage?: number; priorityMethods?: string[]; }); /** * Calculate the daily quota based on the number of devices */ private calculateDailyQuota; /** * Get the current date in YYYY-MM-DD format */ private getCurrentDate; /** * Check if the quota should be reset (new day) */ private checkAndResetQuota; /** * Update the device count and recalculate the quota */ updateDeviceCount(count: number): void; /** * Check if an API call can be made based on the current quota */ canMakeApiCall(methodName: string): boolean; /** * Record an API call */ recordApiCall(methodName: string): void; /** * Log the remaining quota every 5 minutes */ private logRemainingQuota; /** * Get the current API call count */ getApiCallCount(): number; /** * Get the daily quota */ getDailyQuota(): number; /** * Get the remaining quota */ getRemainingQuota(): number; /** * Get the quota usage percentage */ getQuotaUsagePercentage(): number; } //# sourceMappingURL=quota-manager.d.ts.map