kuhschnappel/tapo-api

访问 Tapo 设备智能家居数据的 API 连接器

v2.1.0 2023-03-26 15:09 UTC

This package is auto-updated.

Last update: 2024-09-26 18:22:21 UTC


README

此接口主要开发用于使用 PHP 从 TP-Link TapoP110 插座获取消耗数据。

用法

与所有 Tapo 设备通信

创建新的连接

$device = new Tapo('email', 'password', 'http://192.168.xxx.xxx');
$device = new Tapo('email', 'password', 'http://192.168.xxx.xxx:port');
$device = new Tapo('email', 'password', 'http://dyndns.tld:port');

使用一个命令向设备发送多个更改

$device->sendChangedSettings();

设备名称

$device->getName();
$device->setName('Gerätename')

设备位置

$device->getLongitude()
$device->getLatitude()
$device->setLongitude(12.00000)
$device->setLatitude(50.000000)

获取设备信息

$device->getInfo();

=>

stdClass Object (
    [device_id] => 8022DFC785E6EC92987142C17FD2E06420996XXX
    [fw_ver] => 1.1.6 Build 221114 Rel.203339
    [hw_ver] => 1.0
    [type] => SMART.TAPOPLUG
    [model] => P110
    [mac] => AC-15-A2-E4-4B-13
    [hw_id] => 2FB30EF5BF920C44099401D396C6BXXX
    [fw_id] => 00000000000000000000000000000000
    [oem_id] => 18BDC6C734AF8407B3EF871EACFCECXXX
    [ip] => 192.168.5.103
    [time_diff] => 60
    [ssid] => XXX (base64 encoded string)
    [rssi] => -50
    [signal_level] => 2
    [latitude] => 0
    [longitude] => 0
    [lang] => de_DE
    [avatar] => plug
    [region] => Europe/Berlin
    [specs] => 
    [nickname] => XXX (base64 encoded string)
    [has_set_location_info] => 
    [device_on] => 1
    [on_time] => 3390611
    [default_states] => stdClass Object (
        [type] => last_states
        [state] => stdClass Object (
        )
    )
    [overheated] => 
    [power_protection_status] => normal
)

TapoPlug 设备

开关电源

$device->getPower() => false / true;
$device->setPowerOn();
$device->setPowerOff();
$device->setPower(false / true);

更改一些设置并将其发送到您的 Tapo 设备

$device->setAvatar(TAPO::AVATAR_PLUG)
       ->setLongitude(12.00000)
       ->setLatitude(12.00000)
       ->setPowerOn()
       ->sendChangedSettings();

$device->setAvatar(TAPO::AVATAR_PLUG)
$device->setLongitude(12.00000);
$device->setLatitude(12.00000);
$device->setPowerOn();
$device->sendChangedSettings();

TapoPlug P110 设备

能源使用

$device->getEnergyUsage();

=>

    [today_runtime] => 1002
    [month_runtime] => 37002
    [today_energy] => 1224
    [month_energy] => 39851
    [local_time] => 2023-02-26 16:42:17
    [electricity_charge] => Array (
        [0] => 0
        [1] => 6422
        [2] => 11945
    )
    [current_power] => 118314 // in milliwat
)

能源使用(获取包含时间戳和过去几天消耗的数组)

$device->getEnergyData();

=>

Array
(
    [1672527600] => 1233
    [1672614000] => 232
    [1672700400] => 0
    ...
    [1680040800] => 9999
    [1680127200] => 0
    [1680213600] => 0
)

支持

如果您想支持此项目,请考虑买我一杯咖啡。

Buy Me A Coffee