承接 antalaron/tapo 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

antalaron/tapo

最新稳定版本:v0.1.1

Composer 安装命令:

composer require antalaron/tapo

包简介

PHP library for controlling TP-Link Tapo smart devices

README 文档

README

A PHP library for controlling TP-Link Tapo smart devices.

CI

Acknowledgements

The implementation of this library was inspired by:

Requirements

  • PHP 7.1 or higher

Installation

Install via Composer:

composer require antalaron/tapo

Usage

Basic Example

<?php

require 'vendor/autoload.php';

use Antalaron\Tapo\Device;

// Create a device instance
$device = new Device('192.168.1.100', 'your-email@example.com', 'your-password');

// Get device information
echo 'Model: '.$device->getModel()."\n";
echo 'Name: '.$device->getDeviceName()."\n";

// Get device status (true = ON, false = off)
echo 'Device is '.($device->getStatus() ? 'ON' : 'OFF')."\n";

// Turn the device on
$device->turnOn();

// Turn the device off
$device->turnOff();

Supported Devices

The library supports a wide range of Tapo devices:

Smart Plugs

  • P100, P105 - Basic smart plugs (on/off control)
  • P110, P110M, P115 - Smart plugs with energy monitoring
  • P300, P306, P304M, P316M - Power strips with multiple outlets

Smart Bulbs

  • L510, L520, L610 - Dimmable white bulbs
  • L530, L535, L630 - Color bulbs with temperature control
  • L900, L920, L930 - LED light strips (L920, L930 support lighting effects)

Available Methods

Common Methods (All Devices)

// Get device information
$info = $device->getDeviceInfo();
$jsonInfo = $device->getDeviceInfoJson();

// Device control
$device->getDeviceName();
$device->getDeviceUsage();
$device->refreshSession();

// Device management
$device->deviceReboot();
$device->deviceReset();

Smart Plug Methods

// Basic control
$device->turnOn();
$device->turnOff();

// Delayed switching (countdown timer)
$device->switchWithDelay(true, 60); // Turn on after 60 seconds

// Get countdown rules
$rules = $device->getCountDownRules();

Energy Monitoring (P110, P110M, P115)

// Get current power consumption
$power = $device->getCurrentPower();

// Get energy data
$energyData = $device->getEnergyData();
$energyUsage = $device->getEnergyUsage();
$powerData = $device->getPowerData();

Smart Bulb Methods

// Brightness control (all bulbs)
$device->setBrightness(50); // 0-100

// Color control (L530, L535, L630, L900, L920, L930)
$device->setColor(120, 80); // hue (0-360), saturation (0-100)
$device->setColor(120, 80, 75); // with brightness

$device->setHueSaturation(180, 90);

// Color temperature (L530, L535, L630, L900, L920, L930)
$device->setColorTemperature(4000); // 2500-6500K
$device->setColorTemperature(4000, 80); // with brightness

// Lighting effects (L920, L930)
$device->setLightingEffect('Aurora', ['brightness' => 80]);

Power Strips (P300, P306, P304M, P316M)

// Get child devices (individual outlets)
$children = $device->getChildDeviceList();

Feature Detection

You can check if a device supports a specific feature:

if ($device->supportsFeature('set_color')) {
    $device->setColor(240, 100);
}

Protocol Support

The library automatically detects and uses the appropriate protocol for your device. You can also specify a preferred protocol:

// Force new protocol
$device = new Device('192.168.1.100', 'email', 'password', 'new');

// Force old protocol
$device = new Device('192.168.1.100', 'email', 'password', 'old');

Error Handling

The library throws Antalaron\Tapo\Exception\RuntimeException when errors occur:

use Antalaron\Tapo\Exception\RuntimeException;

try {
    $device->turnOn();
} catch (RuntimeException $e) {
    echo sprintf('Error: %s', $e->getMessage());
}

License

This library is released under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

统计信息

  • 总下载量: 4
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-13