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
81 lines (80 loc) • 2.25 kB
TypeScript
import { TapoApiRequest, TapoApiResponse } from '../types';
export interface ColorInfo {
hue?: number;
saturation?: number;
color_temp?: number;
}
export interface BrightnessInfo {
brightness?: number;
}
export interface LightingState {
on?: boolean;
brightness?: number;
hue?: number;
saturation?: number;
color_temp?: number;
}
export interface LightEffect {
name: string;
enable: boolean;
brightness?: number;
custom?: number;
segments?: number[];
expansion_strategy?: number;
}
/**
* Controller for lighting functionality (brightness, color, effects)
* Single responsibility: Lighting control and color management
*/
export declare class LightingController {
private readonly sendRequest;
constructor(sendRequest: (request: TapoApiRequest) => Promise<TapoApiResponse>);
/**
* Set device brightness (1-100)
*/
setBrightness(brightness: number): Promise<void>;
/**
* Set color using HSV values
*/
setColorHSV(hue: number, saturation: number, brightness?: number): Promise<void>;
/**
* Set color using RGB values
*/
setColorRGB(red: number, green: number, blue: number, brightness?: number): Promise<void>;
/**
* Set color using predefined color names
*/
setNamedColor(colorName: string, brightness?: number): Promise<void>;
/**
* Set color temperature (2500K - 6500K)
*/
setColorTemperature(temperature: number, brightness?: number): Promise<void>;
/**
* Set lighting effect
*/
setLightEffect(effect: LightEffect): Promise<void>;
/**
* Get current lighting state
*/
getLightingState(): Promise<LightingState>;
/**
* Check if device supports brightness control
*/
static supportsBrightnessControl(deviceModel: string): boolean;
/**
* Check if device supports color control
*/
static supportsColorControl(deviceModel: string): boolean;
/**
* Check if device supports color temperature control
*/
static supportsColorTemperature(deviceModel: string): boolean;
/**
* Convert RGB to HSV
*/
private rgbToHsv;
/**
* Get predefined color map
*/
private getNamedColorMap;
}