1. Go to this page and download the library: Download antalaron/tapo library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
antalaron / tapo example snippets
ntalaron\Tapo\Device;
// Create a device instance
$device = new Device('192.168.1.100', '[email protected]', '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();
// Get device information
$info = $device->getDeviceInfo();
$jsonInfo = $device->getDeviceInfoJson();
// Device control
$device->getDeviceName();
$device->getDeviceUsage();
$device->refreshSession();
// Device management
$device->deviceReboot();
$device->deviceReset();
// 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();
// Get current power consumption
$power = $device->getCurrentPower();
// Get energy data
$energyData = $device->getEnergyData();
$energyUsage = $device->getEnergyUsage();
$powerData = $device->getPowerData();
// 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]);
// Get child devices (individual outlets)
$children = $device->getChildDeviceList();
if ($device->supportsFeature('set_color')) {
$device->setColor(240, 100);
}
// 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');