Skip to content

feat: support multiple devices in devices:history - #848

Open
sungmpar wants to merge 1 commit into
SmartThingsCommunity:mainfrom
sungmpar:feat/devices-history-multiple-devices
Open

feat: support multiple devices in devices:history#848
sungmpar wants to merge 1 commit into
SmartThingsCommunity:mainfrom
sungmpar:feat/devices-history-multiple-devices

Conversation

@sungmpar

@sungmpar sungmpar commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Issue #643 asks for a way to query multiple devices with devices:history and export their records together. This change makes the positional device argument variadic and uses one combined history stream, avoiding separate CLI runs and manual result merging.

  • With no positional argument, the existing interactive single-device selection remains unchanged.
  • With one unique device, request parameters remain scalar and the existing common table columns are preserved.
  • With multiple devices, direct IDs and numeric indexes are resolved, numeric selections share one device-list snapshot, and resolved device IDs are deduplicated in first-seen order.
  • Metadata is fetched for every unique device, and each returned locationId is checked to be a non-empty string before history or output begins; any metadata lookup failure or missing, non-string, or empty locationId aborts before any history request, table, formatter, or output write. Multiple unique devices use ordered device IDs and first-seen deduplicated locations, with a scalar location when all devices share one.
  • Common output includes device names only for multiple devices. JSON, YAML, and --output continue to format and write one combined result.
  • Existing pagination, limit handling, before, after, UTC formatting, and warning behavior apply to the combined stream.
  • The generated command reference now shows devices:history [id-or-index..], and a patch changeset is included.
  • The locations:history test now imports its type-only CommandArgs from the command it exercises. The variadic device-history type exposed this pre-existing mismatch during compilation; the correction does not change runtime or test behavior.

Testing

  • npm run test -- --runTestsByPath src/__tests__/commands/locations/history.test.ts --no-watchman — passed, 1 suite / 4 tests
  • npm run test -- --runTestsByPath src/__tests__/commands/devices/history.test.ts --no-watchman — passed, 1 suite / 19 tests
  • npm run test -- --runTestsByPath src/__tests__/lib/command/util/history.test.ts src/__tests__/lib/command/command-util.test.ts src/__tests__/lib/command/util/util-util.test.ts src/__tests__/lib/command/util/devices-choose.test.ts src/__tests__/commands/locations/history.test.ts --no-watchman — passed, 5 suites / 91 tests
  • npm run compile — passed
  • npm run build — passed; clean, compile, and README generation completed
  • node dist/src/run.js devices:history --help — passed and shows the variadic syntax
  • npm run lint — passed
  • npm run test -- --no-watchman — passed, 175 suites; 1,581 passed, 2 todo, 1,583 total
  • git diff --check — passed

The automated coverage validates request construction and output behavior with mocks; no live SmartThings account, API, or hardware validation was performed.

Closes #643

Checklist

  • I have read the CONTRIBUTING document
  • Any required documentation has been added
  • My code follows the code style of this project (npm run lint produces no warnings/errors)
  • I have added tests to cover my changes

@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9783acf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@smartthings/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

question: Input multiple device IDs in smarttions devices:history

1 participant