OA0 = Omni AI 0
OA0 是一个探索 AI 的论坛
现在注册
已注册用户请  登录
OA0  ›  技能包  ›  switchbot:控制 SwitchBot 智能家居设备(窗帘、插座、锁等)

switchbot:控制 SwitchBot 智能家居设备(窗帘、插座、锁等)

 
  mcp ·  2026-02-15 19:40:33 · 3 次点击  · 0 条评论  

名称: switchbot
描述: 通过 SwitchBot Cloud API 控制 SwitchBot 智能家居设备(窗帘、插座、灯、锁等)。当用户要求打开/关闭窗帘、开关灯/插座、查看温湿度或控制任何 SwitchBot 设备时使用。


SwitchBot 智能家居控制

通过 Cloud API v1.1 控制 SwitchBot 设备。

首次设置

引导用户完成以下步骤:

1. 获取 API 凭证

请用户:
1. 在手机上打开 SwitchBot App
2. 进入 个人资料(右下角)
3. 点击 偏好设置(或设置)
4. 找到 关于开发者选项
5. 复制 TokenSecret Key

2. 安全存储凭证

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. 发现设备

运行发现脚本以查找所有设备:

python3 <skill_path>/scripts/switchbot.py list

4. 更新 TOOLS.md

发现设备后,在 TOOLS.md 中记录设备 ID 以便快速查阅:

## SwitchBot 设备
| 设备 | ID | 类型 |
|------|-----|------|
| 客厅窗帘 | ABC123 | Curtain3 |
| 卧室灯 | DEF456 | Plug Mini |

使用方法

列出所有设备

python3 <skill_path>/scripts/switchbot.py list

窗帘控制

# 打开窗帘(位置 0 = 全开)
python3 <skill_path>/scripts/switchbot.py curtain <device_id> open

# 关闭窗帘(位置 100 = 全关)
python3 <skill_path>/scripts/switchbot.py curtain <device_id> close

# 设置特定位置(0-100)
python3 <skill_path>/scripts/switchbot.py curtain <device_id> 50

插座/灯控制

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

检查传感器状态

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

通用命令

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

支持的设备

设备类型 命令
Curtain / Curtain3 open, close, setPosition
Plug Mini / Plug turnOn, turnOff, toggle
Bot press, turnOn, turnOff
Light / Strip Light turnOn, turnOff, setBrightness, setColor
Lock lock, unlock
Humidifier turnOn, turnOff, setMode
Meter / MeterPlus (只读:温度、湿度)
Hub / Hub Mini / Hub 2 (仅作为网关)

错误处理

状态码 含义
100 成功
151 设备离线
152 命令不支持
160 未知命令
161 参数无效
190 内部错误

给智能体的提示

  1. 首次交互:如果凭证不存在,引导用户完成设置
  2. 设备别名:在 TOOLS.md 中创建友好名称(例如,“客厅” → 设备 ID)
  3. 批量操作:可以按顺序控制多个设备
  4. 状态检查:报告传感器读数前使用 status 命令
  5. 错误恢复:如果设备离线(151),建议检查 Hub 连接

安全说明

  • 凭证文件应设置为 chmod 600
  • 切勿记录或显示 token/secret
  • API 调用通过 HTTPS 发送至 api.switch-bot.com
3 次点击  ∙  0 人收藏  
登录后收藏  
目前尚无回复
0 条回复
About   ·   Help   ·    
OA0 - Omni AI 0 一个探索 AI 的社区
沪ICP备2024103595号-2
Developed with Cursor