#iot-devices #smart-home #iot #smart-plug #smart-bulb

tapo

非官方 Tapo API 客户端。适用于 TP-Link Tapo 智能设备。已测试灯具(L510、L520、L530、L610、L630)、灯带(L900、L920、L930)、插座(P100、P105、P110、P115、P300)、集线器(H100)、开关(S200B)和传感器(KE100、T100、T110、T300、T310、T315)。

21 个版本

0.7.12 2024年6月27日
0.7.10 2024年4月5日
0.7.9 2024年1月27日
0.7.6 2023年11月25日
0.2.0 2022年6月12日

127硬件支持

Download history 5/week @ 2024-04-26 154/week @ 2024-05-03 8/week @ 2024-05-10 7/week @ 2024-05-17 6/week @ 2024-05-24 5/week @ 2024-05-31 52/week @ 2024-06-07 13/week @ 2024-06-14 68/week @ 2024-06-21 91/week @ 2024-06-28 5/week @ 2024-07-05 11/week @ 2024-07-19 88/week @ 2024-07-26 7/week @ 2024-08-02 2/week @ 2024-08-09

每月108 次下载

MIT 许可证

245KB
5K SLoC

Tapo

License Crates Documentation Crates.io PyPI Python PyPI
非官方 Tapo API 客户端。适用于 TP-Link Tapo 智能设备。已测试灯具(L510、L520、L530、L610、L630)、灯带(L900、L920、L930)、插座(P100、P105、P110、P115、P300)、集线器(H100)、开关(S200B)和传感器(KE100、T100、T110、T300、T310、T315)。

设备支持

✓ - 仅 Rust
✅ - Rust 和 Python

功能


GenericDevice


L510
L520
L610
L530
L630

L900


L920
L930

P100
P105

P110
P115

P300


H100


device_reset
get_child_device_component_list_json
get_child_device_list
get_child_device_list_json
get_current_power
get_device_info
get_device_info_json
get_device_usage
get_energy_data
get_energy_usage
off
on
refresh_session
set_brightness
set_color
set_color_temperature
set_hue_saturation
set_lighting_effect
set() API *

* set() API 允许在单个请求中设置多个属性。

集线器(H100)子设备支持

功能

KE100

S200B

T100

T110

T300

T310
T315
get_device_info *
get_device_info_json
get_temperature_humidity_records
get_trigger_logs
set_child_protection
set_frost_protection
set_max_control_temperature
set_min_control_temperature
set_target_temperature
set_temperature_offset

* 通过在集线器设备上调用 get_child_device_list 或在子设备处理器上调用 get_device_info 获取。

Rust

使用方法

Cargo.toml

[dependencies]
tapo = "0.7"

main.rs

let device = ApiClient::new("<tapo-username>", "tapo-password")?
    .p110("<device ip address>")
    .await?;

device.on().await?;

示例

export TAPO_USERNAME=
export TAPO_PASSWORD=
export IP_ADDRESS=

cargo run --example tapo_l530

查看所有示例 /tapo/examples

REST API 封装器

tapo-rest 是此库的 REST 封装器,可以作为服务部署或作为高级示例。

Python

使用方法

pip install tapo
client = ApiClient("<tapo-username>", "tapo-password")
device = await client.p110("<device ip address>")

await device.on()

示例

cd tapo-py
poetry install
poetry shell

export TAPO_USERNAME=
export TAPO_PASSWORD=
export IP_ADDRESS=
python examples/tapo_p110.py

查看所有示例 /tapo-py/examples

贡献

欢迎并鼓励贡献!请参阅 /CONTRIBUTING.md

故障排除

1. 在 Windows 上安装 openssl

使用 chocolatey

choco install openssl
[System.Environment]::SetEnvironmentVariable('OPENSSL_DIR', $Env:Programfiles + "\OpenSSL-Win64", "User")

或使用vcpkg

git clone git@github.com:microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.bat
./vcpkg.exe install openssl-windows:x64-windows
./vcpkg.exe install openssl:x64-windows-static
./vcpkg.exe integrate install
[System.Environment]::SetEnvironmentVariable('OPENSSL_DIR', (Get-Location).Path + "\installed\x64-windows-static", "User")

致谢

灵感来源于petretiandrea/plugp100

依赖项

~57MB
~1M SLoC