tsvesync
Version:
A TypeScript library for interacting with VeSync smart home devices
118 lines (117 loc) • 3.4 kB
TypeScript
/**
* VeSync API Device Library
*/
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;
username: string;
password: string;
token: string | null;
accountId: string | null;
countryCode: string | null;
devices: VeSyncBaseDevice[] | null;
enabled: boolean;
updateInterval: number;
timeZone: 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 debug - Optional debug mode flag
* @param redact - Optional redact mode flag
* @param apiUrl - Optional API base URL override
* @param customLogger - Optional custom logger implementation
* @param excludeConfig - Optional device exclusion configuration
*/
constructor(username: string, password: string, timeZone?: string, debug?: boolean, redact?: boolean, apiUrl?: string, customLogger?: Logger, excludeConfig?: ExcludeConfig);
/**
* 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);
/**
* Test if device should be removed
*/
static removeDevTest(device: VeSyncBaseDevice, newList: any[]): boolean;
/**
* Test if new device should be added
*/
addDevTest(newDev: Record<string, any>): 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<boolean>;
/**
* Login to VeSync server
*/
login(retryAttempts?: number, initialDelayMs?: number): Promise<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<void>;
/**
* Create device instance from details
*/
createDevice(details: Record<string, any>): VeSyncBaseDevice | null;
/**
* Call API with authentication
*/
protected callApi(endpoint: string, method: string, data?: any, headers?: Record<string, string>): Promise<[any, number]>;
}