Tuya Electric Vehicle Status & Safety Skill
Basic Information
- Authentication: Via Header
Authorization: Bearer {Api-key} - Credentials: Read from environment variable
TUYA_API_KEY. The base URL is auto-detected from the API key prefix (e.g.sk-AY...→ China,sk-EU...→ Europe). You can override by settingTUYA_BASE_URL. - API Reference: See individual files under
references/ - Python SDK: See
scripts/tuya_api.py, which provides aTuyaAPIclass for calling all APIs directly
Environment Variable Configuration
Set the following environment variable before use:
export TUYA_API_KEY="your-tuya-api-key"
# TUYA_BASE_URL is optional — auto-detected from API key prefix
API Key Prefix → Data Center Mapping
| 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/
The skill will not load if the TUYA_API_KEY environment variable is missing.
Usage
Via Python SDK (Recommended)
import sys
sys.path.insert(0, "{baseDir}/scripts")
from tuya_api import TuyaAPI
api = TuyaAPI()
# List all devices, then filter for electric vehicles
devices = api.get_all_devices()
# Get vehicle detail (battery, signal, location, online status)
detail = api.get_device_detail("your_device_id")
# Query weather at vehicle location
weather = api.get_weather(lat="30.27", lon="120.15")
Via Command Line
python3 {baseDir}/scripts/tuya_api.py devices
python3 {baseDir}/scripts/tuya_api.py device_detail <device_id>
python3 {baseDir}/scripts/tuya_api.py weather <lat> <lon>
Feature Overview
| Module | Capabilities | Reference |
|---|---|---|
| Vehicle Discovery | List all devices, filter electric vehicles by category | references/device-query.md |
| Vehicle Status | Battery level, signal strength, online/offline, last GPS location | references/device-query.md |
| Weather at Location | Temperature, humidity, weather condition at vehicle's last reported position | references/weather.md |
Scope
This skill focuses exclusively on read-only monitoring of electric vehicles. It does NOT support:
- Remotely locking/unlocking the vehicle
- Sending control commands to the vehicle
- Device pairing or removal
- Firmware upgrades
- Video/camera operations
If the user requests any of these, inform them that this skill is for status monitoring only and suggest using the Tuya App for control operations.
Core Workflows
Workflow 1: Find the User's Electric Vehicle
When the user asks about their electric vehicle (e.g. "check my e-bike", "how's my scooter doing"):
- List all devices — Call the "List All Devices" API
- Filter for electric vehicles — Electric vehicle / e-bike devices typically have category codes like
ddc(electric vehicle),cldc(e-bike tracker), or similar mobility-related categories. Match bycategoryorcategory_namecontaining keywords related to electric vehicles, motorcycles, scooters, or trackers - Handle ambiguity:
- If only one EV device is found, use it directly
- If multiple EV devices are found, list them and ask the user to choose
- If no EV device is found, show all devices and ask the user to identify which one is their vehicle
Workflow 2: Query Vehicle Status
When the user asks about battery, signal, online status, or location (e.g. "what's my e-bike's battery?", "is my scooter online?", "where is my electric vehicle?"):
- Locate the vehicle — Use Workflow 1 to find the target device and get its
device_id - Get device detail — Call
GET /v1.0/end-user/devices/{device_id}/detail - Extract status from properties — The
propertiesfield contains the vehicle's real-time state. Common property codes for electric vehicles include:
| Property Code | Description | Typical Type |
|---|---|---|
battery_percentage / battery / va_battery |
Battery level (%) | value (0-100) |
signal_strength / signal |
Signal strength | value |
latitude / lat |
GPS latitude | string/value |
longitude / lon |
GPS longitude | string/value |
gps_state |
GPS fix status | bool/enum |
last_update_time |
Last report time | string/value |
Since property codes vary across manufacturers, use the Thing Model API (GET /v1.0/end-user/devices/{device_id}/model) to discover the actual property codes and their meanings if the common codes above don't match.
- Present the status — Summarize the vehicle's status in natural language. For example:
Your electric vehicle "My E-bike" is currently online.
- Battery: 78%
- Signal strength: Good (85)
- Last reported location: 30.2741°N, 120.1551°E
- Last update: 2 minutes ago
Workflow 3: Query Weather at Vehicle Location
When the user asks about weather conditions at their vehicle's location (e.g. "what's the weather where my e-bike is parked?", "is it raining at my scooter's location?"):
-
Get vehicle location — Follow Workflow 2 to get the vehicle's latitude and longitude from the device properties
-
Query weather — Call the Weather API with the vehicle's coordinates:
GET /v1.0/end-user/services/weather/recent?codes=["w.temp","w.humidity","w.condition","w.realFeel","w.windLevel","w.hour.7"]&lat={lat}&lon={lon} -
Present weather info — Translate the response into a user-friendly summary:
Weather at your vehicle's location (30.27°N, 120.15°E):
- Temperature: 12°C (feels like 9°C)
- Humidity: 65%
- Condition: Partly Cloudy
- Wind: Level 3
If the vehicle has no GPS data, ask the user for a city or coordinates to query weather manually.
Workflow 4: Comprehensive Status Check
When the user says something general like "check my e-bike" or "how's my vehicle doing", combine Workflows 2 and 3 to give a full status report:
- Get the vehicle detail (battery, signal, online status, location)
- If GPS coordinates are available, also query weather at that location
- Present everything in one clear summary
API Calling Convention
Request Format
All APIs use the configured Base URL concatenated with the path:
GET {base_url}/v1.0/end-user/devices/all
GET {base_url}/v1.0/end-user/devices/{device_id}/detail
GET {base_url}/v1.0/end-user/devices/{device_id}/model
GET {base_url}/v1.0/end-user/services/weather/recent
Response Format
Success:
{
"success": true,
"t": 1710234567890,
"result": { ... }
}
Error:
{
"success": false,
"code": 1108,
"msg": "uri path invalid"
}
Error Handling
| Scenario | How to Handle |
|---|---|
| No EV device found | Show all available devices and ask the user which one is their vehicle |
| Device offline | Inform the user the vehicle is offline and show the last known status |
| No GPS data in properties | Tell the user the vehicle has no recent location data; ask for a city to query weather manually |
| Token invalid (code: 1010) | Tell the user the API key has expired and needs to be updated |
| API call failure | Tell the user the service is temporarily unavailable, please try again later |
| Other issues | Guide the user to visit https://github.com/tuya/tuya-openclaw-skills |
Important Notes
- Electric vehicle category codes vary by manufacturer — always check
categoryandcategory_nameto identify the right device, and be flexible with fuzzy matching - Property codes (like
battery_percentage,signal_strength,latitude) are not standardized across all EV products. When in doubt, query the Thing Model to discover the actual codes - GPS coordinates in device properties may use different formats (decimal degrees, or scaled integers). Check the Thing Model's
typeSpecfor thescalefield to convert correctly - The weather API requires latitude and longitude as strings
- This skill is read-only — it monitors status but does not send control commands to the vehicle
