用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/benx517/hermes_sos --skill smartthings-cli命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Extract text from PDFs and scanned documents. Use web_extract for remote URLs, pymupdf for local text-based PDFs, marker-pdf for OCR/scanned docs. For DOCX use python-docx, for PPTX see the powerpoint skill.
Diagnose home appliance faults using local knowledge base before searching external sources
Query Samsung SmartThings compatible devices catalog via GraphQL API — fetch all categories, super categories, brands, and products for China and global regions.
基于 SOC 职业分类
正在显示 SKILL.md
| name | smartthings-cli |
| description | Query and manage SmartThings devices via CLI, with China region support using --environment flag. |
| version | 1.0.0 |
| author | community |
| license | Apache-2.0 |
| metadata | {"hermes":{"tags":["Smart-Home","SmartThings","IoT","Samsung","China-Region"],"homepage":"https://github.com/SmartThingsCommunity/smartthings-cli"}} |
| prerequisites | {"commands":["smartthings"]} |
Command-line interface for managing SmartThings devices, especially for China region users.
npm install -g @smartthings/cli
Requirements: Node.js >= 22 (or at least 20.x may work with warnings)
The SmartThings CLI supports both global and China regions. Use the --environment flag:
# Query devices in China region
smartthings devices --environment china
# Query devices in global region (default)
smartthings devices --environment global
# All devices in China
smartthings devices --environment china
# With verbose output (includes location/room)
smartthings devices --environment china --verbose
# JSON output
smartthings devices --environment china --json
# Filter by capability
smartthings devices --environment china --capability switch
# Filter by device type
smartthings devices --environment china --type zigbee --type zwave
# Get specific device by ID
smartthings devices <device-id> --environment china
# Get device status
smartthings devices:status <device-id> --environment china
# Get device health
smartthings devices:health <device-id> --environment china
# Get device history
smartthings devices:history <device-id> --environment china
# List locations
smartthings locations --environment china
# List rooms in a location
smartthings locations:rooms <location-id> --environment china
# List scenes
smartthings scenes --environment china
# Execute a scene
smartthings scenes:execute <scene-id> --environment china
# List rules
smartthings rules --environment china
~/.config/@smartthings/cli/config.yaml~/Library/Preferences/@smartthings/cli/config.yaml%LOCALAPPDATA%\@smartthings\cli\config.yamlTo avoid typing --environment china every time, add to config:
default:
environment: china
default:
environment: global
china:
environment: china
indent: 2
Use with --profile flag:
smartthings devices --profile china
China region requires PAT -- browser OAuth is NOT supported.
The CLI automatically opens a browser window for OAuth login on first use. This only works for the global environment. If you try smartthings devices --environment china without a token, you'll get: a token is required for the china environment.
default:
token: <your-pat-uuid>
environment: china
If your config has a token set, the CLI will always use it -- smartthings logout does NOT clear bearer tokens. To force browser OAuth, you must manually remove the token line from config:
# Delete or edit config
rm ~/.config/@smartthings/cli/config.yaml
# Then run a command for the global environment (China requires PAT)
smartthings devices
default:
token: <your-pat-uuid>
environment: china
Or use inline:
smartthings devices --token <uuid> --environment china
Available --type filters:
ZIGBEE, ZWAVE, MATTERLAN, MQTT, OCFBLE, BLE_D2DVIRTUAL, MOBILEHUB, GROUPIR, IR_OCFENDPOINT_APP, DTHPENGYOU, SHP, VIDEO, VIPER, WATCHEDGE_CHILDIf you see EBADENGINE warnings about Node version:
# Upgrade Node.js to >= 22
# Or ignore warnings if CLI works
If you try to use browser_navigate for the PAT portal on an IDX/NixOS system:
npm install -g @playwright/test && npx playwright install chromium)error while loading shared libraries: libglib-2.0.so.0npx playwright install --with-deps fails because su: must be run from a terminalnix-env -iA nixpkgs.glib doesn't help -- NixOS doesn't use standard /lib paths# Note: smartthings logout does NOT clear bearer/PAT tokens in config.yaml.
# To force re-authentication:
# - For global: remove token from config.yaml, then run any command
# - For china: get a new PAT from https://account.samsungiotcloud.cn/tokens
# Force re-login (global only)
smartthings logout
smartthings devices
The China environment (--environment china) does NOT support browser OAuth. It requires a Personal Access Token (PAT) from https://account.samsungiotcloud.cn/tokens. Attempting to use China without a token produces: a token is required for the china environment.
Root cause (from source code):
In @smartthings/core-sdk/dist/endpoint-client.js:
globalSmartThingsURLProvider has authURL (auth-global.api.smartthings.com/oauth/token) and keyApiURLchinaSmartThingsURLProvider only has baseURL (api.samsungiotcloud.cn) — no authURL, no clientIdThe CLI's buildAuthenticator() in api-command.js checks 'clientId' in urlProvider to decide between browser OAuth vs PAT. Since China's provider lacks clientId, it falls through to the fatalError path.
A comment in the SDK reads: // When login auth flow is added for China, make authURL required again. — meaning Samsung has预留 this hook for future OAuth support.
CLI version check: As of 2026-04-20, @smartthings/cli@2.1.1 is the latest version and still has no China OAuth support.
China region uses different API endpoints. Some features available globally may not be available in China region and vice versa.
# Turn switch on/off
smartthings devices:commands <device-id> switch:on --environment china
smartthings devices:commands <device-id> switch:off --environment china
# Set brightness level
smartthings devices:commands <device-id> 'switchLevel:setLevel(50)' --environment china
# Set color temperature (Kelvin)
smartthings devices:commands <device-id> 'colorTemperature:setColorTemperature(2700)' --environment china
Important: Use single quotes around the command to prevent shell JSON parsing errors.
# Set hue (0-360)
smartthings devices:commands <device-id> 'colorControl:setHue(0)' --environment china
# Set saturation (0-100)
smartthings devices:commands <device-id> 'colorControl:setSaturation(100)' --environment china
The colorControl:setColor command has inconsistent argument formats depending on device type:
Format 1 (physical devices like Nanoleaf): {"color":{"hue":0,"saturation":100}}
smartthings devices:commands <device-id> 'colorControl:setColor({"color":{"hue":0,"saturation":100}})' --environment china
Format 2 (virtual lights): {"hue":0,"saturation":100} (no nested color key)
smartthings devices:commands <device-id> 'colorControl:setColor({"hue":0,"saturation":100})' --environment china
If setColor fails (422 error): Fall back to separate setHue and setSaturation commands — this is more reliable for virtual lights and some Matter devices:
# Reliable approach for all device types:
smartthings devices:commands <device-id> 'colorControl:setHue(0)' --environment china
smartthings devices:commands <device-id> 'colorControl:setSaturation(100)' --environment china
Color Reference:
⚠️ JSON Processing: python3 and jq may not be available on this system. Use node -e for JSON processing:
# List devices with label, type, location, room
smartthings devices --environment china --json | node -e "
const chunks=[]; process.stdin.on('data',d=>chunks.push(d));
process.stdin.on('end',()=>{
const data=JSON.parse(Buffer.concat(chunks));
data.forEach((d,i)=>console.log(\`\${i+1}. \${d.label} | \${d.type} | \${d.location} / \${d.room}\`));
});
"
# Count devices by type
smartthings devices --environment china --json | node -e "
const chunks=[]; process.stdin.on('data',d=>chunks.push(d));
process.stdin.on('end',()=>{
const data=JSON.parse(Buffer.concat(chunks));
const counts={}; data.forEach(d=>counts[d.type]=(counts[d.type]||0)+1);
console.log(counts);
});
"
smartthings devices --environment china --capability switch --json | jq '.[].label'
smartthings devices --environment china --json > devices.json
### ⚠️ Why China Requires PAT (Code-Level Analysis)
The `chinaSmartThingsURLProvider` in `@smartthings/core-sdk` only defines `baseURL` (`https://api.samsungiotcloud.cn`) — it is missing `authURL` and `clientId`. The CLI checks `'clientId' in urlProvider` to trigger browser OAuth. Since China's provider lacks it, the CLI falls back to: `fatalError('a token is required for the china environment')`. The SDK source explicitly comments: `// When login auth flow is added for China, make authURL required again.` This confirms the OAuth endpoints are simply not provisioned on the China backend yet.
### ⚠️ Common Pitfalls & Observations
### 1. Virtual vs Physical Devices
Many devices in SmartThings are **Virtual** (`type: "VIRTUAL"`).
- They accept commands and update state successfully.
- **However, they have no physical effect** (no actual light turns on).
- Always check `type` in device details if the user complains "it didn't work" despite a successful command.
### 2. Location/Room Confusion
- Device labels (e.g., "顶灯1") can be duplicated across different rooms (e.g., Living Room vs Dining Room).
- **Always verify the `roomId` and room name** before executing commands if multiple devices share the same label.
### 3. Bulk Command Permissions (403 Forbidden)
- When executing bulk commands across many devices, you may get **403 Forbidden** for some.
- This usually happens when devices belong to **different Locations** (e.g., "Existing user" location) or are managed by a different Hub/Account that the current CLI profile doesn't have write access to.
- Use `;` instead of `&&` when chaining commands to ensure execution continues for authorized devices even if one fails.
## Related Resources
- GitHub: https://github.com/SmartThingsCommunity/smartthings-cli
- API Docs: https://developer.smartthings.com/docs/api/public/
- Core SDK: https://github.com/SmartThingsCommunity/smartthings-core-sdk