SwitchBot OpenAPI Skill
This skill equips the agent to operate SwitchBot devices via HTTPS requests to the official OpenAPI v1.1. It includes ready-to-run scripts and a Node CLI; use these instead of re-deriving the HMAC signature each time.
Quick Start (Operator)
- Set environment variables:
- SWITCHBOT_TOKEN: your OpenAPI token
- SWITCHBOT_SECRET: your OpenAPI secret
- Test (list devices):
- Bash:
scripts/list_devices.sh
- Node:
node scripts/switchbot_cli.js list
- Common tasks:
Basic controls:
- List devices:
node scripts/switchbot_cli.js list
- Get status:
node scripts/switchbot_cli.js status <deviceId>
- Turn on/off:
node scripts/switchbot_cli.js cmd <deviceId> turnOn / turnOff
- Toggle:
node scripts/switchbot_cli.js cmd <deviceId> toggle
- Press (Bot):
node scripts/switchbot_cli.js cmd <deviceId> press
Curtain / Curtain 3:
- Set position:
node scripts/switchbot_cli.js cmd <deviceId> setPosition --pos=50
(0=open, 100=closed; CLI auto-formats to 0,ff,50)
- Pause:
node scripts/switchbot_cli.js cmd <deviceId> pause
Lock / Lock Pro / Lock Ultra / Lock Lite:
- Lock/Unlock:
node scripts/switchbot_cli.js cmd <deviceId> lock / unlock
- Deadbolt:
node scripts/switchbot_cli.js cmd <deviceId> deadbolt
Lights (Color Bulb / Strip Light / Floor Lamp / Strip Light 3 / RGBICWW etc.):
- Set color:
node scripts/switchbot_cli.js cmd <deviceId> setColor --param="255:100:0"
- Set brightness:
node scripts/switchbot_cli.js cmd <deviceId> setBrightness --param=80
- Set color temp:
node scripts/switchbot_cli.js cmd <deviceId> setColorTemperature --param=4000
Fans (Battery Circulator Fan / Circulator Fan / Standing Circulator Fan):
- Wind mode:
node scripts/switchbot_cli.js cmd <deviceId> setWindMode --param=natural
- Wind speed:
node scripts/switchbot_cli.js cmd <deviceId> setWindSpeed --param=50
- Night light:
node scripts/switchbot_cli.js cmd <deviceId> setNightLightMode --param=1
- Auto-off timer:
node scripts/switchbot_cli.js cmd <deviceId> closeDelay --param=3600
Robot Vacuum S1/S1 Plus/K10+/K10+ Pro:
- Start:
node scripts/switchbot_cli.js cmd <deviceId> start
- Stop:
node scripts/switchbot_cli.js cmd <deviceId> stop
- Dock:
node scripts/switchbot_cli.js cmd <deviceId> dock
- Suction:
node scripts/switchbot_cli.js cmd <deviceId> PowLevel --param=2
Robot Vacuum K10+ Pro Combo / K20+ Pro / S10 / S20 / K11+:
- Start clean:
node scripts/switchbot_cli.js cmd <deviceId> startClean --param='{"action":"sweep_mop","param":{"fanLevel":2,"waterLevel":1,"times":1}}'
- Pause/Dock:
node scripts/switchbot_cli.js cmd <deviceId> pause / dock
- Volume:
node scripts/switchbot_cli.js cmd <deviceId> setVolume --param=50
- Self clean (S10/S20):
node scripts/switchbot_cli.js cmd <deviceId> selfClean --param=1
Blind Tilt:
- Set position:
node scripts/switchbot_cli.js cmd <deviceId> setPosition --param="up;60"
- Fully open:
node scripts/switchbot_cli.js cmd <deviceId> fullyOpen
- Close:
node scripts/switchbot_cli.js cmd <deviceId> closeUp / closeDown
Roller Shade:
- Set position:
node scripts/switchbot_cli.js cmd <deviceId> setPosition --param=50
Humidifier (original):
- Set mode:
node scripts/switchbot_cli.js cmd <deviceId> setMode --param=auto
Evaporative Humidifier / Auto-refill:
- Set mode:
node scripts/switchbot_cli.js cmd <deviceId> setMode --param='{"mode":7,"targetHumidify":60}'
- Child lock:
node scripts/switchbot_cli.js cmd <deviceId> setChildLock --param=true
Air Purifier (VOC/PM2.5/Table):
- Set mode:
node scripts/switchbot_cli.js cmd <deviceId> setMode --param='{"mode":2,"fanGear":2}'
- Child lock:
node scripts/switchbot_cli.js cmd <deviceId> setChildLock --param=1
Smart Radiator Thermostat:
- Set mode:
node scripts/switchbot_cli.js cmd <deviceId> setMode --param=1
- Set temp:
node scripts/switchbot_cli.js cmd <deviceId> setManualModeTemperature --param=22
Relay Switch 1PM / 1 / 2PM:
- Toggle:
node scripts/switchbot_cli.js cmd <deviceId> toggle
- Set mode:
node scripts/switchbot_cli.js cmd <deviceId> setMode --param=0
- 2PM channel:
node scripts/switchbot_cli.js cmd <deviceId> turnOn --param="1" (channel 1 or 2)
Garage Door Opener:
- Open/Close:
node scripts/switchbot_cli.js cmd <deviceId> turnOn / turnOff
Video Doorbell:
- Motion detection:
node scripts/switchbot_cli.js cmd <deviceId> enableMotionDetection / disableMotionDetection
Candle Warmer Lamp:
- Brightness:
node scripts/switchbot_cli.js cmd <deviceId> setBrightness --param=50
AI Art Frame:
- Next/Previous:
node scripts/switchbot_cli.js cmd <deviceId> next / previous
Keypad / Keypad Touch / Keypad Vision / Keypad Vision Pro:
- Create passcode:
node scripts/switchbot_cli.js cmd <deviceId> createKey --param='{"name":"Guest","type":"permanent","password":"12345678"}'
- Delete passcode:
node scripts/switchbot_cli.js cmd <deviceId> deleteKey --param='{"id":"11"}'
- ⚠️ Keypad commands are async — results come via webhook.
IR Remote - Air Conditioner:
- Set all:
node scripts/switchbot_cli.js cmd <deviceId> setAll --param="26,2,1,on"
(format: temperature, mode, fan speed, power state)
- mode: 0/1=auto, 2=cool, 3=dry, 4=fan, 5=heat
- fan: 1=auto, 2=low, 3=medium, 4=high
- power: on/off
IR Remote - TV:
- Channel:
node scripts/switchbot_cli.js cmd <deviceId> SetChannel --param=5
- Volume:
node scripts/switchbot_cli.js cmd <deviceId> volumeAdd / volumeSub
IR Remote - Others (DIY):
- Custom button:
node scripts/switchbot_cli.js cmd <deviceId> <buttonName> --commandType=customize
Scenes (fallback):
- List scenes:
node scripts/switchbot_cli.js scenes
- Execute scene:
node scripts/switchbot_cli.js scene <sceneId>
API Reference
Base URL: https://api.switch-bot.com
Path prefix: /v1.1
Daily limit: 10,000 API calls
Headers (all required):
- Authorization:
<SWITCHBOT_TOKEN>
- sign: HMAC-SHA256(
token + t + nonce, secret), Base64-encoded
- t: 13-digit millisecond timestamp
- nonce: random UUID
Key endpoints:
GET /v1.1/devices — list all devices
GET /v1.1/devices/{deviceId}/status — device status
POST /v1.1/devices/{deviceId}/commands — send command
GET /v1.1/scenes — list scenes
POST /v1.1/scenes/{sceneId}/execute — execute scene
Command body format:
{
"command": "<commandName>",
"parameter": "<string|object>",
"commandType": "command"
}
For IR "Others" (DIY) devices, use "commandType": "customize".
Agent Guidelines
- Always use the provided CLI scripts — they handle HMAC signatures automatically.
- The CLI runs preflight checks for BLE devices (Bot, Lock, Curtain, Blind Tilt) — requires Hub + Cloud Services enabled.
- For IR Air Conditioner, only
setAll is supported (not separate setMode/setTemp).
- For Keypad commands (createKey/deleteKey), results are async via webhook.
- If a command returns statusCode 160, the device may not support that command — use Scenes as fallback.
- Never log tokens/secrets. Ask user to set them as environment variables.
Files
scripts/switchbot_cli.js — Node CLI (list/status/cmd/scenes)
scripts/list_devices.sh — curl: list devices
scripts/get_status.sh — curl: get status
scripts/send_command.sh — curl: send command
scripts/list_scenes.sh — curl: list scenes
scripts/execute_scene.sh — curl: execute scene
references/commands.md — complete command reference per device type
references/examples.md — usage examples
1---2name: switchbot-openapi-23description: Control and query SwitchBot devices using the official OpenAPI (v1.1). Use when the user asks to list SwitchBot devices, get device status, or send commands (turn on/off, press, set mode, lock/unlock, curtain open %, IR air conditioner, lights, fans, robot vacuums, keypads, etc.). Requires SWITCHBOT_TOKEN and SWITCHBOT_SECRET.4---5
6# SwitchBot OpenAPI Skill
7
8This skill equips the agent to operate SwitchBot devices via HTTPS requests to the official OpenAPI v1.1. It includes ready-to-run scripts and a Node CLI; use these instead of re-deriving the HMAC signature each time.
9
10## Quick Start (Operator)
11
121) Set environment variables:
13- SWITCHBOT_TOKEN: your OpenAPI token
14- SWITCHBOT_SECRET: your OpenAPI secret
15
162) Test (list devices):
17- Bash: `scripts/list_devices.sh`
18- Node: `node scripts/switchbot_cli.js list`
19
203) Common tasks:
21
22**Basic controls:**
23- List devices: `node scripts/switchbot_cli.js list`
24- Get status: `node scripts/switchbot_cli.js status <deviceId>`
25- Turn on/off: `node scripts/switchbot_cli.js cmd <deviceId> turnOn` / `turnOff`
26- Toggle: `node scripts/switchbot_cli.js cmd <deviceId> toggle`
27- Press (Bot): `node scripts/switchbot_cli.js cmd <deviceId> press`
28
29**Curtain / Curtain 3:**
30- Set position: `node scripts/switchbot_cli.js cmd <deviceId> setPosition --pos=50`
31 (0=open, 100=closed; CLI auto-formats to `0,ff,50`)
32- Pause: `node scripts/switchbot_cli.js cmd <deviceId> pause`
33
34**Lock / Lock Pro / Lock Ultra / Lock Lite:**
35- Lock/Unlock: `node scripts/switchbot_cli.js cmd <deviceId> lock` / `unlock`
36- Deadbolt: `node scripts/switchbot_cli.js cmd <deviceId> deadbolt`
37
38**Lights (Color Bulb / Strip Light / Floor Lamp / Strip Light 3 / RGBICWW etc.):**
39- Set color: `node scripts/switchbot_cli.js cmd <deviceId> setColor --param="255:100:0"`
40- Set brightness: `node scripts/switchbot_cli.js cmd <deviceId> setBrightness --param=80`
41- Set color temp: `node scripts/switchbot_cli.js cmd <deviceId> setColorTemperature --param=4000`
42
43**Fans (Battery Circulator Fan / Circulator Fan / Standing Circulator Fan):**
44- Wind mode: `node scripts/switchbot_cli.js cmd <deviceId> setWindMode --param=natural`
45- Wind speed: `node scripts/switchbot_cli.js cmd <deviceId> setWindSpeed --param=50`
46- Night light: `node scripts/switchbot_cli.js cmd <deviceId> setNightLightMode --param=1`
47- Auto-off timer: `node scripts/switchbot_cli.js cmd <deviceId> closeDelay --param=3600`
48
49**Robot Vacuum S1/S1 Plus/K10+/K10+ Pro:**
50- Start: `node scripts/switchbot_cli.js cmd <deviceId> start`
51- Stop: `node scripts/switchbot_cli.js cmd <deviceId> stop`
52- Dock: `node scripts/switchbot_cli.js cmd <deviceId> dock`
53- Suction: `node scripts/switchbot_cli.js cmd <deviceId> PowLevel --param=2`
54
55**Robot Vacuum K10+ Pro Combo / K20+ Pro / S10 / S20 / K11+:**
56- Start clean: `node scripts/switchbot_cli.js cmd <deviceId> startClean --param='{"action":"sweep_mop","param":{"fanLevel":2,"waterLevel":1,"times":1}}'`
57- Pause/Dock: `node scripts/switchbot_cli.js cmd <deviceId> pause` / `dock`
58- Volume: `node scripts/switchbot_cli.js cmd <deviceId> setVolume --param=50`
59- Self clean (S10/S20): `node scripts/switchbot_cli.js cmd <deviceId> selfClean --param=1`
60
61**Blind Tilt:**
62- Set position: `node scripts/switchbot_cli.js cmd <deviceId> setPosition --param="up;60"`
63- Fully open: `node scripts/switchbot_cli.js cmd <deviceId> fullyOpen`
64- Close: `node scripts/switchbot_cli.js cmd <deviceId> closeUp` / `closeDown`
65
66**Roller Shade:**
67- Set position: `node scripts/switchbot_cli.js cmd <deviceId> setPosition --param=50`
68
69**Humidifier (original):**
70- Set mode: `node scripts/switchbot_cli.js cmd <deviceId> setMode --param=auto`
71
72**Evaporative Humidifier / Auto-refill:**
73- Set mode: `node scripts/switchbot_cli.js cmd <deviceId> setMode --param='{"mode":7,"targetHumidify":60}'`
74- Child lock: `node scripts/switchbot_cli.js cmd <deviceId> setChildLock --param=true`
75
76**Air Purifier (VOC/PM2.5/Table):**
77- Set mode: `node scripts/switchbot_cli.js cmd <deviceId> setMode --param='{"mode":2,"fanGear":2}'`
78- Child lock: `node scripts/switchbot_cli.js cmd <deviceId> setChildLock --param=1`
79
80**Smart Radiator Thermostat:**
81- Set mode: `node scripts/switchbot_cli.js cmd <deviceId> setMode --param=1`
82- Set temp: `node scripts/switchbot_cli.js cmd <deviceId> setManualModeTemperature --param=22`
83
84**Relay Switch 1PM / 1 / 2PM:**
85- Toggle: `node scripts/switchbot_cli.js cmd <deviceId> toggle`
86- Set mode: `node scripts/switchbot_cli.js cmd <deviceId> setMode --param=0`
87- 2PM channel: `node scripts/switchbot_cli.js cmd <deviceId> turnOn --param="1"` (channel 1 or 2)
88
89**Garage Door Opener:**
90- Open/Close: `node scripts/switchbot_cli.js cmd <deviceId> turnOn` / `turnOff`
91
92**Video Doorbell:**
93- Motion detection: `node scripts/switchbot_cli.js cmd <deviceId> enableMotionDetection` / `disableMotionDetection`
94
95**Candle Warmer Lamp:**
96- Brightness: `node scripts/switchbot_cli.js cmd <deviceId> setBrightness --param=50`
97
98**AI Art Frame:**
99- Next/Previous: `node scripts/switchbot_cli.js cmd <deviceId> next` / `previous`
100
101**Keypad / Keypad Touch / Keypad Vision / Keypad Vision Pro:**
102- Create passcode: `node scripts/switchbot_cli.js cmd <deviceId> createKey --param='{"name":"Guest","type":"permanent","password":"12345678"}'`
103- Delete passcode: `node scripts/switchbot_cli.js cmd <deviceId> deleteKey --param='{"id":"11"}'`
104- ⚠️ Keypad commands are async — results come via webhook.
105
106**IR Remote - Air Conditioner:**
107- Set all: `node scripts/switchbot_cli.js cmd <deviceId> setAll --param="26,2,1,on"`
108 (format: temperature, mode, fan speed, power state)
109 - mode: 0/1=auto, 2=cool, 3=dry, 4=fan, 5=heat
110 - fan: 1=auto, 2=low, 3=medium, 4=high
111 - power: on/off
112
113**IR Remote - TV:**
114- Channel: `node scripts/switchbot_cli.js cmd <deviceId> SetChannel --param=5`
115- Volume: `node scripts/switchbot_cli.js cmd <deviceId> volumeAdd` / `volumeSub`
116
117**IR Remote - Others (DIY):**
118- Custom button: `node scripts/switchbot_cli.js cmd <deviceId> <buttonName> --commandType=customize`
119
120**Scenes (fallback):**
121- List scenes: `node scripts/switchbot_cli.js scenes`
122- Execute scene: `node scripts/switchbot_cli.js scene <sceneId>`
123
124## API Reference
125
126Base URL: `https://api.switch-bot.com`
127Path prefix: `/v1.1`
128Daily limit: 10,000 API calls
129
130Headers (all required):
131- Authorization: `<SWITCHBOT_TOKEN>`
132- sign: HMAC-SHA256(`token + t + nonce`, secret), Base64-encoded
133- t: 13-digit millisecond timestamp
134- nonce: random UUID
135
136Key endpoints:
137- `GET /v1.1/devices` — list all devices
138- `GET /v1.1/devices/{deviceId}/status` — device status
139- `POST /v1.1/devices/{deviceId}/commands` — send command
140- `GET /v1.1/scenes` — list scenes
141- `POST /v1.1/scenes/{sceneId}/execute` — execute scene
142
143Command body format:
144```json
145{
146 "command": "<commandName>",
147 "parameter": "<string|object>",
148 "commandType": "command"
149}
150```
151For IR "Others" (DIY) devices, use `"commandType": "customize"`.
152
153## Agent Guidelines
154
155- Always use the provided CLI scripts — they handle HMAC signatures automatically.
156- The CLI runs preflight checks for BLE devices (Bot, Lock, Curtain, Blind Tilt) — requires Hub + Cloud Services enabled.
157- For IR Air Conditioner, only `setAll` is supported (not separate setMode/setTemp).
158- For Keypad commands (createKey/deleteKey), results are async via webhook.
159- If a command returns statusCode 160, the device may not support that command — use Scenes as fallback.
160- Never log tokens/secrets. Ask user to set them as environment variables.
161
162## Files
163
164- `scripts/switchbot_cli.js` — Node CLI (list/status/cmd/scenes)
165- `scripts/list_devices.sh` — curl: list devices
166- `scripts/get_status.sh` — curl: get status
167- `scripts/send_command.sh` — curl: send command
168- `scripts/list_scenes.sh` — curl: list scenes
169- `scripts/execute_scene.sh` — curl: execute scene
170- `references/commands.md` — complete command reference per device type
171- `references/examples.md` — usage examples