node-red-contrib-tplink-tapo-connect-api
Version:
This unofficial node-RED node allows connection to TP-Link Tapo devices. This project has been enhanced with AI support to enable new features. Starting with v0.50, we have added support for the KLAP protocol. To prioritize the operation of this node, we
56 lines (55 loc) • 2.26 kB
TypeScript
/**
* Optional retry configuration for wrapper methods
* All parameters are optional - sensible defaults will be used
*/
export interface RetryOptions {
/** Maximum number of retry attempts. Default: 3 for control operations, 2 for info operations */
maxAttempts?: number;
/** Base delay between retries in milliseconds. Default: 2000ms for control, 1000ms for info */
baseDelay?: number;
/** Retry strategy. Default: 'linear' for control operations, 'fixed' for info operations */
strategy?: 'linear' | 'exponential' | 'fixed';
/** Enable/disable retry. Default: true */
enabled?: boolean;
}
/**
* Internal retry configuration with all required fields
*/
export interface InternalRetryConfig {
maxAttempts: number;
baseDelay: number;
strategy: 'linear' | 'exponential' | 'fixed';
busyErrorPatterns: string[];
sessionErrorPatterns: string[];
onRetry?: (attempt: number, error: Error, delay: number) => void;
}
/**
* Default retry configurations for different operation types
*/
export declare const DEFAULT_RETRY_CONFIGS: {
readonly deviceControl: {
readonly maxAttempts: 3;
readonly baseDelay: 3000;
readonly strategy: "linear";
readonly busyErrorPatterns: readonly ["klap -1012", "device busy", "command timing issue"];
readonly sessionErrorPatterns: readonly ["klap 1002", "session expired", "invalid terminal uuid"];
};
readonly infoRetrieval: {
readonly maxAttempts: 2;
readonly baseDelay: 1000;
readonly strategy: "fixed";
readonly busyErrorPatterns: readonly ["klap -1012", "device busy"];
readonly sessionErrorPatterns: readonly ["klap 1002", "session expired"];
};
readonly energyMonitoring: {
readonly maxAttempts: 2;
readonly baseDelay: 1500;
readonly strategy: "fixed";
readonly busyErrorPatterns: readonly ["klap -1012", "device busy"];
readonly sessionErrorPatterns: readonly ["klap 1002", "session expired"];
};
};
/**
* Convert user-provided RetryOptions to internal configuration
*/
export declare function createRetryConfig(operationType: keyof typeof DEFAULT_RETRY_CONFIGS, userOptions?: RetryOptions): InternalRetryConfig | null;