返回顶部
t

tuya-smart-control涂鸦智能控制

Control Tuya smart home devices via natural language. Use when the user asks to control smart devices (turn on/off lights, AC, plugs, adjust brightness/temperature/mode), query device status or list devices, manage homes and rooms, rename devices, check weather by location, send notifications (SMS, voice call, email, or App push), view device data statistics (e.g. energy/power consumption), or capture snapshots/short videos from IPC cameras. Requires TUYA_API_KEY.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.3
安全检测
已通过
493
下载量
免费
免费
63
收藏
概述
安装方式
版本历史

tuya-smart-control

Tuya智能家居设备控制技能

基本信息

  • - 官方网站: https://www.tuya.com/
  • 源代码: https://github.com/tuya/tuya-openclaw-skills
  • 认证方式: 通过请求头 Authorization: Bearer {Api-key}
  • 凭据: 从环境变量 TUYAAPIKEY 读取。基础URL根据API密钥前缀自动检测。前缀到区域的映射表请参见 references/api-conventions.md。可通过设置 TUYABASEURL 覆盖。
  • API参考: 请参见 references/ 下的各个文件
  • Python SDK: 请参见 scripts/tuya_api.py

环境变量配置

使用前请设置以下环境变量:

bash
export TUYAAPIKEY=your-tuya-api-key

TUYABASEURL 可选 — 根据API密钥前缀自动检测


仅在需要时覆盖:export TUYABASEURL=https://openapi.tuyaus.com

如果缺少 TUYAAPIKEY 环境变量,该技能将不会加载。

使用方法

始终优先使用方法1(命令行) — 单条命令,无需样板代码。它自动处理认证、URL解析、JSON序列化和错误处理。

方法1:通过命令行(推荐)

bash
python3 {baseDir}/scripts/tuya_api.py [params...]

示例:


python3 {baseDir}/scripts/tuya_api.py homes
python3 {baseDir}/scripts/tuya_api.py devices
python3 {baseDir}/scripts/tuya_api.py devices --home 5053559
python3 {baseDir}/scripts/tuya_api.py devices --room 123456
python3 {baseDir}/scripts/tuyaapi.py devicedetail
python3 {baseDir}/scripts/tuyaapi.py model id>
python3 {baseDir}/scripts/tuyaapi.py control id> {switch_led:true}
python3 {baseDir}/scripts/tuyaapi.py rename id> New Name
python3 {baseDir}/scripts/tuya_api.py weather 39.90 116.40
python3 {baseDir}/scripts/tuya_api.py sms Your message
python3 {baseDir}/scripts/tuya_api.py voice Your message
python3 {baseDir}/scripts/tuya_api.py mail Subject Content
python3 {baseDir}/scripts/tuya_api.py push Subject Content
python3 {baseDir}/scripts/tuyaapi.py statsconfig
python3 {baseDir}/scripts/tuyaapi.py statsdata id> code>
python3 {baseDir}/scripts/tuyaapi.py ipcpicfetch id> [piccount] [homeid]
python3 {baseDir}/scripts/tuyaapi.py ipcvideofetch id> [home_id]

CLI验证规则:

  • - devices 一次仅支持一个范围标志:--home 或 --room
  • control 要求 propertiesjson 是有效的JSON对象(不是数组/字符串)
  • weather 验证坐标范围:纬度 [-90, 90],经度 [-180, 180]
  • statsdata 验证 start/end 格式为 yyyyMMddHH,且时间窗口最大24小时
  • ipcpicfetch 参数:id> [piccount] [homeid] — consent 1 = 解密后的URL
  • ipcvideofetch 参数:id> [homeid] — duration 以秒为单位(1-60)
  • 使用 python3 {baseDir}/scripts/tuyaapi.py --help 获取命令帮助和示例

方法2:通过Python SDK

当需要在单个脚本中链式调用多个API或执行复杂逻辑时使用:

python
import sys
sys.path.insert(0, {baseDir}/scripts)
from tuya_api import TuyaAPI

api = TuyaAPI()

homes = api.get_homes()
devices = api.getalldevices()
detail = api.getdevicedetail(deviceidhere)
result = api.issueproperties(deviceidhere, {switchled: True, bright_value: 500})
weather = api.get_weather(lat=39.90, lon=116.40)

IPC云抓拍 — 拍摄快照并获取解密后的URL


capture = api.ipcaicapturepicallocateandfetch(deviceidhere, userprivacyconsent_accepted=True)

功能概览

模块能力参考文档
家庭管理列出所有家庭,列出家庭中的房间references/home-and-space.md
设备查询
所有设备、按家庭/房间查询设备、单个设备详情(包括当前属性状态) | references/device-query.md | | 设备控制 | 查询设备物模型、下发属性命令 | references/device-control.md | | 设备管理 | 重命名设备 | references/device-management.md | | 天气服务 | 当前和预报天气 | references/weather.md | | 通知 | 短信、语音电话、邮件、App推送 | references/notifications.md | | 数据统计 | 小时级统计配置查询、统计值查询 | references/statistics.md | | IPC云抓拍 | IPC摄像头的云快照和短视频抓拍 | references/ipc-cloud-capture.md | | 错误处理 | 错误码和恢复策略 | references/error-handling.md | | API约定 | 请求/响应格式、数据中心映射 | references/api-conventions.md |

核心工作流

工作流1:设备控制

当用户说“打开客厅灯”或“把空调温度调到26度”时:

  1. 1. 定位设备 — 根据用户提到的设备名称或位置找到目标设备。按以下优先级:
- 优先级1 — 房间+品类匹配:如果用户提到房间(如“客厅空调”),先查询家庭列表→房间列表匹配房间,然后列出该房间的设备并按 category_name 或设备 name 匹配 - 优先级2 — 设备名称匹配:如果用户只提到设备名称(如“空调”),调用“列出所有设备”API并按 category_name 优先匹配,然后按设备 name 模糊匹配 - 优先级3 — 消歧:如果匹配到多个设备,列出所有候选设备及其房间信息,让用户选择
  1. 2. 获取当前状态 — 调用“获取单个设备详情”API
- 如果 result 为 null:设备不存在或您没有权限 — 告知用户并停止 - 如果 online 为 false:设备离线 — 告诉用户“设备XX当前离线,请检查其电源和网络连接”,不再继续 - 仅在 result 有效且 online 为 true 时继续 - properties 字段包含每个功能属性的当前值(如开关状态、亮度、温度)
  1. 3. 查询能力 — 调用“查询设备物模型”API获取设备支持的属性列表
- 重要:result.model 字段是一个JSON字符串,必须再次解析(如 json.loads(result[model]))才能获取属性定义 - 检查每个属性的 accessMode: - ro(只读):不可控制,只能查询 — 告知用户“此属性为只读” - wr(只写):可控制但无法读取当前值 - rw(读写):既可控制也可查询
  1. 4. 映射命令 — 将用户意图映射到物模型属性:
- 打开/关闭 → 查找布尔类型的开关属性(如 switch_led、switch) - 调节亮度 → 查找数值类型的亮度属性 - 调节温度 → 查找数值类型的温度属性 - 如果设备不支持请求的功能,告知用户并列出支持的功能 - 相对调节 — 当用户说“亮一点”、“温度降低2度”等时: 1. 从设备详情的 properties 中读取当前值(步骤2) 2. 从物模型 typeSpec 中读取 min、max、step(步骤3) 3. 计算目标值: - 模糊(“一点”、“稍微”)→ 当前值 ± (max - min) × 10% - 具体(“2度”、“100”)→ 当前值 ± 指定数值 4. 将目标值限制在 [min, max] 范围内,

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 tuya-smart-control-1776115091 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 tuya-smart-control-1776115091 技能

通过命令行安装

skillhub install tuya-smart-control-1776115091

下载

⬇ 下载 tuya-smart-control v1.0.3(免费)

文件大小: 29.54 KB | 发布时间: 2026-4-17 16:25

v1.0.3 最新 2026-4-17 16:25
Version 1.0.3

- Added detailed API documentation: api conventions, error handling, and IPC cloud capture guides in the `references/` directory.
- Introduced CLI validation, new device, IPC camera capture, and notification commands to the CLI.
- Updated documentation for CLI usage, arguments, and validation rules; CLI is now recommended as the primary usage method.
- Expanded feature overview to cover error handling, IPC cloud capture, API conventions, and clarified all modules.
- Clarified and detailed device control workflows, error conditions, user intent mapping, and property access modes.
- Added Python dependencies file (`scripts/requirements.txt`).

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large