UNPKG

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

49 lines 2.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DEFAULT_RETRY_CONFIGS = void 0; exports.createRetryConfig = createRetryConfig; /** * Default retry configurations for different operation types */ exports.DEFAULT_RETRY_CONFIGS = { deviceControl: { maxAttempts: 3, baseDelay: 3000, strategy: 'linear', busyErrorPatterns: ['klap -1012', 'device busy', 'command timing issue'], sessionErrorPatterns: ['klap 1002', 'session expired', 'invalid terminal uuid'] }, infoRetrieval: { maxAttempts: 2, baseDelay: 1000, strategy: 'fixed', busyErrorPatterns: ['klap -1012', 'device busy'], sessionErrorPatterns: ['klap 1002', 'session expired'] }, energyMonitoring: { maxAttempts: 2, baseDelay: 1500, strategy: 'fixed', busyErrorPatterns: ['klap -1012', 'device busy'], sessionErrorPatterns: ['klap 1002', 'session expired'] } }; /** * Convert user-provided RetryOptions to internal configuration */ function createRetryConfig(operationType, userOptions) { var _a, _b, _c; // If retry is explicitly disabled, return null if ((userOptions === null || userOptions === void 0 ? void 0 : userOptions.enabled) === false) { return null; } const defaultConfig = exports.DEFAULT_RETRY_CONFIGS[operationType]; return { maxAttempts: (_a = userOptions === null || userOptions === void 0 ? void 0 : userOptions.maxAttempts) !== null && _a !== void 0 ? _a : defaultConfig.maxAttempts, baseDelay: (_b = userOptions === null || userOptions === void 0 ? void 0 : userOptions.baseDelay) !== null && _b !== void 0 ? _b : defaultConfig.baseDelay, strategy: (_c = userOptions === null || userOptions === void 0 ? void 0 : userOptions.strategy) !== null && _c !== void 0 ? _c : defaultConfig.strategy, busyErrorPatterns: [...defaultConfig.busyErrorPatterns], sessionErrorPatterns: [...defaultConfig.sessionErrorPatterns] }; } //# sourceMappingURL=retry-options.js.map