Xpersona
T

Tuya Smart Control

CLAWHUB · Unverified

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/tempe... Skill: Tuya Smart Control Owner: gaosq856 Summary: 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/tempe... Tags: latest:1.0.5 Version history: v1.0.5 | 2026-04-28T09:05:17.302Z | user No user-visible changes in this release. - Version bump to 1.0.5 with no detected file changes. - All features and documentation re

62
Rank
84
Safety
1.6k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1.6K downloads reported by the source. Last updated 10/10/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s171j9g2syww0fznp0dph2hgvh83g91h:tuya-smart-control
  1. Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-gaosq856-tuya-smart-control/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

147,095 characters of source documentation, loaded on request.

Extracted files

5 files captured from the source.

SKILL.md

---
name: tuya-smart-control
description: 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), capture snapshots/short videos from IPC cameras, or subscribe to real-time device events (property changes, online/offline status) via WebSocket. Requires TUYA_API_KEY.
metadata: { "openclaw": { "version": "1.0.0", "emoji": "🏠", "requires": { "env": ["TUYA_API_KEY"], "pip": ["requests>=2.28.0", "websockets>=12.0"] }, "primaryEnv": "TUYA_API_KEY" } }
---

# Tuya Smart Home Device Control Skill

## Basic Information

- **Official Website**: https://www.tuya.com/
- **Source Code**: https://github.com/tuya/tuya-openclaw-skills
- **Authentication**: Via Header `Authorization: Bearer {Api-key}`
- **Credentials**: Read from environment variable `TUYA_API_KEY`. Base URL is auto-detected from API key prefix. See `references/api-conventions.md` for the prefix-to-region mapping table. You can override by setting `TUYA_BASE_URL`.
- **API Reference**: See individual files under `references/`
- **Python SDK**: See `scripts/tuya_api.py`
- **Device Message Client**: See `scripts/tuya_device_mq_client.py` (real-time WebSocket subscription)

## Environment Variable Configuration

Set the following environment variable before use:

```bash
export TUYA_API_KEY="your-tuya-api-key"
# TUYA_BASE_URL is optional — auto-detected from API key prefix
# Override only if needed: export TUYA_BASE_URL="https://openapi.tuyaus.com"
```

The same `TUYA_API_KEY` is used for both the REST API and WebSocket message subscription. The WebSocket URI is auto-detected from the API key prefix (same 7 data centers as the REST API). See `references/device-message.md` for the full mapping table.

The skill will not load if the `TUYA_API_KEY` environment variable is missing.

## Usage

**Always prefer Method 1 (Command Line)** — single command, no boilerplate code. It handles authentication, URL resolution, JSON serialization, and error handling automatically.

### Method 1: Via Command Line (Recommended)

```bash
python3 {baseDir}/scripts/tuya_api.py <command> [params...]
# Examples:
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/tuya_api.py device_detail <device_id>
python3 {baseDir}/scripts/tuya_api.py model <device_id>
python3 {baseDir}/scripts/tuya_api.py control <device_id> '{"switch_led":true}'
python3 {baseDir}/scripts/tuya_api.py rename <device_id> "New Name"
python3 {baseDir}/scripts/tuya_api.py weather 39.90 116.40
python3 {baseDir}/scripts/tuya_api.py sms "Your messa

_meta.json

{
  "ownerId": "kn771jx7qrypfqjhdjbxnethrn8333av",
  "slug": "tuya-smart-control",
  "version": "1.0.5",
  "publishedAt": 1777367117302
}

references/api-conventions.md

# API Conventions

## API Key Prefix → Data Center Mapping

The base URL is automatically resolved from the first two characters after `sk-` in the API key:

| Prefix | Region | Base URL |
|--------|--------|----------|
| AY | China Data Center | https://openapi.tuyacn.com |
| AZ | US West Data Center | https://openapi.tuyaus.com |
| EU | Central Europe Data Center | https://openapi.tuyaeu.com |
| IN | India Data Center | https://openapi.tuyain.com |
| UE | US East Data Center | https://openapi-ueaz.tuyaus.com |
| WE | Western Europe Data Center | https://openapi-weaz.tuyaeu.com |
| SG | Singapore Data Center | https://openapi-sg.iotbing.com |

How to obtain an API key:
- China Mainland users: Get from https://tuyasmart.com/
- International users: Get from https://tuya.ai/
- Different regions use different API service domains, which must match your account registration region

## Request Format

All APIs use the configured Base URL concatenated with the path. Examples:

```
GET {base_url}/v1.0/end-user/homes/all
POST {base_url}/v1.0/end-user/devices/{device_id}/shadow/properties/issue
```

Authentication is via the `Authorization: Bearer {Api-key}` header (handled automatically by the Python SDK).

## Response Format

APIs return a unified structure:

**Success response**:
```json
{
  "success": true,
  "t": 1710234567890,
  "result": { ... }
}
```

**Error response**:
```json
{
  "success": false,
  "code": 1108,
  "msg": "uri path invalid"
}
```

- When `success` is `true`, the result is in the `result` field
- When `success` is `false`, error details are in the `code` and `msg` fields
- The Python SDK automatically checks `success` and raises `TuyaAPIError` on failure
- HTTP 429 and transient 5xx responses are retried automatically with backoff

references/device-control.md

# Device Control

## 1. Query Device Thing Model

Query the Thing Model definition of a specified device to understand which functional properties it supports.

**Request**

```
GET /v1.0/end-user/devices/{device_id}/model
```

**Path Parameters**

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| device_id | String | Yes | Device ID |

**Response**

```json
{
  "success": true,
  "t": 1673423649773,
  "result": {
    "model": "{\"modelId\":\"000004****\",\"services\":[{\"code\":\"\",\"description\":\"\",\"name\":\"\",\"properties\":[{\"code\":\"switch_led\",\"description\":\"Light switch\",\"accessMode\":\"rw\",\"name\":\"Switch\",\"typeSpec\":{\"type\":\"bool\"},\"abilityId\":20},{\"code\":\"bright_value\",\"description\":\"Brightness adjustment\",\"accessMode\":\"rw\",\"name\":\"Brightness\",\"typeSpec\":{\"max\":1000,\"scale\":0,\"type\":\"value\",\"unit\":\"\",\"min\":10,\"step\":1},\"abilityId\":22}]}]}"
  }
}
```

> `result.model` is a JSON string that needs to be parsed again.

**Parsed model structure**

```json
{
  "modelId": "000004****",
  "services": [
    {
      "code": "",
      "name": "",
      "description": "",
      "properties": [
        {
          "abilityId": 20,
          "code": "switch_led",
          "name": "Switch",
          "description": "Light switch",
          "accessMode": "rw",
          "typeSpec": {
            "type": "bool"
          }
        },
        {
          "abilityId": 22,
          "code": "bright_value",
          "name": "Brightness",
          "description": "Brightness adjustment",
          "accessMode": "rw",
          "typeSpec": {
            "type": "value",
            "min": 10,
            "max": 1000,
            "step": 1,
            "unit": "",
            "scale": 0
          }
        }
      ]
    }
  ]
}
```

### Thing Model Structure

**service**

| Field | Type | Description |
|-------|------|-------------|
| code | String | Service identifier; empty string represents the default service |
| name | String | Service name |
| description | String | Service description |
| properties | List | Property definition list |

**property**

| Field | Type | Description |
|-------|------|-------------|
| abilityId | Integer | Ability identifier ID |
| code | String | Property code (used as the key when issuing properties) |
| name | String | Property display name |
| description | String | Property description |
| accessMode | String | Access mode: `ro` read-only, `wr` write-only, `rw` read-write |
| typeSpec | Object | Data type specification |

### typeSpec Type Definitions

**value (numeric)**

```json
{ "type": "value", "min": 0, "max": 100, "step": 1, "unit": "%", "scale": 0 }
```

- `scale`: Decimal multiplier. Actual value = input value / 10^scale. Example: if `scale` is `1` and raw value is `255`, actual value = 255 / 10^1 = 25.5

**bool (boolean)**

```json
{ "type": "bool" }
```

- Values: `true` or `false`

**enum (enumeration)

references/device-management.md

# Device Management

## Rename Device

Modify a device's custom name by device ID.

**Request**

```
POST /v1.0/end-user/devices/{device_id}/attribute
```

**Path Parameters**

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| device_id | String | Yes | Device ID |

**Request Body**

| Parameter | Type | Required | Description | Constraints |
|-----------|------|----------|-------------|-------------|
| name | String | Yes | New device name | Max 50 characters, cannot be empty |

**Request Example**

```json
{
  "name": "Master Bedroom Smart Bedside Lamp"
}
```

**Response (success)**

```json
{
  "success": true,
  "t": 1706256000000,
  "result": {
    "device_id": "0620068884f3eb414579",
    "name": "Master Bedroom Smart Bedside Lamp"
  }
}
```

**Response (device not found)**

```json
{
  "success": false,
  "t": 1706256000000,
  "code": "DEVICE_NOT_EXIST_V2",
  "msg": "Device does not exist"
}
```

**Response Fields**

| Field | Type | Description |
|-------|------|-------------|
| result.device_id | String | Device ID |
| result.name | String | Updated device name |

Sponsored

Ads related to Tuya Smart Control and adjacent AI workflows.