Skip to content

Use GetEntitiesForDisplayUseCase in ManageControls#7184

Open
TimoPtr wants to merge 2 commits into
mainfrom
feature/manage_controls_remove_friendly_name
Open

Use GetEntitiesForDisplayUseCase in ManageControls#7184
TimoPtr wants to merge 2 commits into
mainfrom
feature/manage_controls_remove_friendly_name

Conversation

@TimoPtr

@TimoPtr TimoPtr commented Jul 16, 2026

Copy link
Copy Markdown
Member

Summary

This PR closes #7181 by replacing the usage of friendly name with the GetEntitiesForDisplayUseCase in ManageControls.

I've added the icon of the Entity in the list too, to be like in the other entity pickers.

Checklist

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.

Screenshots

image

Any other notes

I've hidden the entity marked as hidden.

Copilot AI review requested due to automatic review settings July 16, 2026 08:09
@TimoPtr TimoPtr requested a review from jpelgrom July 16, 2026 08:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses #7181 by switching the Control settings screen to use GetEntitiesForDisplayUseCase for entity display metadata (instead of relying on the friendly name attribute), and aligns the UI with other entity pickers by showing entity icons and richer subtitle information.

Changes:

  • Replace entity loading in ManageControlsViewModel with GetEntitiesForDisplayUseCase, excluding hidden entities and sorting by display name.
  • Update ManageControlsView to render EntityDisplayItem (icon + subtitle()), removing the old domain-string mapping.
  • Add Robolectric coverage for hidden-entity exclusion, sorting, and per-server failure behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
app/src/main/kotlin/io/homeassistant/companion/android/settings/controls/ManageControlsViewModel.kt Switches entity retrieval to GetEntitiesForDisplayUseCase, filters hidden items, sorts by resolved display name.
app/src/main/kotlin/io/homeassistant/companion/android/settings/controls/views/ManageControlsView.kt Displays icons and uses EntityDisplayItem.subtitle() instead of a domain-to-string helper.
app/src/main/kotlin/io/homeassistant/companion/android/util/compose/EntityInfo.kt Removes now-unused getEntityDomainString helper.
app/src/test/kotlin/io/homeassistant/companion/android/settings/controls/ManageControlsViewModelTest.kt Adds tests for filtering/sorting and error handling across multiple servers.

Comment on lines +96 to 101
val displayState = getEntitiesForDisplay(server.id) { it.domain in supportedDomains }.last()
if (displayState is EntityDisplayState.Loaded) {
entitiesList[server.id] = displayState.entities
.filterNot { it.isHidden }
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use GetEntitiesForDisplayUseCase in Control settings screen

2 participants