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
96 lines (95 loc) • 2.8 kB
TypeScript
export interface TapoCredentials {
username: string;
password: string;
}
export interface TapoDeviceInfo {
device_id: string;
fw_ver: string;
hw_ver: string;
type: string;
model: string;
mac: string;
hw_id: string;
fw_id: string;
oem_id: string;
specs: string;
device_on: boolean;
on_time: number;
overheated: boolean;
nickname: string;
location: string;
avatar: string;
longitude: number;
latitude: number;
has_set_location_info: boolean;
ip: string;
ssid?: string;
signal_level: number;
rssi: number;
region: string;
time_diff: number;
lang: string;
default_states: {
type: string;
state: Record<string, unknown>;
};
auto_off_status: string;
auto_off_remain_time: number;
}
export declare function getDeviceId(deviceInfo: TapoDeviceInfo): string;
export declare function getDeviceType(deviceInfo: TapoDeviceInfo): string;
export declare function getFwVer(deviceInfo: TapoDeviceInfo): string;
export declare function getHwVer(deviceInfo: TapoDeviceInfo): string;
export declare function getOnTime(deviceInfo: TapoDeviceInfo): number;
export declare function getSignalLevel(deviceInfo: TapoDeviceInfo): number;
export interface TapoApiRequest {
method: string;
params?: Record<string, unknown>;
}
export interface TapoApiResponse<T = unknown> {
error_code: number;
result: T;
msg?: string;
}
export interface TapoHandshakeResponse {
key: string;
session: string;
}
export interface TapoError extends Error {
errorCode: number;
message: string;
}
export declare class FeatureNotSupportedError extends Error {
readonly name = "FeatureNotSupportedError";
readonly feature: string;
readonly deviceModel: string;
constructor(feature: string, deviceModel: string, message?: string);
}
export declare class DeviceCapabilityError extends Error {
readonly name = "DeviceCapabilityError";
readonly capability: string;
readonly reason: string;
constructor(capability: string, reason: string, message?: string);
}
export type Result<T, E = Error> = {
success: true;
data: T;
} | {
success: false;
error: E;
};
export interface DeviceMethodOptions {
throwOnUnsupported?: boolean;
timeout?: number;
}
export declare abstract class BaseTapoDevice {
protected ip: string;
protected credentials: TapoCredentials;
protected sessionKey?: string;
protected sessionId?: string;
constructor(ip: string, credentials: TapoCredentials);
abstract connect(): Promise<void>;
abstract getDeviceInfo(): Promise<TapoDeviceInfo>;
abstract disconnect(): Promise<void>;
protected abstract sendRequest<T>(request: TapoApiRequest): Promise<TapoApiResponse<T>>;
}