@switchbot/openapi-cli 3.6.1 → 3.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -7
- package/dist/index.js +50356 -37286
- package/dist/policy/schema/v0.2.json +33 -1
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ Under the hood every surface shares the same catalog, cache, and HMAC client —
|
|
|
45
45
|
|
|
46
46
|
## Table of contents
|
|
47
47
|
|
|
48
|
-
- [Features](#features) · [Requirements](#requirements) · [Installation](#installation)
|
|
48
|
+
- [Features](#features) · [Supported devices](#supported-devices) · [Requirements](#requirements) · [Installation](#installation)
|
|
49
49
|
- [Quick start](#quick-start)
|
|
50
50
|
- [Credentials](#credentials)
|
|
51
51
|
- [Policy](#policy) · [Rules engine](#rules-engine)
|
|
@@ -63,9 +63,29 @@ Under the hood every surface shares the same catalog, cache, and HMAC client —
|
|
|
63
63
|
- 🎨 **Dual output modes** — colorized tables by default; `--json` passthrough for `jq` and scripting
|
|
64
64
|
- 🔐 **Secure credentials** — HMAC-SHA256 signed requests; config file written with `0600`; env-var override for CI
|
|
65
65
|
- 🔍 **Dry-run mode** — preview every mutating request before it hits the API
|
|
66
|
-
- 🧪 **Fully tested** —
|
|
66
|
+
- 🧪 **Fully tested** — 2500+ Vitest tests, mocked axios, zero network in CI
|
|
67
67
|
- ⚡ **Shell completion** — Bash / Zsh / Fish / PowerShell
|
|
68
68
|
|
|
69
|
+
## Supported devices
|
|
70
|
+
|
|
71
|
+
The built-in catalog covers every device type in the [SwitchBot Cloud API v1.1](https://github.com/OpenWonderLabs/SwitchBotAPI).
|
|
72
|
+
Run `switchbot catalog list` to see the full list including aliases and per-command details.
|
|
73
|
+
|
|
74
|
+
| Category | Devices |
|
|
75
|
+
|---|---|
|
|
76
|
+
| **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 |
|
|
77
|
+
| **Climate** | Humidifier · Humidifier2 · Air Purifier VOC · Air Purifier Table VOC · Air Purifier PM2.5 · Air Purifier Table PM2.5 · Smart Radiator Thermostat |
|
|
78
|
+
| **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 |
|
|
79
|
+
| **Curtains & blinds** | Curtain · Curtain3 · Blind Tilt · Roller Shade |
|
|
80
|
+
| **Power** | Plug · Plug Mini (US) · Plug Mini (JP) · Plug Mini (EU) · Relay Switch 1 · Relay Switch 1PM · Relay Switch 2PM |
|
|
81
|
+
| **Fans** | Battery Circulator Fan · Circulator Fan · Standing Circulator Fan |
|
|
82
|
+
| **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 |
|
|
83
|
+
| **Sensors** _(read-only)_ | Meter · MeterPlus · WoIOSensor · MeterPro · MeterPro(CO2) · WeatherStation · Motion Sensor · Presence Sensor · Contact Sensor · Water Detector · Wallet Finder Card |
|
|
84
|
+
| **Hubs** _(read-only)_ | Hub · Hub Plus · Hub Mini · Hub 2 · Hub 3 · AI Hub |
|
|
85
|
+
| **Cameras** _(status only)_ | Indoor Cam · Pan/Tilt Cam · Pan/Tilt Cam 2K · Pan/Tilt Cam Plus 2K · Pan/Tilt Cam Plus 3K · Outdoor Spotlight Cam |
|
|
86
|
+
| **Other** | Bot · AI Art Frame · Home Climate Panel · Remote |
|
|
87
|
+
| **IR virtual remotes** _(via Hub)_ | Air Conditioner · TV · Streamer · Set Top Box · DVD · Speaker · Fan · Light · Others |
|
|
88
|
+
|
|
69
89
|
## Requirements
|
|
70
90
|
|
|
71
91
|
- **Node.js ≥ 18**
|
|
@@ -244,7 +264,8 @@ With a policy.yaml (v0.2) you can declare automations that the CLI
|
|
|
244
264
|
executes for you. Supported triggers: **MQTT** (device events),
|
|
245
265
|
**cron** (schedule-driven), and **webhook** (local HTTP POST).
|
|
246
266
|
Supported conditions: `time_between` (quiet hours), `device_state`
|
|
247
|
-
(live API check with per-tick dedup),
|
|
267
|
+
(live API check with per-tick dedup), `event_count` (rolling-window
|
|
268
|
+
counts over per-device history), and `llm` (AI decision — see
|
|
248
269
|
below). Every fire is recorded in `~/.switchbot/audit.log`. `rules run` is long-running; use
|
|
249
270
|
`daemon start` / `daemon reload` for the managed background mode.
|
|
250
271
|
|
|
@@ -272,14 +293,22 @@ then:
|
|
|
272
293
|
conditions:
|
|
273
294
|
- llm:
|
|
274
295
|
prompt: "Is the temperature above normal comfort range?"
|
|
275
|
-
provider: auto # auto | openai | anthropic
|
|
296
|
+
provider: auto # auto | openai | anthropic | local
|
|
276
297
|
cache_ttl: 5m
|
|
277
298
|
budget:
|
|
278
299
|
max_calls_per_hour: 20
|
|
300
|
+
max_tokens_per_hour: 100000 # optional rolling 1h token cap
|
|
301
|
+
max_cost_per_day_usd: 1.00 # optional rolling 24h USD cap
|
|
279
302
|
on_error: pass # fail | pass | skip
|
|
280
303
|
```
|
|
281
304
|
|
|
282
|
-
Set `OPENAI_API_KEY` or `ANTHROPIC_API_KEY
|
|
305
|
+
Set `OPENAI_API_KEY` or `ANTHROPIC_API_KEY` for the cloud providers.
|
|
306
|
+
For `provider: local`, point `SWITCHBOT_LOCAL_LLM_URL` at any
|
|
307
|
+
OpenAI-compatible `/v1/chat/completions` endpoint (Ollama, llama.cpp,
|
|
308
|
+
vLLM, LM Studio); `SWITCHBOT_LOCAL_LLM_MODEL` picks the model and
|
|
309
|
+
`SWITCHBOT_LOCAL_LLM_TOOL_USE=1` opts into native tool-use when the
|
|
310
|
+
endpoint supports it (otherwise a structured-output fallback is used).
|
|
311
|
+
`rules lint` flags misconfigured LLM conditions.
|
|
283
312
|
|
|
284
313
|
**Decision trace** — set `automation.audit.evaluate_trace: sampled` (or `full`) in `policy.yaml` to record every evaluation decision.
|
|
285
314
|
|
|
@@ -633,7 +662,7 @@ switchbot doctor
|
|
|
633
662
|
switchbot doctor --json
|
|
634
663
|
```
|
|
635
664
|
|
|
636
|
-
Runs local checks (Node version, credentials, profiles, catalog, catalog-schema, catalog-coverage, cache, quota, clock, MQTT, policy, MCP, keychain, path, inventory, audit, daemon, health, notify-connectivity, release-notes) and exits 1 if any check fails. `warn` results exit 0. The MQTT check reports `ok` when REST credentials are configured (auto-provisioned on first use). The `notify-connectivity` check probes webhook URLs declared in `type: notify` actions. Use this to diagnose connectivity or config issues before running automation.
|
|
665
|
+
Runs local checks (Node version, credentials, profiles, catalog, catalog-schema, catalog-coverage, cache, quota, clock, MQTT, policy, MCP, keychain, path, inventory, audit, daemon, daemon-ipc, health, notify-connectivity, local-llm-reachable, release-notes) and exits 1 if any check fails. `warn` results exit 0. The MQTT check reports `ok` when REST credentials are configured (auto-provisioned on first use). The `notify-connectivity` check probes webhook URLs declared in `type: notify` actions. `daemon-ipc` round-trips the JSON-RPC socket when the daemon is running (silently skipped otherwise); `local-llm-reachable` only fires when policy uses `provider: local`. Use this to diagnose connectivity or config issues before running automation.
|
|
637
666
|
|
|
638
667
|
`--json` output includes `maturityScore` (0–100) and `maturityLabel` (`production-ready` / `mostly-ready` / `needs-work` / `not-ready`) to give an at-a-glance readiness rating:
|
|
639
668
|
|
|
@@ -807,7 +836,7 @@ npm install
|
|
|
807
836
|
|
|
808
837
|
npm run dev -- <args> # Run from TypeScript sources via tsx
|
|
809
838
|
npm run build # Compile to dist/
|
|
810
|
-
npm test # Run the Vitest suite
|
|
839
|
+
npm test # Run the Vitest suite
|
|
811
840
|
npm run test:watch # Watch mode
|
|
812
841
|
npm run test:coverage # Coverage report (v8, HTML + text)
|
|
813
842
|
```
|