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
64 lines (63 loc) • 1.76 kB
TypeScript
import { TapoCredentials } from '../types';
export interface ConnectionOptions {
maxRetries?: number;
retryDelay?: number;
timeout?: number;
}
export interface ConnectionState {
isConnected: boolean;
connectionTime?: number;
lastActivity: number;
retryCount: number;
}
/**
* Manages device connections and connection state
* Single responsibility: Connection lifecycle management
*/
export declare class ConnectionManager {
protected readonly ip: string;
protected readonly credentials: TapoCredentials;
private connectionState;
private readonly options;
constructor(ip: string, credentials: TapoCredentials, options?: ConnectionOptions);
/**
* Establish connection to device
*/
connect(): Promise<void>;
/**
* Disconnect from device
*/
disconnect(): Promise<void>;
/**
* Check if connection is active and healthy
*/
isConnected(): boolean;
/**
* Get current connection state
*/
getConnectionState(): Readonly<ConnectionState>;
/**
* Update last activity timestamp
*/
updateActivity(): void;
/**
* Check if connection has been idle for too long
*/
isIdle(maxIdleTime?: number): boolean;
/**
* Reset connection state (useful for error recovery)
*/
reset(): void;
/**
* Actual connection implementation - no-op as connection is handled by protocol-specific auth classes
*/
protected performConnection(): Promise<void>;
/**
* Actual disconnection implementation - no-op as disconnection is handled by protocol-specific auth classes
*/
protected performDisconnection(): Promise<void>;
/**
* Utility method for delays
*/
private delay;
}