/** * VeSync API Device Library */ import { Session, SessionStore } from './session'; import { VeSyncBaseDevice } from './vesyncBaseDevice'; import { Logger } from './logger'; /** * Device exclusion configuration */ export interface ExcludeConfig { type?: string[]; model?: string[]; name?: string[]; namePattern?: string[]; id?: string[]; } /** * VeSync Manager Class */ export declare class VeSync { private _debug; private _redact; private _energyUpdateInterval; private _energyCheck; private _devList; private _lastUpdateTs; private _inProcess; private _excludeConfig; private _appId; private _terminalId; private _region; private _countryCodeOverride; private _apiUrlOverride; private _sessionStore?; private _onTokenChange?; private _loginPromise; username: string; password: string; token: string | null; accountId: string | null; countryCode: string | null; devices: VeSyncBaseDevice[] | null; enabled: boolean; updateInterval: number; timeZone: string; authFlowUsed?: 'legacy' | 'new'; apiBaseUrl?: string; fans: VeSyncBaseDevice[]; outlets: VeSyncBaseDevice[]; switches: VeSyncBaseDevice[]; bulbs: VeSyncBaseDevice[]; scales: VeSyncBaseDevice[]; /** * Initialize VeSync Manager * @param username - VeSync account username * @param password - VeSync account password * @param timeZone - Optional timezone for device operations (defaults to America/New_York) * @param optionsOrDebug - Either options object or debug flag for backward compatibility * @param redact - Optional redact mode flag (used when optionsOrDebug is boolean) * @param apiUrl - Optional API base URL override (used when optionsOrDebug is boolean) * @param customLogger - Optional custom logger implementation (used when optionsOrDebug is boolean) * @param excludeConfig - Optional device exclusion configuration (used when optionsOrDebug is boolean) */ constructor(username: string, password: string, timeZone?: string, optionsOrDebug?: boolean | { debug?: boolean; redact?: boolean; apiUrl?: string; customLogger?: Logger; excludeConfig?: ExcludeConfig; region?: string; countryCode?: string; debugMode?: boolean; sessionStore?: SessionStore; onTokenChange?: (session: Session) => void; }, redact?: boolean, apiUrl?: string, customLogger?: Logger, excludeConfig?: ExcludeConfig); /** * Adopt a previously persisted client identity without restoring credentials. * * Callers that decide not to reuse a stored token (because it has expired, say) should still keep the * terminal/app id from that session, so the fresh login presents the same client to VeSync. */ restoreClientIdentity(identity: { terminalId?: string | null; appId?: string | null; }): void; /** * Hydrate manager from a previously persisted session */ hydrateSession(session: Session): void; private emitTokenChange; /** * Get/Set debug mode */ get debug(): boolean; set debug(flag: boolean); /** * Get/Set redact mode */ get redact(): boolean; set redact(flag: boolean); /** * Get/Set energy update interval */ get energyUpdateInterval(): number; set energyUpdateInterval(interval: number); /** * Get current App ID */ get appId(): string; /** * Terminal id presented to VeSync during authentication. Issued tokens carry it as a JWT claim, so it * is persisted with the session and reused across logins and restarts. */ get terminalId(): string; /** * Get current region */ get region(): string; /** * Return the configured API URL override, if any. */ get apiUrlOverride(): string | null; /** * Set region and update API endpoint */ set region(region: string); /** * Test if device should be removed */ static removeDevTest(device: VeSyncBaseDevice, newList: any[]): boolean; /** * Test if new device should be added */ addDevTest(newDev: Record): boolean; /** * Remove devices not found in device list return */ removeOldDevices(devices: any[]): boolean; /** * Correct devices without cid or uuid */ static setDevId(devices: any[]): any[]; /** * Process devices from API response */ private processDevices; /** * Get list of VeSync devices */ getDevices(): Promise; /** * Login to VeSync server with new authentication flow and backwards compatibility */ login(retryAttempts?: number, initialDelayMs?: number): Promise; /** * True when the current token carries an `exp` claim that has already passed. * * Deliberately conservative: a token that cannot be decoded, or that has no `exp`, is treated as * usable and left to the API to accept or reject. */ isTokenExpired(skewSeconds?: number): boolean; /** * Test if update interval has been exceeded */ deviceTimeCheck(): boolean; /** * Check if a device should be excluded based on configuration */ private shouldExcludeDevice; /** * Update device list and details */ update(): Promise; /** * Create device instance from details */ createDevice(details: Record): VeSyncBaseDevice | null; /** * Call API with authentication */ protected callApi(endpoint: string, method: string, data?: any, headers?: Record): Promise<[any, number]>; }