agentleFS
facebookincubatorfacebookincubator/muse-gadget-sdk/skills/gadget-tuya-cloud-devices/SKILL.md

gadget-tuya-cloud-devices

Skill2.8k starsChanged 26 days agoApache-2.0View on GitHub

Read status and control the user's Tuya app devices through Tuya's cloud end-user API with a user-supplied API key: homes and rooms, device detail, thing-model property control, rename, weather, hourly statistics, self-send notifications, IPC cloud snapshots and real-time event subscription. Cloud only; prefer a device-specific or local-TCP skill when one matches. Switching heaters, valves, openers, irrigation or unknown loads needs the user's confirmation.

Trending

More talk lately.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 13 mentionsNov 2026: 1 mention
Dec 2025Jun 2026Nov 2026
Mentions a month of the facebookincubator/muse-gadget-sdk repository that our weekly crawl found: only 14 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Who's talking about facebookincubator/muse-gadget-sdk

The biggest 5 of 14 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 14

Talked about on GitHub, Bluesky and Hacker News (14 times).

On GitHub · 11

6 more on GitHub

On Hacker News · 1

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use this skill when the user supplies a Tuya end-user API key (sk-...) and asks to control or query devices from their Tuya app account.

    line 13
  2. Very specific:

    Read and follow the Home Link networking and safety rules in ~/docs/devices/home_link.md.

    line 20
  3. Very specific:

    Read GET /v1.0/end-user/devices/{device_id}/detail.

    line 52
  4. Very specific:

    Read the thing model GET /v1.0/end-user/devices/{device_id}/model.

    line 55
  5. Distinctive:

    Before switching a heater, valve, garage or door opener, irrigation controller, or a socket, plug or switch whose load is unknown, read …

    line 75
  6. Distinctive:

    Wait 1–2 seconds, re-read the detail and compare the mapped value with the requested value before reporting success.

    line 88
  7. Distinctive:

    If the value does not match or the device went offline, say so.

    line 91
  8. Distinctive:

    Start it only when the user asks for ongoing monitoring or automation, and run one instance per key.

    line 146
  9. Distinctive:

    No lock/unlock, live video streaming, firmware updates, pairing or device removal — say so and point to the Tuya app.

    line 171

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Tuya Cloud Devices: End-User API Control

Use this skill when the user supplies a Tuya end-user API key (sk-...) and asks to control or query devices from their Tuya app account. Devices are reached in the cloud, so no local keys or model-specific datapoint maps are needed. For direct local-TCP control with a confirmed key and datapoint schema, prefer Tuya Wi-Fi devices.

Prerequisites

Read and follow the Home Link networking and safety rules in ~/docs/devices/home_link.md.

Workflow

  1. List homes with GET /v1.0/end-user/homes/all, and rooms with GET /v1.0/end-user/homes/{home_id}/rooms when the user names one.
  2. Locate the device: GET /v1.0/end-user/devices/all, or scope to .../homes/{home_id}/devices or .../homes/room/{room_id}/devices. Each entry in result.devices[] carries device_id, name, category, category_name, online and, under a home scope, room_id. Match the user's words against category_name first, then fuzzy-match name. With multiple matches, list the candidates with their rooms and ask.
  3. Read GET /v1.0/end-user/devices/{device_id}/detail. A null result means the device does not exist or the key has no access — stop. online: false means report the device as offline and command nothing. result.properties maps each property code to its current value.
  4. Read the thing model GET /v1.0/end-user/devices/{device_id}/model. Its result.model field is a JSON string that needs a second parse. services[].properties[] then defines each property's code, accessMode (ro is read-only — say so; wr is write-only and cannot be read back) and typeSpec:
    • value: min, max, step and scale — the real-world value is the raw number divided by 10^scale.
    • enum: the issued value must be one of range.
    • bool / string: true/false, and maxlen respectively. Common codes are switch_led/switch (bool power), bright_value/temp_value (0–1000), temp_set (16–30) and mode (enum) — the model response is always authoritative.
  5. Issue POST /v1.0/end-user/devices/{device_id}/shadow/properties/issue with a body whose properties value is a JSON string, not an object — it is double-serialized: {"properties": "{\"switch_led\":true}"}. An empty result object means the command was accepted, not that it took effect. For relative asks ("a bit brighter"), adjust the current value by 10% of the typeSpec range for vague amounts or by the stated amount exactly, clamp to [min, max], honor scale and round to step. A relative ask needs a readable current value; for a wr property, ask for an absolute value instead.

Confirm Before Acting

  • Before switching a heater, valve, garage or door opener, irrigation controller, or a socket, plug or switch whose load is unknown, read back the device, its room, the property and the value, and wait for the user's yes. A yes covers that one command only.
  • Judge this by the device's category from the device list, not only by its name: for example qn, rs, dr and dbl (heaters), sfkzq and ggq (valves and irrigation), ckmkzq and mk (garage doors and access control), and cz, pc and kg (sockets, power strips and switches, unless the user has said what they power and it is none of these). Confirm an unfamiliar category the same way.
  • An automation's confirmed trigger→action mapping covers its later actions only if it names the device and the action.

Verify the Result

  • Wait 1–2 seconds, re-read the detail and compare the mapped value with the requested value before reporting success. A value that already matched before the write is a success.
  • A wr property cannot be read back: report the command as accepted but unverified.
  • If the value does not match or the device went offline, say so; do not report success.

Also Available

  • Rename: POST /v1.0/end-user/devices/{device_id}/attribute with {"name": "..."}, max 50 characters.
  • Weather: GET /v1.0/end-user/services/weather/recent with lat, lon and codes — a URL-encoded JSON array of attribute codes such as w.temp, w.humidity, w.condition, w.conditionNum, w.pressure, w.realFeel, w.uvi, w.windDir, w.windLevel, w.windSpeed, plus w.hour.N to set the forecast horizon to the next N hours. Response keys are {code}.{index} with index 0 meaning now. Use the home's latitude / longitude from the homes list, shaped {"Value": "30.3"} — read the inner Value. If the home has none set, ask the user for their city and use its latitude and longitude.
  • Hourly statistics: confirm capability with GET /v1.0/end-user/statistics/hour/config (items carry dev_id, dp_code, statistic_type of SUM/COUNT/MAX/MIN), then GET .../hour/data?dev_id=..&dp_code=..&statistic_type=..&start_time=..&end_time=... Times are yyyyMMddHH and one request spans at most 24 hours; split longer ranges and aggregate. Values return as an array of {time: value} pairs with string values.
  • Notifications are self-send only — they reach the key's own user, nobody else: POST /v1.0/end-user/services/{sms|voice|mail|push}/self-send. SMS and voice take {"message": "..."}; mail and push take {"subject": "...", "content": "..."}. Rate and duplicate limits apply (per contact: 15–30 per day, identical content more than twice within 50 seconds is refused).
  • IPC cloud snapshots (cameras): first ask the user to confirm they want a capture from that camera and a decrypted, viewable link to it. A request for a snapshot is not by itself that consent; if they decline, do not capture.
    1. Allocate with POST /v1.0/end-user/ipc/{device_id}/capture/allocate and body {"capture_json": "<json string>"} — double-serialized like property issue. The string carries device_id, capture_type (PIC or VIDEO), optionally pic_count (clamped to 1–5), video_duration_seconds (1–60, default 10) and home_id. Allocate only reserves an upload slot: result.status is ACCEPTED or REJECTED and result carries bucket, encryption_key and the object key(s) (image_object_key, and for VIDEO also video_object_key / cover_image_object_key) — never a media URL; the device still has to capture and upload. With pic_count above 1, pic_slots[] holds per-snapshot keys.
    2. Resolve with POST .../capture/resolve and a resolve_json string echoing device_id, capture_type, bucket, encryption_key and the object key(s) — one resolve per pic_slots[] entry, with that slot's key and encryption_key. Set user_privacy_consent_accepted: true only after the user's explicit yes for this capture; never set it on their behalf. It returns the decrypted decrypt_image_url / decrypt_video_url (and decrypt_cover_image_url); without it, resolve returns encrypted raw_presigned_* URLs that cannot be viewed.
    3. status: NOT_READY means keep polling — for PIC sleep 2 s, then resolve every 2 s up to 30 s, then retry up to 3 times 3 s apart; for VIDEO sleep max(5, video_duration_seconds_effective) + 2 s using the clamped duration from the allocate response, then resolve every 2 s up to 120 s, then retry up to 3 times 5 s apart. A video's cover image can lag the video itself — check message_for_user.
    4. The link is private camera footage: give it only to the requesting user; never log or forward it.

Real-Time Subscription

Property changes and online/offline transitions are also pushed over WebSocket. This is a long-lived process for an always-on host (a Linux gadget), not a one-shot query. Write a short Python script using the websockets package:

  • Start it only when the user asks for ongoing monitoring or automation, and run one instance per key. Read the key from the user-only file (see Prerequisites) instead of writing it into the script, and tell the user where it runs and how to stop it.
  • URI by key prefix (same mapping as the REST table): AZ wss://wsmsgs.iot-wus.com, EU wss://wsmsgs.iot-eu.com, IN wss://wsmsgs.iot-ap.com, UE wss://wsmsgs.iot-eus.com, WE wss://wsmsgs.iot-weu.com, SG wss://wsmsgs.iot-sea.com.
  • Auth: an Authorization: <key> header on the handshake — the same key as REST but without the Bearer prefix.
  • Frames are JSON with two top-level fields, eventType and data. A devicePropertyChange carries data.devId and data.status[], each with code, value and time (ms); an onlineStatusChange carries data.devId, data.status ("online"/"offline") and data.time.
  • Codes match thing-model codes. Look their meanings up via the model endpoint instead of guessing from the code string.
  • Reconnect with backoff on transient drops. Treat close codes 1002, 1003 and 1008 as fatal. Close code 1011 is a server error: retry it a few times with growing backoff, then stop and tell the user. A frame containing error, errorMsg, a failing errorCode, or "success": false is a server error: stop and report it.
  • For event-driven automation, on a matching trigger issue properties to the action device as in Workflow step 5, and confirm the trigger→action mapping with the user before running it.

Limits

  • Control only basic property types (bool, enum, integer value, string). Never write raw, bitmap, struct or array properties, or anything absent from the thing model.
  • No lock/unlock, live video streaming, firmware updates, pairing or device removal — say so and point to the Tuya app.
  • Device listing takes one scope at a time (all, home or room). Rate-limit batch writes with a short delay between commands.
  • Notifications triggered by device events must cool down at least 30 minutes — property events fire frequently.
  • These are the user's own account devices behind an end-user key; never attempt another user's devices.

Sources

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.