Skip to content

fix(open-dash): return full device list instead of first device in listDevices [4534926564] - #22

Merged
pstuart merged 1 commit into
masterfrom
repo-prompt/smartthings-api-smartapp-04224534926564
Sep 5, 2026
Merged

fix(open-dash): return full device list instead of first device in listDevices [4534926564]#22
pstuart merged 1 commit into
masterfrom
repo-prompt/smartthings-api-smartapp-04224534926564

Conversation

@pstuart

@pstuart pstuart commented Sep 4, 2026

Copy link
Copy Markdown
Member

Summary

Automated repository workflow run 20260904T224534926564Z-smartthings-api-smartapp from master @ bab6c6374a9ce964cdec8ae5f798d90f909fe5c4.

Issues fixed

Adds: bounded repository improvement (no coder-confirmed closing keywords)

Issues investigated

  • none (untracked bounded work)

Bare #N refs above are investigation context only — they do not close issues. Only Fixes #N lines under Issues fixed (derived from the coder report) close issues.

Workflow

  • Spark lightning: code and GitHub issue/PR investigation
  • Spark coder: implementation and safe simplification pass
  • Fresh Spark lightning: independent code review (including issue-claim checks)
  • Runner verification: no canonical test command inferred
  • Head SHA: a8aa7f3f9fa98e3a9f3ff1c1c39a62abe36cfd61

Coder report

Done. I applied a single, bounded correctness fix to listDevices(), the one remaining instance of the off-by-one / wrong-shape defect class this project has been fixing (PRs #17#20 were all of this kind). No issues existed to implement, so this is a kind: review-fix improvement.

Issues-Addressed

  • Adds: listDevices() no longer collapses the device list to its first element — corrected the collection/list branch so GET /devices returns all subscribed devices (an array of device objects) instead of only the first one, matching the documented API contract and the behavior of the sibling listing endpoints.

Changes-Made

  • smartapps/opendash/open-dash.src/open-dash.groovy:533-535 — Replaced
    def result = []; result << allSubscribed.collect{deviceItem(it, false)}; ... new JsonBuilder(result[0])
    with
    def result = allSubscribed.collect{deviceItem(it, false)}; ... new JsonBuilder(result).
    Why: the old code wrapped the collect result in a one-element list and then rendered result[0], which (a) returned only the first device for a multi-device location and (b) threw IndexOutOfBoundsException when no devices were subscribed (empty list). Rendering the full result array fixes both and matches listModes/listHubs/listRoutines, which all render their full result list.

Simplification-Pass

  • applied: removed the redundant result << ... append-to-empty-list idiom — the collect list is assigned directly to result (removes needless state/wrapper introduced by the bug).
  • deferred: none. No other duplication or dead code in the touched path. (The duplicate type key in getHubDetail and the i.supportedAttributes missing ?. in allDevices were noted but left alone as out-of-scope, not part of this fix.)

Verification

  • git diff — single file changed, 2 insertions / 3 deletions; only listDevices() modified.
  • git status --short M smartapps/opendash/open-dash.src/open-dash.groovy (exactly one modified file; nothing else touched).
  • awk brace-balance check on open-dash.groovy → balance 0 (syntactically balanced; no unbalanced braces/brackets introduced).
  • grep -nE 'result\[[0-9]+\]' over the file → no remaining index-into-accumulated-list patterns; the off-by-one shape is now unique to this fixed site.
  • find for *.gradle/pom.xml/Jenkinsfile/*Test*.groovy and ls → no test suite or build tooling exists in the repo, so there is no canonical test command to execute; verification above (diff + static checks) is the full verification available.
  • No Groovy compiler/interpreter available in this environment, so execution of the SmartApp is not possible here; correctness is established by the diff, brace balance, and consistency with the documented API.

Remaining-Risks

  • No executable test harness exists for this SmartApp (no Gradle/Spock/CI), so the change is verified by static analysis only. Runtime behavior (SmartThings findDevice/allSubscribed/deviceItem semantics) cannot be exercised in this sandbox. The change is low-risk: it only alters the non-id branch of listDevices() to render the full list, identical in shape to the already-working listModes/listHubs/listRoutines.

Suggested-Commit-Title

fix(open-dash): return full device list instead of first device in listDevices

Independent review

{"passed": true, "summary": "Fixes listDevices() off-by-one/wrong-shape defect: changed result wrapping from [0] to full array, matching sibling endpoints and preventing IndexOutOfBoundsException on empty lists"}

@pstuart
pstuart marked this pull request as ready for review September 5, 2026 17:42
@pstuart
pstuart merged commit 7cf5349 into master Sep 5, 2026
@pstuart
pstuart deleted the repo-prompt/smartthings-api-smartapp-04224534926564 branch September 5, 2026 17:42
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