Skip to content

Feat/mqtt cli exposure#11

Merged
chenliuyun merged 8 commits intomainfrom
feat/mqtt-cli-exposure
Apr 19, 2026
Merged

Feat/mqtt cli exposure#11
chenliuyun merged 8 commits intomainfrom
feat/mqtt-cli-exposure

Conversation

@chenliuyun
Copy link
Copy Markdown
Collaborator

♻️ Current situation

Describe the current situation. Explain current problems, if there are any. Be as descriptive as possible (e.g., including examples or code snippets).

💡 Proposed solution

Describe the proposed solution and changes. How does it affect the project? How does it affect the internal structure (e.g., refactorings)?

⚙️ Release Notes

Provide a summary of the changes or features from a user's point of view. If there are breaking changes, provide migration guides using code examples of the affected features.

➕ Additional Information

If applicable, provide additional context in this section.

Testing

Which tests were added? Which existing tests were adapted/changed? Which situations are covered, and what edge cases are missing?

Reviewer Nudging

Where should the reviewer start? what is a good entry point?

chenliuyun added 8 commits April 19, 2026 19:22
- Add `events` entry to the table of contents
- Add `### events` section covering both `events tail` (webhook receiver)
  and `events mqtt-tail` (MQTT stream) with usage examples
- Extend the Environment variables table with all four MQTT vars
Wrong commands fixed:
- `devices explain` was described as taking <deviceId> <command> (wrong);
  corrected to one-shot device summary with --no-live flag
- `### watch` used non-existent `switchbot watch` syntax;
  corrected to `switchbot devices watch` under proper heading
- `### batch` described `plan run/validate` with wrong command names;
  replaced with correct `### plan` section

Missing command sections added: doctor, quota, history, catalog,
schema, capabilities, devices meta (devices watch moved from wrong
top-level position to its own section)

Additional fixes:
- README tagline updated to mention MCP/AI integration
- TOC updated to match actual command names
- Project layout updated: correct file labels, added expand.ts,
  device-meta.ts, capabilities.ts; removed non-existent batch.ts entry
- Test count updated: 592 → 692
- npm description improved to communicate AI/MCP value
- agent-guide.md: added events mqtt-tail to observability section
Replace manual SWITCHBOT_MQTT_HOST/USERNAME/PASSWORD env vars with
zero-config mTLS client certificates obtained from the SwitchBot
credential endpoint (POST /v1.1/iot/credential). Users need only
SWITCHBOT_TOKEN + SWITCHBOT_SECRET — no additional MQTT setup required.

- credential.ts: add fetchMqttCredential(); remove getMqttConfig()
- client.ts: switch from username/password to mTLS TLS client certs
- events-subscription.ts: initialize(token, secret) instead of mqttConfig
- doctor/capabilities: report MQTT status based on REST credentials
- Remove SWITCHBOT_MQTT_* from README env table, index.ts help text
The SwitchBot credential API returns full PEM strings in the tls.caBase64,
certBase64, and keyBase64 fields despite the misleading field names. Decoding
them as base64 produces garbage bytes that fail TLS handshake.
…down

1. Add tryLoadConfig() that returns null instead of process.exit(1), so
   mcp serve can genuinely degrade gracefully when credentials are absent.
   The try/catch around loadConfig() never caught anything because loadConfig
   calls process.exit, not throw.

2. Use tryLoadConfig() in events mqtt-tail so the UsageError path actually
   executes instead of the process exiting before the catch block runs.

3. Add a disconnecting flag to SwitchBotMqttClient so that intentional
   disconnect() calls suppress the close->attemptReconnect() chain. Without
   this, --max N, Ctrl-C and MCP shutdown all race against a reconnect loop.
   Also remove the unused stableTimer dead code.
- account_overview.mqtt description now says "auto-provisioned via REST
  credentials" instead of the outdated "MQTT env vars" wording
- Move "Connected to..." banner in mqtt-tail to after client.connect()
  resolves, so the message only appears when the connection is confirmed
- Add devices batch section and TOC entry (was completely undocumented)
- Add config list-profiles to config section
- Add catalog refresh to catalog section
- Fix doctor description: 'MQTT config' → clarify auto-provisioned from REST credentials
- Restore mcp TOC entry that was accidentally dropped in previous edit
@chenliuyun chenliuyun merged commit f4f83e2 into main Apr 19, 2026
3 checks passed
@chenliuyun chenliuyun deleted the feat/mqtt-cli-exposure branch April 19, 2026 12:47
chenliuyun pushed a commit that referenced this pull request Apr 20, 2026
)

Add fileMissing flag to VerifyReport. When audit.log does not exist (fresh install),
return fileMissing=true, exit with 0, and set status to 'warn' in JSON output.
Existing behavior preserved for malformed/unversioned content (still exits 1).

Tests: 6 new tests added to verify the behavior: fresh account, empty file,
malformed entries, and JSON output variants.

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>
chenliuyun pushed a commit that referenced this pull request Apr 20, 2026
)

Add fileMissing flag to VerifyReport. When audit.log does not exist (fresh install),
return fileMissing=true, exit with 0, and set status to 'warn' in JSON output.
Existing behavior preserved for malformed/unversioned content (still exits 1).

Tests: 6 new tests added to verify the behavior: fresh account, empty file,
malformed entries, and JSON output variants.
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant