Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ All notable changes to `@switchbot/openapi-cli` are documented in this file.
The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [3.11.0]

### Added

Expand All @@ -26,7 +26,7 @@ This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- CLI and MCP distinguish repeat safety from request-key deduplication. Unclear intent no longer generates a write; scoped replay and IR checks use the verified target. Legacy Luma overrides apply to Frame 2; DVD/Speaker discovery identifies undocumented DVD volume support.
- Compact bootstrap no longer dumps the catalog on a cold cache. Single-model schemas narrow webhook results; help examples and byte budgets are exercised on cold and populated fixtures.

See the [pinned protocol notes](./docs/openapi-alignment-ambiguities.md). No new REST endpoint, CLI command, MCP tool or release version.
See the [pinned protocol notes](./docs/openapi-alignment-ambiguities.md). No new REST endpoint, CLI command or MCP tool.

## [3.10.0]

Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![license](https://img.shields.io/npm/l/@switchbot/openapi-cli.svg)](./LICENSE)
[![node](https://img.shields.io/node/v/@switchbot/openapi-cli.svg)](https://nodejs.org)
[![CI](https://github.com/OpenWonderLabs/switchbot-openapi-cli/actions/workflows/ci.yml/badge.svg)](https://github.com/OpenWonderLabs/switchbot-openapi-cli/actions/workflows/ci.yml)
[![Fully tested: 3300 tests](https://img.shields.io/badge/tests-3300-blue)](#development)

SwitchBot smart home CLI — control devices, run scenes, stream events, and plug AI agents into your home via the built-in MCP server.

Expand Down Expand Up @@ -66,7 +67,7 @@ Run `switchbot catalog show` for the effective catalog, including aliases and pe

### Device contract notes

**Unreleased OpenAPI update** (after CLI 3.10.0):
**OpenAPI changes in CLI 3.11.0:**

- **Plug Mini (IT) and Outdoor Plug (EU):** `switchbot --json devices status <plugId>` reports `power` in watts and `usedElectricity` in watt-minutes for the day. Read `switchStatus` (0 off, 1 on) for the relay state. The two models have distinct webhook identities; their events do not report energy readings.
- **Hub 4 and Vision Doorbell:** use `switchbot --json devices status <id>` rather than sending a command. Hub 4 reports motion and environmental readings and has webhook events. Vision Doorbell reports `version`, `battery`, and `online`; no webhook is documented. Unlike Video Doorbell, it has no motion-detection controls. Its inventory entry may include `lockDeviceId` (a linked lock ID or `null`).
Expand Down Expand Up @@ -377,7 +378,7 @@ switchbot config list-profiles
switchbot mcp serve # stdio — default 18 tools; readonly 15; --tools all 29
```

Read endpoints added in CLI 3.9.0: `mindclip transcript <id>` and `devices diary <id> --start <unix-ms> --end <unix-ms>`. Both have readonly MCP equivalents; diary windows are limited to 31 days and embedded detail strings remain raw.
Read endpoints added in CLI 3.9.0: `mindclip transcript <id>` and `devices diary <id> --start <unix-ms> --end <unix-ms>`. Both are available in the readonly MCP profile; diary windows are limited to 31 days and embedded detail strings remain raw.

### `webhook`

Expand Down Expand Up @@ -470,7 +471,7 @@ switchbot completion bash/zsh/fish/powershell
| Flag | Description |
| --- | --- |
| `--json` | Raw JSON output |
| `--format <fmt>` | `tsv` / `yaml` / `jsonl` / `id` |
| `--format <fmt>` | `table` (default), `json`, `jsonl`, `tsv`, `yaml`, `id`, or `markdown` |
| `--fields <cols>` | Comma-separated column filter |
| `--dry-run` | Preview supported actions without applying changes; unsupported writes fail. Reads may consume quota. Use `rules simulate` for offline rule decisions. |
| `--verbose` | Log HTTP request/response to stderr |
Expand Down
9 changes: 6 additions & 3 deletions docs/agent-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ If you're a human looking for a tour, start with the [top-level README](../READM
> its Skill + MCP architecture and existing startup contract.
> The documented CLI/MCP surfaces are the shared contract. Check offline
> catalog/bootstrap compatibility with
> `switchbot doctor --json | jq '.data.checks[] | select(.name=="catalog-schema")'`.
> `switchbot doctor --section catalog-schema --json`.

---

Expand Down Expand Up @@ -74,7 +74,7 @@ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)

### Available tools (29, including 3 deprecated aliases)

The default profile exposes 18 tools; `--tools readonly` exposes 15. Policy, audit and rule-administration tools require `--tools all`. Installations keep the safe default rather than enabling all tools merely for onboarding.
`switchbot mcp serve` exposes 18 tools by default; `--tools readonly` exposes 15. Policy, audit and rule-administration tools require `--tools all`. To inspect a profile without starting the server, run `switchbot mcp tools --tools default --json` (or substitute `readonly` or `all`). Unlike `serve`, `mcp tools` lists all 29 when no profile is specified.

| Tool | Purpose | Safety tier |
| --- | --- | --- |
Expand All @@ -88,6 +88,9 @@ The default profile exposes 18 tools; `--tools readonly` exposes 15. Policy, aud
| `describe_device` | Catalog-derived capabilities + optional live status | read |
| `account_overview` | Cold-start snapshot (devices/scenes/quota/cache/MQTT) | read |
| `device_history` | Read locally-persisted history. mode: "raw" (latest + ring) / "query" (time-range JSONL) / "aggregate" (bucketed stats) | read |
| `get_device_history` | Deprecated; use `device_history` with `mode: "raw"` | read |
| `query_device_history` | Deprecated; use `device_history` with `mode: "query"` | read |
| `aggregate_device_history` | Deprecated; use `device_history` with `mode: "aggregate"` | read |
| `mindclip_recordings` | AI MindClip recordings. action: `"list"`, `"get"` metadata, `"summary"`, or `"transcript"` transcription status/result | read |
| `mindclip_list_todos` | List AI-extracted to-dos pulled from voice recordings | read |
| `mindclip_recall` | AI-curated recall views. period: `"daily"` daily recall / `"weekly"` weekly summary / `"urgent_todos"` urgent to-dos | read |
Expand Down Expand Up @@ -467,7 +470,7 @@ Each command entry carries:

### Model-specific boundaries

**Unreleased models** (after CLI 3.10.0):
**Model changes in CLI 3.11.0:**

- For **Plug Mini (IT)** and **Outdoor Plug (EU)**, use `get_device_status` for `switchStatus` (0 off, 1 on), `power` (W), `electricCurrent` (mA), `voltage` (V), and daily `usedElectricity` (W·min). Their separate `changeReport` events expose `online`, `overTemperature`, `overload`, and `switchStatus`, not metering samples.
- **Hub 4** is read-only. Use status for `moveDetected` and webhook `detectionState` for motion events. **Vision Doorbell** is also read-only (`version`, `battery`, `online`), with no documented webhook. `list_devices` may report `lockDeviceId` as a string or `null`, or omit it. It is inventory metadata, not a doorbell command target. Do not offer Video Doorbell's motion-detection controls.
Expand Down
37 changes: 21 additions & 16 deletions docs/audit-log.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Audit Log Format

The SwitchBot CLI writes a JSONL audit record for every mutating device or
scene command when either `--audit-log` is passed or a profile sets
`defaults.flags` including `--audit-log`.
Pass `--audit-log` to record device commands. A device command with a
`planId` uses the default log even without the flag. Direct scene execution
does not write a command record.

- **Default path:** `~/.switchbot/audit.log`
- **Override:** `--audit-log-path <file>`
Expand All @@ -12,7 +12,10 @@ scene command when either `--audit-log` is passed or a profile sets

## Schema

Every record is a JSON object with at least the following fields:
New records share `auditVersion`, `t`, and `kind`. The remaining fields below
describe command records; other kinds have different payloads. For example,
`rule-evaluate` has `rule`, `trigger`, `fireId`, `conditions`, `decision` and
`evaluationMs` instead of command fields.

| Field | Type | Notes |
| --- | --- | --- |
Expand All @@ -21,12 +24,16 @@ Every record is a JSON object with at least the following fields:
| `kind` | string | Record discriminator. Values: `command`, `rule-fire`, `rule-fire-dry`, `rule-throttled`, `rule-webhook-rejected`, `rule-notify`, `rule-evaluate`, `llm-suggest`, `llm-condition`, `llm-budget-exceeded`. |
| `deviceId` | string | Target device ID. |
| `command` | string | SwitchBot command name (e.g. `turnOn`, `setColor`). |
| `parameter` | string \| object | `command` records use the wire parameter. Rule-fire records retain the parameter string, including JSON whitespace; RGB values use `r:g:b`. Unused parameters are `"default"`. |
| `parameter` | JSON value | Device command parameter (for example, a string, number or object). Rule-fire records retain parsed command text, including JSON whitespace; RGB values use `r:g:b`. |
| `commandType` | `"command" \| "customize"` | Matches the upstream SwitchBot API field. |
| `dryRun` | boolean | `true` when the command was intercepted by `--dry-run` and never reached the network. |
| `result` | `"ok" \| "error"` | Optional — only present once the command completed (absent for `dryRun: true`). |
| `result` | `"ok"` \| `"error"` \| `"dry-run"` | Optional. An intercepted device command records `"dry-run"`; a successful `rule-fire-dry` records `"ok"`. |
| `error` | string | Optional — populated when `result === "error"`. |

`llm-condition` is a declared kind. Do not expect a separate record for
each LLM call: the evaluator puts condition details in `rule-evaluate`
traces and writes `llm-budget-exceeded` on budget rejection.

### Example

```json
Expand Down Expand Up @@ -54,19 +61,17 @@ Every record is a JSON object with at least the following fields:

## `history verify`

`switchbot history verify` inspects the log and reports:

- total / parsed / skipped / malformed line counts
- histogram of `auditVersion` values (`unversioned` for pre-v1 records)
- earliest / latest timestamp
- per-line problem details for anything that failed to parse
`switchbot history verify` ignores blank lines. Human output includes parsed
and malformed counts, an `auditVersion` histogram, earliest/latest timestamps
when available, and line numbers for malformed JSON. `--json` instead reports
`data.status`, `fileMissing`, `parsed`, `malformed`, `unversioned` and `message`.

Exit codes:

| Code | Meaning |
|------|----------------------------------------------------------------------------------|
| 0 | Every line parsed; no malformed entries. |
| 1 | File missing OR one or more malformed lines. |
| Code | Meaning |
| --- | --- |
| 0 | No malformed or unversioned entries (`ok`), or file missing (`warn`). |
| 1 | At least one malformed or unversioned entry (`fail`). |

## Rotation

Expand Down
4 changes: 2 additions & 2 deletions docs/json-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ query` emit one JSON envelope.
outer success or error shape changes. A command payload can have an additional
version inside `data`.

For example, schema discovery in CLI 3.10.0 is an envelope at `1.2`, an export
For example, schema discovery in CLI 3.11.0 is an envelope at `1.2`, an export
at `2.0`, and a resource catalog at `2.0`:

~~~json
Expand Down Expand Up @@ -95,7 +95,7 @@ displayed image remains and nothing was deleted. With both values `0`, the
album was empty. Do not treat zero as missing. The count is for the **cloud
album**, including images not downloaded to the frame. A successful deletion
means the cloud removed the image and sent the instruction, not that the frame
has finished. See the [pinned device evidence](openapi-alignment-ambiguities.md#2026-11-20-upstream-snapshot-unreleased).
has finished. See the [pinned device evidence](openapi-alignment-ambiguities.md#2026-11-20-upstream-snapshot).

## 2. Streaming commands

Expand Down
6 changes: 3 additions & 3 deletions docs/openapi-alignment-ambiguities.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OpenAPI alignment ambiguities

The latest entries use the [2026-11-20 upstream snapshot](#2026-11-20-upstream-snapshot-unreleased) (`0db92c78`). The earlier entries below retain their own `dc9a6b0e` evidence links. Written contracts, reported payloads and unresolved server behavior are distinguished throughout.
The latest entries use the [2026-11-20 upstream snapshot](#2026-11-20-upstream-snapshot) (`0db92c78`). The earlier entries below retain their own `dc9a6b0e` evidence links. Written contracts, reported payloads and unresolved server behavior are distinguished throughout.

- [MindClip](https://github.com/OpenWonderLabs/SwitchBotAPI/blob/dc9a6b0e4ad77882c72d186ecd5d134113acdad0/devices/others/ai-mindclip.md): the CLI, library and MCP now require the documented list/todo/date/week query fields; missing fields fail before HTTP rather than relying on an unverified server default. Extra language/time/folder/category filters, legacy numeric bounds and completed/category value meanings still require upstream confirmation; mock responses do not establish them.
- [Curtain and Blind Tilt](https://github.com/OpenWonderLabs/SwitchBotAPI/tree/dc9a6b0e4ad77882c72d186ecd5d134113acdad0/devices/curtains-blinds): scalar Curtain position, Blind Tilt/Roller Shade on/off, and fan toggle support are not tightened without pinned evidence. The documented spaced Blind Tilt form `up; 36` is accepted and normalized to `up;36`.
Expand Down Expand Up @@ -46,10 +46,10 @@ It supplements, rather than replaces, the historical evidence above.
Solar webhook `timeOfSample` is milliseconds, not the status URL expiry
unit.

## 2026-11-20 upstream snapshot (unreleased)
## 2026-11-20 upstream snapshot

[Official delta from `fa8f90c` to `0db92c7`](https://github.com/OpenWonderLabs/SwitchBotAPI/compare/fa8f90c661cfa183d633d87f18c04e0e5059fa74...0db92c78b56808f25b74c61535313f44bef4cd91).
The five additions below use existing REST operations. The evidence is the
CLI 3.11.0 supports the five additions below through existing REST operations. The evidence is the
written OpenAPI contract, not a live-device or regional availability test.

- [Plug Mini (IT)](https://github.com/OpenWonderLabs/SwitchBotAPI/blob/0db92c78b56808f25b74c61535313f44bef4cd91/devices/plugs-switches/plug-mini-it.md)
Expand Down
Loading
Loading