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
124 lines • 5.78 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.retryable = exports.withRetry = exports.TapoRetryHandler = exports.TapoConnect = exports.LightingController = void 0;
// Core infrastructure exports
__exportStar(require("./types"), exports);
__exportStar(require("./core"), exports);
// Device exports
__exportStar(require("./devices/base-device"), exports);
__exportStar(require("./devices/plug-device"), exports);
__exportStar(require("./devices/bulb-device"), exports);
// Controller exports
__exportStar(require("./controllers/device-controller"), exports);
__exportStar(require("./controllers/energy-controller"), exports);
var lighting_controller_1 = require("./controllers/lighting-controller");
Object.defineProperty(exports, "LightingController", { enumerable: true, get: function () { return lighting_controller_1.LightingController; } });
// Factory and services exports
__exportStar(require("./factory/device-factory"), exports);
__exportStar(require("./services/device-control-service"), exports);
__exportStar(require("./services/batch-operation-service"), exports);
// Legacy device classes (for backward compatibility)
__exportStar(require("./devices"), exports);
const device_factory_1 = require("./factory/device-factory");
/**
* Main TapoConnect class with refactored architecture
* Uses the new composition-based device architecture
*/
class TapoConnect {
/**
* Create a device instance with automatic type detection
* Recommended approach for new code
*/
static async createDevice(ip, credentials) {
return device_factory_1.DeviceFactory.createDevice(ip, credentials);
}
/**
* Create a device instance with type hint
* Useful when you know the device type in advance
*/
static async createDeviceWithHint(ip, credentials, methodHint) {
return device_factory_1.DeviceFactory.createDevice(ip, credentials, methodHint);
}
// Legacy methods for backward compatibility
// These will create the appropriate device using the new architecture
/**
* Create a P100 Smart Plug instance
* P100 is a basic smart plug without energy monitoring
* @deprecated Use createDevice() for automatic type detection
*/
static async createP100Plug(ip, credentials) {
return device_factory_1.DeviceFactory.createDevice(ip, credentials, 'basic_control');
}
/**
* Create a P105 Smart Plug instance
* P105 is a basic smart plug without energy monitoring
* @deprecated Use createDevice() for automatic type detection
*/
static async createP105Plug(ip, credentials) {
return device_factory_1.DeviceFactory.createDevice(ip, credentials, 'basic_control');
}
/**
* Create a P110 Smart Plug instance
* P110 is a smart plug with energy monitoring capabilities
* @deprecated Use createDevice() for automatic type detection
*/
static async createP110Plug(ip, credentials) {
return device_factory_1.DeviceFactory.createDevice(ip, credentials, 'getEnergyUsage');
}
/**
* Create a P115 Smart Plug instance
* P115 is a smart plug with energy monitoring capabilities
* @deprecated Use createDevice() for automatic type detection
*/
static async createP115Plug(ip, credentials) {
return device_factory_1.DeviceFactory.createDevice(ip, credentials, 'getEnergyUsage');
}
/**
* Create an L510 Smart Bulb instance
* L510 is a dimmable white light bulb
* @deprecated Use createDevice() for automatic type detection
*/
static async createL510Bulb(ip, credentials) {
return device_factory_1.DeviceFactory.createDevice(ip, credentials, 'setBrightness');
}
/**
* Create an L520 Smart Bulb instance
* L520 is a tunable white light bulb with color temperature control
* @deprecated Use createDevice() for automatic type detection
*/
static async createL520Bulb(ip, credentials) {
return device_factory_1.DeviceFactory.createDevice(ip, credentials, 'setColorTemperature');
}
/**
* Create an L530 Smart Bulb instance
* L530 is a full color bulb with effects support
* @deprecated Use createDevice() for automatic type detection
*/
static async createL530Bulb(ip, credentials) {
return device_factory_1.DeviceFactory.createDevice(ip, credentials, 'setColor');
}
}
exports.TapoConnect = TapoConnect;
exports.default = TapoConnect;
// Wrapper exports (high-level API)
__exportStar(require("./wrapper/tplink-tapo-connect-wrapper"), exports);
// Retry utilities for advanced users
var retry_utils_1 = require("./utils/retry-utils");
Object.defineProperty(exports, "TapoRetryHandler", { enumerable: true, get: function () { return retry_utils_1.TapoRetryHandler; } });
Object.defineProperty(exports, "withRetry", { enumerable: true, get: function () { return retry_utils_1.withRetry; } });
Object.defineProperty(exports, "retryable", { enumerable: true, get: function () { return retry_utils_1.retryable; } });
//# sourceMappingURL=index.js.map