feat: MQTT CLI exposure — events mqtt-tail, doctor check, capabilities surface (v2.1.0)#10
Merged
chenliuyun merged 4 commits intomainfrom Apr 19, 2026
Merged
Conversation
added 4 commits
April 19, 2026 18:17
…bilities surface - events mqtt-tail: new subcommand that connects to the configured MQTT broker via SwitchBotMqttClient and streams shadow events as JSONL; supports --topic (default "#"), --max (stop after N events); requires SWITCHBOT_MQTT_HOST/USERNAME/PASSWORD env vars (UsageError if missing) - doctor: add 8th check 'mqtt' — warn if env vars unset, ok with host:port detail; no live connectivity test to keep doctor offline-safe - capabilities: add surfaces.mqtt object with mode, envVars, cliCmd, mcpResource, protocol, and configured (bool) — agents can now programmatically discover the MQTT surface - index.ts: extend Environment section in --help to list all 4 MQTT vars - tests: 4 new mqtt-tail tests (UsageError, JSONL output, JSON envelope, --max validation); 2 new doctor mqtt tests (warn/ok); 1 capabilities test for surfaces.mqtt shape
- mcp stdio mode: initialize EventSubscriptionManager and pass it to createSwitchBotMcpServer() so switchbot://events is registered in BOTH stdio and HTTP modes — was only available in HTTP mode before (Issue 1) - mcp help text: update "seven tools" → "eight tools", add account_overview to list, add switchbot://events resource section with MQTT env var note - events command description: replace webhook-only wording with description covering both tail (webhook) and mqtt-tail (MQTT stream) subcommands - doctor mqtt detail: explicitly state credentials are not verified and direct user to mqtt-tail for live connectivity testing (Issue 2 clarification)
…nt in both stdio and HTTP when MQTT is configured
When --max triggers ac.abort(), the abort signal path ran cleanup but left the process.once SIGINT/SIGTERM handlers dangling. After the test finishes Vitest sends SIGTERM, cleanup fired again with a torn-down mock where disconnect() returns undefined, causing an unhandled TypeError.
chenliuyun
pushed a commit
that referenced
this pull request
Apr 20, 2026
v2.4.0 release note claimed every mqtt-tail event is appended to device history, but control events (__connect, __reconnect, __disconnect, __heartbeat) have no deviceId and were only emitted to stdout. Route them into a dedicated ~/.switchbot/device-history/__control.jsonl alongside the per-device files, sharing the same 50MB rotation logic. Errors are swallowed — history writes never block the event stream. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
chenliuyun
pushed a commit
that referenced
this pull request
Apr 20, 2026
Document every fix landed in this branch beyond the history-aggregate feature: bugs #1, #4, #5, #6, #8, #9, #10, #11, #12, #13, #14, #15, #16, #17, #18 from the OpenClaw v2.4.0 smoke-test report. Call out the deferred items (#2, #7) explicitly so readers don't assume they were overlooked. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4 tasks
chenliuyun
pushed a commit
that referenced
this pull request
Apr 20, 2026
v2.4.0 release note claimed every mqtt-tail event is appended to device history, but control events (__connect, __reconnect, __disconnect, __heartbeat) have no deviceId and were only emitted to stdout. Route them into a dedicated ~/.switchbot/device-history/__control.jsonl alongside the per-device files, sharing the same 50MB rotation logic. Errors are swallowed — history writes never block the event stream.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
events mqtt-tail: new subcommand to stream live MQTT shadow events as JSONL (--topic,--max,--json)doctor: 8th check reports MQTT config status (warnif unconfigured,okwith broker URL if set)capabilities:surfaces.mqttentry exposes env vars, CLI command, MCP resource, andconfiguredflag for programmatic discoverymcp servestdio path: now initialisesEventSubscriptionManagerwhen MQTT env vars are present (matching the HTTP path), soswitchbot://eventsresource works in stdio mode--help: Environment section extended with all 4 MQTT env varsaccount_overview.mqttfield description changed from "HTTP mode only" to "present when MQTT env vars are configured"Test plan
npm test)doctor --jsonshowsmqtt: warnwithout env vars,okwithcapabilities --json→surfaces.mqtt.configured: false,surfaces.mcp.toolshas 8 entries,resources: ["switchbot://events"]events mqtt-tailexits 2 with UsageError when MQTT not configureddoctoranddevices listagainst real SwitchBot API