360 Secure SkillHub
360 安全技能中心

tuya-ride-control

基于 Tuya 2C 端用户 API 的只读监控技能:列出并筛选电动车设备,读取电池电量、信号强度、在线状态与最近 GPS 位置,并可按坐标查询车辆所在地天气;需配置 TUYA_API_KEY,可通过 Python 脚本或 SDK 调用。

ypan2411
ypan2411
热度 20.55
最近更新 2026-03-20 18:36:48
分类:生活依赖:代码执行 / 第三方 API应用场景:报告撰写 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add tuya-ride-control
Metadata
name
Tuya-ride-control
description
Tuya-ride-control is an AI Agent skill for electric vehicle (EV/e-bike) status monitoring and safety management, built on Tuya's 2C end-user APIs. It helps users check their electric vehicle's battery level, signal strength, online status, last reported GPS location, and query weather conditions at the vehicle's location. Use this skill whenever the user mentions electric vehicles, e-bikes, scooters, battery status, vehicle location, ride safety, or wants to check on their EV — even if they don't explicitly say "ride control".
metadata
{"openclaw":{"emoji":"🛵","name":"Tuya-ride-control","description":"Tuya-ride-control is an AI Agent skill for electric vehicle (EV/e-bike) status monitoring and safety management, built on Tuya's 2C end-user APIs. Check battery, signal, online status, GPS location, and weather at vehicle location.","requires":{"env":["TUYA_API_KEY"],"pip":["requests"]},"primaryEnv":"TUYA_API_KEY","env":{"TUYA_API_KEY":{"label":"Tuya API Key","description":"Your Tuya Open Platform API Key (base URL is auto-detected from key prefix, e.g. sk-AY... → China, sk-AZ... → US, sk-EU... → Europe)","placeholder":"e.g. sk-AY12c7ee...","required":true}}}}

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 setting TUYA_BASE_URL.
  • API Reference: See individual files under references/
  • Python SDK: See scripts/tuya_api.py, which provides a TuyaAPI class 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:

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"):

  1. List all devices — Call the "List All Devices" API
  2. 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 by category or category_name containing keywords related to electric vehicles, motorcycles, scooters, or trackers
  3. 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?"):

  1. Locate the vehicle — Use Workflow 1 to find the target device and get its device_id
  2. Get device detail — Call GET /v1.0/end-user/devices/{device_id}/detail
  3. Extract status from properties — The properties field 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.

  1. 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?"):

  1. Get vehicle location — Follow Workflow 2 to get the vehicle's latitude and longitude from the device properties

  2. 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}
    
  3. 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:

  1. Get the vehicle detail (battery, signal, online status, location)
  2. If GPS coordinates are available, also query weather at that location
  3. 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

  1. Electric vehicle category codes vary by manufacturer — always check category and category_name to identify the right device, and be flexible with fuzzy matching
  2. 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
  3. GPS coordinates in device properties may use different formats (decimal degrees, or scaled integers). Check the Thing Model's typeSpec for the scale field to convert correctly
  4. The weather API requires latitude and longitude as strings
  5. This skill is read-only — it monitors status but does not send control commands to the vehicle