← 返回
开发者工具 Key 中文

Tuya Smart Home

Control Tuya/Smart Life smart home devices including pet feeders, lights, plugs, curtains via cloud API or local network. Use when: (1) controlling smart hom...
通过云端API或本地网络控制涂鸦/智生活智能家居设备,包括宠物喂食器、灯光、插座、窗帘。适用场景:(1) 控制智能家居设备。
rachelchoo1212 rachelchoo1212 来源
开发者工具 clawhub v1.0.0 1 版本 99872.1 Key: 需要
★ 0
Stars
📥 781
下载
💾 16
安装
1
版本
#latest

概述

Tuya Smart Home

Control any Tuya/Smart Life device via cloud API or local network.

Dependencies

pip3 install tinytuya tuya-connector-python

Configuration

Two control modes available:

Cloud Mode

Requires Tuya IoT Platform credentials from https://iot.tuya.com:

  • ACCESS_ID — from Cloud Project
  • ACCESS_SECRET — from Cloud Project
  • REGION — cn (China), us (Americas/SEA), eu (Europe), in (India)

Local Mode (Recommended)

Requires device info (obtain via cloud API first):

  • DEVICE_ID — device identifier
  • LOCAL_KEY — device encryption key
  • IP — device local IP address
  • VERSION — protocol version (usually 3.4)

Quick Start

Scan for devices on local network

python3 scripts/tuya_scan.py

Get device info (cloud)

python3 scripts/tuya_control.py --mode cloud --action info \
  --device-id DEVICE_ID \
  --access-id ACCESS_ID --access-secret ACCESS_SECRET --region cn

Query device status

# Cloud
python3 scripts/tuya_control.py --mode cloud --action status \
  --device-id DEVICE_ID \
  --access-id ACCESS_ID --access-secret ACCESS_SECRET --region cn

# Local
python3 scripts/tuya_control.py --mode local --action status \
  --device-id DEVICE_ID --ip IP --local-key KEY

Send command

# Cloud — feed pet 1 portion
python3 scripts/tuya_control.py --mode cloud --action send \
  --device-id DEVICE_ID --code manual_feed --value 1 \
  --access-id ACCESS_ID --access-secret ACCESS_SECRET --region cn

# Local — feed pet 1 portion
python3 scripts/tuya_control.py --mode local --action send \
  --device-id DEVICE_ID --ip IP --local-key KEY \
  --dp-id 3 --value 1

# Turn on light
python3 scripts/tuya_control.py --mode cloud --action send \
  --device-id DEVICE_ID --code switch_led --value true \
  --access-id ACCESS_ID --access-secret ACCESS_SECRET --region cn

# Open curtain
python3 scripts/tuya_control.py --mode cloud --action send \
  --device-id DEVICE_ID --code control --value open \
  --access-id ACCESS_ID --access-secret ACCESS_SECRET --region cn

Common Device Commands

DeviceCodeValuesDescription
-----------------------------------
Pet Feedermanual_feed1-12Feed N portions
Pet Feederquick_feedtrueQuick feed
Pet Feederlighttrue/falseNight light
Lightswitch_ledtrue/falseOn/off
Lightbright_value10-1000Brightness
Lighttemp_value0-1000Color temperature
Plugswitch_1true/falseOn/off
Curtaincontrolopen/stop/closeMovement
Curtainpercent_control0-100Position %

China Region Note

China data center (openapi.tuyacn.com) blocks non-China IPs by default.

Solutions:

  1. Add your IP to whitelist in Tuya IoT Platform → Project → IP Whitelist
  2. Use local mode (bypasses cloud entirely, recommended)

API Reference

For detailed API documentation, DP code tables, and setup guide, see references/tuya_api.md.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 00:00 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

life-service

healthcheck

stellarhold170nt
使用 JSON 文件存储追踪饮水和睡眠
★ 11 📥 29,866
life-service

Caldav Calendar

asleep123
使用 vdirsyncer + khal 同步并查询 CalDAV 日历(iCloud、Google、Fastmail、Nextcloud 等)。适用于 Linux。
★ 242 📥 30,437
life-service

Weather

steipete
获取当前天气和预报(无需API密钥)
★ 451 📥 226,968