tuya/tuya-openclaw-skills/tuya-smart-control
Claude Code and agent skill by tuya/tuya-openclaw-skills
- community
Checking that the SKILL.md file is still in the repository.
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.
Install
npx vskill@latest install tuya/tuya-openclaw-skills/tuya-smart-controlSKILL.md
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— obtain it at tuyasmart.com (China Mainland) or tuya.ai (International). Base URL is auto-detected from API key prefix. Seereferences/api-conventions.mdfor the prefix-to-region mapping table. You can override by settingTUYA_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:
Where to get an API Key:
| User Type | Where to Get | |
|---|---|---|
| China Mainland | tuyasmart.com | |
| International | tuya.ai |
The API Key format is sk-<PREFIX><rest>, where the prefix is used to automatically identify the data center. Make sure the API Key region matches your Tuya account registration region.
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)
CLI validation rules:
devicessupports only one scope flag at a time:--home <id>or--room <id>controlrequiresproperties_jsonto be a valid JSON object (not array/string)weathervalidates coordinate range: latitude[-90, 90], longitude[-180, 180]stats_datavalidatesstart/endformatyyyyMMddHHand max 24-hour windowipc_pic_fetchargs:<device_id> <consent> [pic_count] [home_id]— consent1= decrypted URLipc_video_fetchargs:<device_id> <duration> <consent> [home_id]— duration in seconds (1-60)- Use
python3 {baseDir}/scripts/tuya_api.py --helpfor command help and examples
Method 2: Via Python SDK
Use when you need to chain multiple API calls or do complex logic in a single script:
Method 3: Device Message Subscription (WebSocket)
Use when you need real-time device event monitoring (property changes, online/offline status):
Important: The WebSocket client runs server-side only. It reuses the sameTUYA_API_KEY— no separate credentials needed. The WebSocket URI is auto-detected from the key prefix (same 7 data centers as the REST API). Notification throttling (minimum 30-minute cooldown) is mandatory when triggering notifications from device events. Seereferences/device-message.mdfor message format details and more examples.
Feature Overview
| Module | Capabilities | Reference | |
|---|---|---|---|
| Home Management | List all homes, list rooms in a home | references/home-and-space.md | |
| Device Query | All devices, devices by home/room, single device detail (including current property states) | references/device-query.md | |
| Device Control | Query device Thing Model, issue property commands | references/device-control.md | |
| Device Management | Rename device | references/device-management.md | |
| Weather Service | Current and forecast weather | references/weather.md | |
| Notifications | SMS, voice call, email, App push | references/notifications.md | |
| Data Statistics | Hourly statistics config query, statistics value query | references/statistics.md | |
| IPC Cloud Capture | Cloud snapshot and short video capture for IPC cameras | references/ipc-cloud-capture.md | |
| Device Message Subscription | Real-time WebSocket subscription for device property changes and online/offline events | references/device-message.md | |
| Error Handling | Error codes and recovery strategies | references/error-handling.md | |
| API Conventions | Request/response format, data center mapping | references/api-conventions.md |
Core Workflows
Workflow 1: Device Control
When the user says things like "turn on the living room light" or "set the AC temperature to 26 degrees":
- Locate the device — Find the target device based on the device name or location mentioned by the user. Follow this priority:
- Priority 1 — Room + category match: If the user mentions a room (e.g. "living room AC"), first query the home list → room list to match the room, then list devices in that room and match by
category_nameor devicename - Priority 2 — Device name match: If the user only mentions a device name (e.g. "AC"), call "List All Devices" API and match by
category_namefirst, then by devicenamefuzzy match - Priority 3 — Disambiguation: If multiple devices match, list all candidates with their room information and ask the user to choose
- Get current state — Call the "Get Single Device Detail" API
- If `result` is `null`: the device does not exist or you have no permission — inform the user and stop
- If `online` is `false`: the device is offline — tell the user "Device XX is currently offline, please check its power and network connection" and do not proceed further
- Only continue when
resultis valid andonlineistrue - The
propertiesfield contains current values of each functional property (e.g. switch state, brightness, temperature)
- Query capabilities — Call the "Query Device Thing Model" API to get the device's supported property list
- Important: The
result.modelfield is a JSON string that must be parsed again (e.g.json.loads(result["model"])) to obtain the property definitions - Check each property's
accessMode: ro(read-only): cannot be controlled, only queried — inform the user "this property is read-only"wr(write-only): can be controlled but current value cannot be readrw(read-write): can be both controlled and queried
- Map the command — Map the user's intent to Thing Model properties:
- Turn on/off → find a bool-type switch property (e.g.
switch_led,switch) - Adjust brightness → find a value-type brightness property
- Adjust temperature → find a value-type temp property
- If the device does not support the requested function, inform the user and list supported functions
- Relative adjustments — When the user says "a bit brighter", "lower the temperature by 2 degrees", etc.:
- Read the current value from
propertiesin the device detail (Step 2) - Read
min,max,stepfrom the Thing ModeltypeSpec(Step 3) - Calculate the target value:
- Vague ("a bit", "a little") → current value ± (max - min) × 10%
- Specific ("by 2 degrees", "by 100") → current value ± the specified amount
- Clamp the target value within [min, max] and round to the nearest
step
- Validate value range: Before issuing, confirm the target value is within the
typeSpecmin/max range
- Issue the command — Call the "Issue Properties" API using the Python SDK:
api.issue_properties(device_id, {property_code: value})
- The SDK handles
propertiesJSON string serialization automatically - If not using the SDK: the
propertiesfield must be a JSON string, not a JSON object. You must double-serialize:{"properties": "{\"switch_led\":true}"}
- Verify and return result — After issuing the command:
- Wait 1-2 seconds, then call "Get Device Detail" again to read the updated
properties - Compare the target value with the actual value to confirm execution
- If values match: inform the user the operation succeeded
- If values differ: tell the user "command sent, but the device state has not updated yet — there may be a delay"
Workflow 2: Rename Device
- Locate the device using Workflow 1 Step 1 to obtain the device_id
- Call the "Rename Device" API with the new name
- Return the result
Workflow 3: Notifications
- Identify the message type: SMS / Voice / Email / App Push
- Extract required parameters (message content; email and push also need a subject)
- Call the corresponding API (all notification APIs are self-send — messages can only be sent to the current logged-in user)
- Return the send result
Workflow 4: Weather Query
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingtuya-smart-control/SKILL.md
Popularity
- Repository stars
- 565
- Repository forks
- 46
- 7-day trend score
- 32
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 20 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/tuya/tuya-openclaw-skills/tuya-smart-control)