Skip to content

feat: add hub filter to devices command - #847

Open
sungmpar wants to merge 1 commit into
SmartThingsCommunity:mainfrom
sungmpar:feat/devices-hub-filter
Open

feat: add hub filter to devices command#847
sungmpar wants to merge 1 commit into
SmartThingsCommunity:mainfrom
sungmpar:feat/devices-hub-filter

Conversation

@sungmpar

@sungmpar sungmpar commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a long-form --hub filter to devices while preserving -H for --health
  • match declared integration-specific hub IDs for DTH, LAN, Matter, Zigbee,
    Z-Wave, Edge Child, and Virtual devices
  • include nested child devices by following parent-device ancestry
  • preserve existing list filters, numeric-index selection, health, status, and
    verbose output behavior
  • add comprehensive regression coverage and a patch changeset

Root cause

The devices list API has no hub filter, and hub membership can span multiple
parent-device levels. The CLI previously forwarded only API-supported filters
and did not reconstruct device topology, so users with multiple hubs could not
isolate every device joined to one hub, especially nested child devices.

When another list filter narrows the candidates, the implementation loads one
unfiltered device list for ancestry lookup. Missing parents and cycles fail
closed, duplicate candidates are removed, and the selected hub itself is not
returned.

Verification

  • npm run test -- --runTestsByPath src/__tests__/commands/devices.test.ts --no-watchman (20 of 20 tests passed)
  • npm run build
  • node dist/src/run.js devices --help
  • npm run lint
  • npm run test -- --no-watchman (175 suites and 1,577 tests passed)
  • git diff --check

The built help shows long-form --hub, retains -H for --health, and
includes a hub-filter example. The README generator ran during the build and
produced no tracked README change.

Verification used repository-native mocked devices; no live SmartThings account
or hardware mutation was performed.

Fixes #588

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: d827be4

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.

[feat] Add a flag to the devices command to filter devices by which Hub they're joined to

1 participant