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
52 changes: 33 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,23 @@ jobs:
cache: npm
- run: npm ci
- run: npm run build
- name: Seed device-cache fixture
- name: Check offline discovery budgets on cold and populated caches
run: |
set -euo pipefail
export HOME="$RUNNER_TEMP/discovery-home"
mkdir -p "$HOME"
output="$RUNNER_TEMP/discovery.json"
check_budget() {
local limit=$1
shift
node dist/index.js "$@" > "$output"
local bytes
bytes=$(wc -c < "$output")
echo "$* = $bytes bytes (limit: $limit)"
test "$bytes" -lt "$limit"
}
check_budget 20000 agent-bootstrap --compact
jq -e '(.data.devices | length) == 0 and .data.catalog == {"scope":"used","types":[]}' "$output"
mkdir -p "$HOME/.switchbot"
cat > "$HOME/.switchbot/devices.json" <<'JSON'
{
Expand All @@ -165,24 +180,23 @@ jobs:
}
}
JSON
- name: agent-bootstrap --compact must stay under 20 KB
run: |
OUT=$(node dist/index.js agent-bootstrap --compact)
BYTES=$(printf '%s' "$OUT" | wc -c)
echo "agent-bootstrap --compact = $BYTES bytes"
if [ "$BYTES" -ge 20000 ]; then
echo "FAIL: budget is 20000, got $BYTES"
exit 1
fi
- name: schema export --compact --used must stay under 15 KB
run: |
OUT=$(node dist/index.js schema export --compact --used)
BYTES=$(printf '%s' "$OUT" | wc -c)
echo "schema export --compact --used = $BYTES bytes"
if [ "$BYTES" -ge 15000 ]; then
echo "FAIL: budget is 15000, got $BYTES"
exit 1
fi
check_budget 20000 agent-bootstrap --compact
# Evaluate the jq expressions advertised to users, not copies of them.
mapfile -t projections < <(node dist/index.js agent-bootstrap --help | sed -n "s/.*| jq '\\([^']*\\)'.*/\\1/p")
test "${#projections[@]}" -eq 2
test "$(jq -e "${projections[0]}" "$output")" -eq 4
jq -e "${projections[1]} | .discovery | length > 0" "$output"
check_budget 15000 schema export --compact --used
check_budget 15000 schema export --type S30
jq -e '[.data.resources.webhooks.events[].context.deviceType] == ["Robot Vacuum Cleaner S30"]' "$output"
- name: Evaluate isolated household decisions
run: node scripts/household-eval.mjs > "$RUNNER_TEMP/household-report.json"
- uses: actions/upload-artifact@v4
if: always()
with:
name: household-contract-report
path: ${{ runner.temp }}/household-report.json
if-no-files-found: ignore

pack-install-smoke:
name: Packed install smoke (${{ matrix.os }})
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Plug Mini (IT) and Outdoor Plug (EU) controls, metering status and separate webhook identities; Hub 4 read-only status and events.
- Vision Doorbell status and optional `lockDeviceId` in inventory, cache and MCP list results. This is not Video Doorbell and exposes no commands or documented webhook.
- Robot Vacuum Cleaner S30 commands, status and change-only webhook fields. Its `selfClean` takes a numeric mode (1–4); `refill` is not supported.
- Offline household decision checks with separate practice and held-out reports, forbidden-write gates and optional local-model comparison.
- MCP 2026-07-28 discovery and calls over stdio and HTTP alongside legacy initialization; the existing Node minimum, profiles and tool schemas are retained.

### Changed

- AI Art Frame 2 is the canonical name; AI Art Frame Luma remains a discovery alias. Both frame models support irreversible, non-idempotent `deleteImage` through the reviewed plan workflow. Rules, policy pre-approval and live command-history replay cannot authorize it; HTTP 429 does not trigger a retry.
- Successful plan command steps retain the cloud result, including zero-valued deletion counts. Cloud acknowledgement does not confirm the physical frame has finished.
- `devices command --explain` now reports catalog idempotency in text and JSON. An unknown `deleteImage` target points to an inventory refresh, not `--allow-unknown-device`.
- Supported dry-runs suppress cloud and local business writes; other writes refuse preview. Human review shows exact targets and redacts sensitive parameters. Approval seals the plan and account and honors extra confirmation; concurrent execution and blind retries are blocked.
- 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.

## [3.10.0]

### Added
Expand Down
34 changes: 25 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,29 @@ Run `switchbot catalog show` for the effective catalog, including aliases and pe
| --- | --- |
| **Lighting** | Color Bulb · Strip Light · Strip Light 3 · RGBICWW Strip Light · RGBICWW Light Bars · Floor Lamp · RGBICWW Floor Lamp · Ceiling Light · Ceiling Light Pro · RGBICWW Ceiling Light · RGBIC Neon Rope Light · RGBIC Neon Wire Rope Light · Candle Warmer Lamp · Permanent Outdoor Lights |
| **Climate** | Humidifier · Humidifier2 · Air Purifier VOC · Air Purifier Table VOC · Air Purifier PM2.5 · Air Purifier Table PM2.5 · Smart Radiator Thermostat |
| **Security** | Smart Lock · Smart Lock Pro · Smart Lock Pro Wifi · Smart Lock Ultra · Smart Lock Ultra Max · Lock Lite · Lock Vision · Lock Vision Pro · Keypad · Keypad Touch · Keypad Vision · Keypad Vision Pro · Garage Door Opener · Video Doorbell |
| **Security** | Smart Lock · Smart Lock Pro · Smart Lock Pro Wifi · Smart Lock Ultra · Smart Lock Ultra Max · Lock Lite · Lock Vision · Lock Vision Pro · Keypad · Keypad Touch · Keypad Vision · Keypad Vision Pro · Garage Door Opener · Video Doorbell · Vision Doorbell _(status only)_ |
| **Curtains & blinds** | Curtain · Curtain3 · Curtain 4 · Blind Tilt · Roller Shade |
| **Power** | Plug · Plug Mini (US) · Plug Mini (JP) · Plug Mini (EU) · Relay Switch 1 · Relay Switch 1PM · Relay Switch 2PM |
| **Power** | Plug · Plug Mini (US) · Plug Mini (JP) · Plug Mini (EU) · Plug Mini (IT) · Outdoor Plug (EU) · Relay Switch 1 · Relay Switch 1PM · Relay Switch 2PM |
| **Fans** | Battery Circulator Fan · Battery Circulator Fan 2 Pro · Circulator Fan · Standing Circulator Fan |
| **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 K11 Plus Pro · Robot Vacuum Cleaner K20 Plus Pro |
| **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 S30 · Robot Vacuum Cleaner K11+ · Robot Vacuum Cleaner K11 Plus Pro · Robot Vacuum Cleaner K20 Plus Pro |
| **Sensors** _(read-only)_ | Meter · MeterPlus · WoIOSensor · MeterPro · MeterPro(CO2) · WeatherStation · Motion Sensor · Presence Sensor · Contact Sensor · Water Detector · Wallet Finder Card |
| **Hubs** _(read-only)_ | Hub · Hub Plus · Hub Mini · Hub 2 · Hub 3 · AI Hub |
| **Hubs** _(read-only)_ | Hub · Hub Plus · Hub Mini · Hub 2 · Hub 3 · Hub 4 · AI Hub |
| **Cameras** | Indoor Cam · Pan/Tilt Cam · Pan/Tilt Cam 2K · Pan/Tilt Cam Plus 2K · Pan/Tilt Cam Plus 3K · Outdoor Spotlight Cam · Outdoor Pan/Tilt Cam 3K _(status only)_ · Solar Pan/Tilt Cam 2K |
| **Other** | Bot · AI Art Frame · AI Art Frame Luma · AI MindClip · Kata Friends · Home Climate Panel · Remote |
| **Other** | Bot · AI Art Frame · AI Art Frame 2 (also discoverable as AI Art Frame Luma) · AI MindClip · Kata Friends · Home Climate Panel · Remote |
| **IR virtual remotes** _(via Hub)_ | Air Conditioner · TV · Streamer · Set Top Box · DVD · Speaker · Fan · Light · Others |

### Device contract notes

The capabilities below are available starting in CLI 3.10.0.
**Unreleased OpenAPI update** (after CLI 3.10.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`).
- **Robot Vacuum Cleaner S30:** `switchbot --dry-run devices command <s30Id> selfClean 4` previews emptying the dustbin. S30 takes a number from 1 to 4 and has no `refill`; do not reuse an S10/S20 command list.
- **AI Art Frame and AI Art Frame 2:** `deleteImage` permanently deletes one eligible album image by `random`, `newest`, or `oldest`. Use a [reviewed plan](./docs/agent-guide.md#reviewing-an-art-frame-deletion); do not retry on an uncertain outcome.

See the [pinned protocol notes](./docs/openapi-alignment-ambiguities.md) for model-specific fields and limits of the evidence.

**Available since CLI 3.10.0:**

- Light Bars accept object parameters. For example: `switchbot devices command <lightBarId> setLightEffect '{"effectId":1}'`; `effectId` is an integer from 0 through 25.
- Outdoor Pan/Tilt Cam 3K is status-only. Camera status may include `latestImage` as `{ imageUrl, expireAt }`; `expireAt` is Unix seconds. Treat cached URLs as potentially expired, do not download or persist image bytes, and query again with `--no-cache` when a fresh status is needed.
Expand All @@ -85,6 +94,12 @@ switchbot devices command <id> turnOn
switchbot doctor # self-check
```

For agents, start with `switchbot agent-bootstrap --compact`. An empty cache
means the inventory is unknown; use `devices list` before choosing a target.
Use `schema export --type S30` for a single model rather than loading the
whole catalog. The [agent guide](docs/agent-guide.md#run-semantics) explains
what approval binds and when an interrupted action must not be retried.

---

## Codex integration
Expand Down Expand Up @@ -457,14 +472,14 @@ switchbot completion bash/zsh/fish/powershell
| `--json` | Raw JSON output |
| `--format <fmt>` | `tsv` / `yaml` / `jsonl` / `id` |
| `--fields <cols>` | Comma-separated column filter |
| `--dry-run` | Preview mutating requests without sending |
| `--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 |
| `--timeout <ms>` | HTTP timeout (default `30000`) |
| `--config <path>` | Override credential file location |
| `--profile <name>` | Named credential profile |
| `--cache <dur>` | Cache TTL (`5m`, `1h`, `off`, `auto`) |
| `--no-cache` | Disable all cache reads |
| `--retry-on-429 <n>` | Max 429 retry attempts (default `3`) |
| `--retry-on-429 <n>` | Max retries for a read or verified repeat-safe write (default `3`); never automatically repeat scenes, custom IR buttons or image deletion |
| `--audit-log` | Append mutating commands to audit log |
| `--audit-log-path <path>` | Custom audit path; use together with `--audit-log` |

Expand Down Expand Up @@ -496,14 +511,15 @@ Policy commands retain their documented specialized exit codes (including YAML p

## Development

Verified CLI regression suite: 3211 tests. Plugin workspace checks are separate.
Verified CLI regression suite: 3300 tests. Plugin workspace checks are separate.

```bash
npm install && npm run build
npm run dev -- <args> # run from TypeScript via tsx
npm test # Vitest suite
npm run test:account-lifecycle # focused account/cache/MCP regressions
npm run test:coverage # suite plus coverage thresholds
node scripts/household-eval.mjs > household-report.json # offline decision/authority gate, not a model score
```

CI runs CLI regressions on Node 18/20/22/24, enforces coverage on Node 24,
Expand Down
Loading
Loading