← 返回
开发者工具 Key

Switchbot

Control SwitchBot smart home devices (curtains, plugs, lights, locks, etc.) via SwitchBot Cloud API. Use when user asks to open/close curtains, turn on/off l...
通过 SwitchBot 云 API 控制 SwitchBot 智能家居设备(窗帘、插头、灯、锁等)。当用户要求打开/关闭窗帘、开关灯等时使用。
daaab
开发者工具 clawhub v1.0.1 2 版本 99817.4 Key: 需要
★ 1
Stars
📥 2,166
下载
💾 24
安装
2
版本
#latest

概述

SwitchBot Smart Home Control

Control SwitchBot devices through the Cloud API v1.1.

First-Time Setup

Guide your human through these steps:

1. Get API Credentials

Ask your human to:

  1. Open SwitchBot App on their phone
  2. Go to Profile (bottom right)
  3. Tap Preferences (or Settings)
  4. Find AboutDeveloper Options
  5. Copy Token and Secret Key

2. Store Credentials Securely

mkdir -p ~/.config/switchbot
chmod 700 ~/.config/switchbot

cat > ~/.config/switchbot/credentials.json << 'EOF'
{
  "token": "YOUR_TOKEN_HERE",
  "secret": "YOUR_SECRET_HERE"
}
EOF
chmod 600 ~/.config/switchbot/credentials.json

3. Discover Devices

Run the discovery script to find all devices:

python3 <skill_path>/scripts/switchbot.py list

4. Update Your TOOLS.md

After discovery, note your device IDs in TOOLS.md for quick reference:

## SwitchBot Devices
| Device | ID | Type |
|--------|-----|------|
| Living Room Curtain | ABC123 | Curtain3 |
| Bedroom Light | DEF456 | Plug Mini |

Usage

List All Devices

python3 <skill_path>/scripts/switchbot.py list

Curtain Control

# Open curtain (position 0 = fully open)
python3 <skill_path>/scripts/switchbot.py curtain <device_id> open

# Close curtain (position 100 = fully closed)
python3 <skill_path>/scripts/switchbot.py curtain <device_id> close

# Set specific position (0-100)
python3 <skill_path>/scripts/switchbot.py curtain <device_id> 50

Plug/Light Control

python3 <skill_path>/scripts/switchbot.py plug <device_id> on
python3 <skill_path>/scripts/switchbot.py plug <device_id> off

Check Sensor Status

python3 <skill_path>/scripts/switchbot.py status <device_id>

Generic Command

python3 <skill_path>/scripts/switchbot.py command <device_id> <command> [parameter]

Supported Devices

Device TypeCommands
-----------------------
Curtain / Curtain3open, close, setPosition
Plug Mini / PlugturnOn, turnOff, toggle
Botpress, turnOn, turnOff
Light / Strip LightturnOn, turnOff, setBrightness, setColor
Locklock, unlock
HumidifierturnOn, turnOff, setMode
Meter / MeterPlus(read-only: temperature, humidity)
Hub / Hub Mini / Hub 2(gateway only)

Error Handling

Status CodeMeaning
----------------------
100Success
151Device offline
152Command not supported
160Unknown command
161Invalid parameters
190Internal error

Tips for Agents

  1. First interaction: If no credentials exist, guide the human through setup
  2. Device aliases: Create friendly names in TOOLS.md (e.g., "living room" → device ID)
  3. Batch operations: Multiple devices can be controlled in sequence
  4. Status checks: Use status command before reporting sensor readings
  5. Error recovery: If device is offline (151), suggest checking Hub connection

Security Notes

  • Credentials file should be chmod 600
  • Never log or display the token/secret
  • API calls are made over HTTPS to api.switch-bot.com

版本历史

共 2 个版本

  • v1.0.1 当前
    2026-05-21 22:42 安全 安全
  • v1.0.0
    2026-03-28 17:56 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

developer-tools

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 921 📥 185,812
developer-tools

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 68 📥 180,288
content-creation

HeyGen AI Avatar Video (Lite)

daaab
使用 HeyGen API 创建 AI 数字人视频,免费入门指南。
★ 6 📥 3,983