[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-2932":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":12,"subscribersCount":12,"size":12,"stars1d":14,"stars7d":14,"stars30d":15,"stars90d":12,"forks30d":12,"starsTrendScore":16,"compositeScore":12,"rankGlobal":9,"rankLanguage":9,"license":17,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":18,"hasPages":18,"topics":20,"createdAt":9,"pushedAt":9,"updatedAt":21,"readmeContent":22,"aiSummary":23,"trendingCount":12,"starSnapshotCount":12,"syncStatus":24,"lastSyncTime":25,"discoverSource":26},2932,"switchbot-openapi-cli","OpenWonderLabs\u002Fswitchbot-openapi-cli","OpenWonderLabs","Command-line interface for the SwitchBot API v1.1",null,"TypeScript",120,0,105,1,13,3,"MIT License",false,"main",[],"2026-06-12 02:00:45","# @switchbot\u002Fopenapi-cli\n\n[![npm version](https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fv\u002F@switchbot\u002Fopenapi-cli.svg)](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@switchbot\u002Fopenapi-cli)\n[![npm downloads](https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fdm\u002F@switchbot\u002Fopenapi-cli.svg)](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@switchbot\u002Fopenapi-cli)\n[![license](https:\u002F\u002Fimg.shields.io\u002Fnpm\u002Fl\u002F@switchbot\u002Fopenapi-cli.svg)](.\u002FLICENSE)\n[![node](https:\u002F\u002Fimg.shields.io\u002Fnode\u002Fv\u002F@switchbot\u002Fopenapi-cli.svg)](https:\u002F\u002Fnodejs.org)\n[![CI](https:\u002F\u002Fgithub.com\u002FOpenWonderLabs\u002Fswitchbot-openapi-cli\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg)](https:\u002F\u002Fgithub.com\u002FOpenWonderLabs\u002Fswitchbot-openapi-cli\u002Factions\u002Fworkflows\u002Fci.yml)\n\nSwitchBot smart home CLI — control devices, run scenes, stream events, and plug AI agents into your home via the built-in MCP server.\n\n- **npm:** [`@switchbot\u002Fopenapi-cli`](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@switchbot\u002Fopenapi-cli)\n- **Source \u002F issues:** [github.com\u002FOpenWonderLabs\u002Fswitchbot-openapi-cli](https:\u002F\u002Fgithub.com\u002FOpenWonderLabs\u002Fswitchbot-openapi-cli)\n- **Releases \u002F changelog:** [GitHub Releases](https:\u002F\u002Fgithub.com\u002FOpenWonderLabs\u002Fswitchbot-openapi-cli\u002Freleases)\n\n---\n\n**Human** — start with [Quick start](#quick-start): colored tables, error hints, shell completion, `switchbot doctor`.  \n**Script** — start with [Global options](#global-options): `--json`, `--format tsv\u002Fyaml\u002Fid`, `--fields`, stable exit codes, audit log.  \n**Agent** — start with [`docs\u002Fagent-guide.md`](.\u002Fdocs\u002Fagent-guide.md): `mcp serve`, `schema export`, `plan run`, destructive-command guards.\n\nEvery surface shares the same catalog, cache, and HMAC client.\n\n---\n\n## Installation\n\n```bash\nnpm install -g @switchbot\u002Fopenapi-cli\n```\n\nRequires Node.js ≥ 18. Run `switchbot auth login` to authenticate via browser — no Developer Options needed.\n\nTo use API token\u002Fsecret directly instead, first obtain your credentials from the SwitchBot app:\n\n1. Open the SwitchBot app → tap your profile avatar (top-right)\n2. Go to **Preferences** → **App Version**, tap the version number 10 times to unlock Developer Options\n3. Return to **Preferences** → **Developer Options**\n4. Copy your **Token** and **Secret Key**\n\nThen run:\n\n```bash\nswitchbot config set-token \u003Ctoken> \u003Csecret>\n```\n\n---\n\n## Supported devices\n\nRun `switchbot catalog list` to see the full list including aliases and per-command details.\n\n| Category | Devices |\n|---|---|\n| **Lighting** | Color Bulb · Strip Light · Strip Light 3 · RGBICWW Strip Light · Floor Lamp · RGBICWW Floor Lamp · Ceiling Light · Ceiling Light Pro · RGBIC Neon Rope Light · RGBIC Neon Wire Rope Light · Candle Warmer Lamp |\n| **Climate** | Humidifier · Humidifier2 · Air Purifier VOC · Air Purifier Table VOC · Air Purifier PM2.5 · Air Purifier Table PM2.5 · Smart Radiator Thermostat |\n| **Security** | Smart Lock · Smart Lock Pro · Smart Lock Pro Wifi · Smart Lock Ultra · Lock Lite · Lock Vision · Lock Vision Pro · Keypad · Keypad Touch · Keypad Vision · Keypad Vision Pro · Garage Door Opener · Video Doorbell |\n| **Curtains & blinds** | Curtain · Curtain3 · Blind Tilt · Roller Shade |\n| **Power** | Plug · Plug Mini (US) · Plug Mini (JP) · Plug Mini (EU) · Relay Switch 1 · Relay Switch 1PM · Relay Switch 2PM |\n| **Fans** | Battery Circulator Fan · Circulator Fan · Standing Circulator Fan |\n| **Cleaning** | Robot Vacuum Cleaner S1 · Robot Vacuum Cleaner S1 Plus · K10+ · K10+ Pro · Robot Vacuum Cleaner K10+ Pro Combo · Robot Vacuum Cleaner S10 · Robot Vacuum Cleaner S20 · Robot Vacuum Cleaner K11+ · Robot Vacuum Cleaner K20 Plus Pro |\n| **Sensors** _(read-only)_ | Meter · MeterPlus · WoIOSensor · MeterPro · MeterPro(CO2) · WeatherStation · Motion Sensor · Presence Sensor · Contact Sensor · Water Detector · Wallet Finder Card |\n| **Hubs** _(read-only)_ | Hub · Hub Plus · Hub Mini · Hub 2 · Hub 3 · AI Hub |\n| **Cameras** _(status only)_ | Indoor Cam · Pan\u002FTilt Cam · Pan\u002FTilt Cam 2K · Pan\u002FTilt Cam Plus 2K · Pan\u002FTilt Cam Plus 3K · Outdoor Spotlight Cam |\n| **Other** | Bot · AI Art Frame · Home Climate Panel · Remote |\n| **IR virtual remotes** _(via Hub)_ | Air Conditioner · TV · Streamer · Set Top Box · DVD · Speaker · Fan · Light · Others |\n\n---\n\n## Quick start\n\n```bash\nswitchbot auth login                        # browser OAuth — saves to OS keychain\nswitchbot config set-token \u003Ctoken> \u003Csecret> # or set credentials manually\nswitchbot devices list                      # list all devices\nswitchbot devices command \u003Cid> turnOn\nswitchbot doctor                            # self-check\n```\n\n---\n\n## Codex integration\n\nThe Codex plugin is published to npm as [`@switchbot\u002Fcodex-plugin`](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@switchbot\u002Fcodex-plugin).\n\n**Recommended — paste into Codex chat:**\n\n```\nPlease set up the SwitchBot integration for me by running:\nnpx @switchbot\u002Fopenapi-cli codex setup\nThen restart Codex and confirm it's working.\n```\n\n`codex setup` installs or upgrades the CLI and plugin packages, registers the plugin with Codex, and opens a browser login page to save credentials to the OS keychain — no token copy-paste needed.\n\n**Or install directly:**\n\n```bash\nnpm install -g @switchbot\u002Fopenapi-cli @switchbot\u002Fcodex-plugin\nswitchbot codex setup           # one-shot bootstrap: register, auth, verify\n```\n\n**Or install via Codex Plugin Marketplace** (requires Codex CLI with marketplace support):\n\n```bash\ncodex plugin marketplace add OpenWonderLabs\u002Fswitchbot-openapi-cli\ncodex plugin add switchbot@switchbot\nswitchbot auth login\n```\n\n---\n\n## OpenClaw integration\n\nThe OpenClaw skill is published to npm as [`@switchbot\u002Fopenclaw-skill`](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@switchbot\u002Fopenclaw-skill).\n\n```bash\nnpm install -g @switchbot\u002Fopenapi-cli               # required CLI\nopenclaw plugins install @switchbot\u002Fopenclaw-skill  # via OpenClaw plugin manager (recommended)\n# or\nnpm install -g @switchbot\u002Fopenclaw-skill            # via npm\n\nswitchbot-openclaw setup   # verify CLI install and credentials\nswitchbot auth login       # browser OAuth — saves to OS keychain\n```\n\n`switchbot-openclaw setup` verifies `@switchbot\u002Fopenapi-cli` is installed at `>=3.7.1` and authenticated. Safe to re-run.\n\n---\n\n## Claude Code integration\n\n**Already configured? Paste into Claude Code chat:**\n\n```\nIs my SwitchBot integration working? Please check and list my devices.\n```\n\nClaude will call `account_overview` or `switchbot doctor` to verify — no terminal needed.\n\n**Fresh setup — paste into Claude Code chat:**\n\n```\nPlease set up my SwitchBot integration by running:\nnpx @switchbot\u002Fopenapi-cli claude-code setup\n```\n\nClaude will run the setup command via the Bash tool. It installs the CLI if missing, registers the MCP server via `claude mcp add --scope user`, and opens a browser login if credentials are not yet configured. Restart Claude Code afterwards to load the MCP tools.\n\n**Or run manually in your terminal:**\n\n```bash\nnpm install -g @switchbot\u002Fopenapi-cli\nswitchbot claude-code setup\n```\n\nThe optional skill package [`@switchbot\u002Fclaude-code-plugin`](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@switchbot\u002Fclaude-code-plugin) bundles the SKILL.md context document. Install it only if your environment does not already load the skill automatically.\n\n**Or install via Claude Code Plugin Marketplace** (requires Claude Code with plugin marketplace support enabled):\n\n```\n\u002Fplugin marketplace add OpenWonderLabs\u002Fswitchbot-openapi-cli\n\u002Fplugin install switchbot@switchbot\n```\n\n**Note:** The root `marketplace.json` in this repo is for Codex CLI Route B (git sparse clone) and points to `packages\u002Fcodex-plugin\u002Fplugins\u002Fswitchbot`. The `.claude-plugin\u002Fmarketplace.json` is for Claude Code Plugin Marketplace and points to `packages\u002Fclaude-code-plugin\u002Fplugins\u002Fswitchbot`.\n\n---\n\n## Credentials\n\n> **Recommended:** use `switchbot auth login` for browser-based OAuth — credentials are stored securely in the OS keychain and never need to be copy-pasted anywhere.\n\nPriority: env vars → OS keychain → `~\u002F.switchbot\u002Fconfig.json`\n\n```bash\nswitchbot auth login                             # browser OAuth — opens login page, saves to OS keychain\nswitchbot config set-token \u003Ctoken> \u003Csecret>     # manual setup (alternative)\nexport SWITCHBOT_TOKEN=... SWITCHBOT_SECRET=... # CI \u002F env override\nswitchbot auth keychain set\u002Fget\u002Fdelete          # OS keychain management\n```\n\n---\n\n## Commands\n\n### `devices`\n\n```bash\nswitchbot devices list [--wide] [--filter 'type=Bot'] [--json]\nswitchbot devices status \u003Cid> [--ids A,B,C]\nswitchbot devices command \u003Cid> \u003Ccmd> [parameter]\nswitchbot devices expand \u003Cid> setAll --temp 26 --mode cool  # named flags for packed params\nswitchbot devices watch \u003Cid> [--interval 10s] [--for 5m]\nswitchbot devices batch turnOff --filter 'type=Bot'\nswitchbot devices meta set \u003Cid> --alias \"Office Light\"\n```\n\n### `scenes`\n\n```bash\nswitchbot scenes list\nswitchbot scenes execute \u003CsceneId>\n```\n\n### `codex`\n\n```bash\nswitchbot codex setup [--yes] [--dry-run] [--json]   # full bootstrap\nswitchbot codex doctor [--quiet] [--json]             # 7-check health summary\nswitchbot codex repair [--skip re-auth] [--yes]       # re-register + re-verify\n```\n\n### `auth`\n\n```bash\nswitchbot auth login [--no-open] [--timeout 60]\nswitchbot auth keychain describe\u002Fset\u002Fget\u002Fmigrate\u002Fdelete\n```\n\n### `config`\n\n```bash\nswitchbot config set-token \u003Ctoken> \u003Csecret>\nswitchbot config show\nswitchbot config list-profiles\n```\n\n### `mcp`\n\n```bash\nswitchbot mcp serve    # stdio MCP server — 24 tools\n```\n\n### `webhook`\n\n```bash\nswitchbot webhook setup \u003Curl>\nswitchbot webhook query [--details \u003Curl>]\nswitchbot webhook update \u003Curl> --enable\u002F--disable\nswitchbot webhook delete \u003Curl>\n```\n\n### `events`\n\n```bash\nswitchbot events tail [--filter deviceId=X] [--port 8080]\nswitchbot events mqtt-tail [--max 10] [--for 30s] [--json]\n```\n\n### `status-sync`\n\n```bash\nswitchbot status-sync start --openclaw-model home-agent\nswitchbot status-sync status --json\nswitchbot status-sync stop\n```\n\n### `rules` \u002F `daemon`\n\nPolicy-driven automations. Triggers: `mqtt` · `cron` · `webhook`. Conditions: `time_between` · `device_state` · `event_count` · `llm`. Actions: `command` · `notify`.\n\n```bash\nswitchbot rules lint\nswitchbot rules list\u002Fexplain\u002Frun\u002Fsimulate\nswitchbot rules tail\u002Freplay\u002Fsummary\u002Fconflicts\u002Fdoctor\nswitchbot rules suggest --intent \"turn off AC at 11pm\" [--llm auto]\nswitchbot daemon start\u002Fstop\u002Freload\u002Fstatus\n```\n\n### `plan`\n\nDeclarative batch operations. A plan file has `version`, `description`, and a `steps` array.\n\n```bash\nswitchbot plan schema\u002Fsuggest\u002Fvalidate\nswitchbot plan run plan.json [--dry-run] [--require-approval]\nswitchbot plan save\u002Freview\u002Fapprove\u002Fexecute\n```\n\n### `policy`\n\n```bash\nswitchbot policy new\u002Fvalidate\u002Fmigrate\u002Fbackup\u002Frestore\n```\n\n### `doctor` \u002F `health`\n\n```bash\nswitchbot doctor [--json] [--fix --yes]\nswitchbot health check [--json] [--prometheus]\nswitchbot health serve [--port 3100]\n```\n\n### Other\n\n```bash\nswitchbot history show [--limit 20]\nswitchbot quota status\u002Freset\nswitchbot upgrade-check [--json]\nswitchbot catalog show\u002Fsearch\nswitchbot schema export [--type 'Strip Light']\nswitchbot capabilities --json\nswitchbot cache show\u002Fclear\nswitchbot reset [--yes] [--keep-credentials]\nswitchbot completion bash\u002Fzsh\u002Ffish\u002Fpowershell\n```\n\n---\n\n## Global options\n\n| Flag | Description |\n|---|---|\n| `--json` | Raw JSON output |\n| `--format \u003Cfmt>` | `tsv` \u002F `yaml` \u002F `jsonl` \u002F `id` |\n| `--fields \u003Ccols>` | Comma-separated column filter |\n| `--dry-run` | Preview mutating requests without sending |\n| `--verbose` | Log HTTP request\u002Fresponse to stderr |\n| `--timeout \u003Cms>` | HTTP timeout (default `30000`) |\n| `--config \u003Cpath>` | Override credential file location |\n| `--profile \u003Cname>` | Named credential profile |\n| `--cache \u003Cdur>` | Cache TTL (`5m`, `1h`, `off`, `auto`) |\n| `--no-cache` | Disable all cache reads |\n| `--retry-on-429 \u003Cn>` | Max 429 retry attempts (default `3`) |\n| `--audit-log` | Append mutating commands to audit log |\n\n---\n\n## Exit codes\n\n| Code | Meaning |\n|---|---|\n| `0` | Success |\n| `1` | Runtime error (API \u002F network \u002F credentials) |\n| `2` | Usage error (bad flag \u002F unknown command \u002F validation) |\n\n---\n\n## Environment variables\n\n| Variable | Description |\n|---|---|\n| `SWITCHBOT_TOKEN` | API token (overrides config file) |\n| `SWITCHBOT_SECRET` | API secret (overrides config file) |\n| `NO_COLOR` | Disable ANSI colors |\n| `CODEX_GIT_MARKETPLACE_REF` | Git ref used when registering the Codex plugin via the git marketplace (default: `main`) |\n\n---\n\n## Development\n\n```bash\nnpm install && npm run build\nnpm run dev -- \u003Cargs>   # run from TypeScript via tsx\nnpm test                # Vitest suite\n```\n\n## License\n\n[MIT](.\u002FLICENSE) © chenliuyun\n\n---\n\n- [SwitchBot API v1.1](https:\u002F\u002Fgithub.com\u002FOpenWonderLabs\u002FSwitchBotAPI) · Base URL: `https:\u002F\u002Fapi.switch-bot.com` · Rate limit: 10,000 req\u002Fday\n","@switchbot\u002Fopenapi-cli 是一个用于控制 SwitchBot 智能家居设备的命令行工具。它支持通过 API v1.1 控制各种设备、运行场景、流式传输事件，并且内置了一个 MCP 服务器，可以将 AI 代理接入智能家居系统中。该工具使用 TypeScript 编写，具备丰富的功能如设备管理、场景设置和事件监听等，同时提供了友好的用户界面与强大的脚本支持选项。适用于需要自动化或远程控制智能家居设备的个人用户及开发者，特别适合那些希望通过编程方式管理和交互智能家居环境的人士。",2,"2026-06-11 02:51:47","CREATED_QUERY"]