Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a frontend-like single entity picker #3653

Merged
merged 2 commits into from
Jul 14, 2023

Conversation

jpelgrom
Copy link
Member

Summary

Adds a new Composable SingleEntityPicker which aims to provide a text input with autocomplete search for entities like the frontend, where you can pick one and easily see which one was picked. This will be useful to have in various places.

Replaced the picker in tiles for now as an example of how it would be used to resolve this unsubmitted feature request. I'll follow up with another PR implementing it in more places if this is accepted.

The frontend includes full fuzzy searching which I'm not going to attempt in the first PR, starting with a search based on friendly name and entity ID, sorting results based on friendly name starts with > entity ID starts with > friendly name to hopefully show the most relevant results first while not requiring an exact match.

Screenshots

Light Dark
Closed/selected state shows friendly name and clear button Text input with title 'Select a entity to toggle or call (required)', clear icon and dropdown indicator at the end, light mode Text input with title 'Select a entity to toggle or call (required)', clear icon and dropdown indicator at the end, dark mode
Opened with selection: current entity at top, other entities sorted by friendly name follow Text input with dropdown menu as described, light mode Text input with dropdown menu as described, dark mode
If there are a lot of entities, use a more specific query to view more List of entities from the picker with the last item 'Refine your search to view more...', light mode List of entities from the picker with the last item 'Refine your search to view more...', dark mode
Searching not only considers the friendly name, but also the entity ID Text input with 'roboro' and one result with a friendly name 'Do not disturb' but entity ID 'switch.roborock_s6_do_not_disturb', light mode Text input with 'roboro' and one result with a friendly name 'Do not disturb' but entity ID 'switch.roborock_s6_do_not_disturb', dark mode

Link to pull request in Documentation repository

n/a

Any other notes

 - Adds a new Composable `SingleEntityPicker` which aims to provide a text input with autocomplete search for entities like the frontend, where you can pick one
…ty IDs

 - Trim search input so the space automatically added after an IME suggestion is ignored
 - Also search entity ID but sort those results second, friendly name keeps priority
Copy link
Member

@dshokouhi dshokouhi left a comment

Choose a reason for hiding this comment

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

This is amazing!

@JBassett JBassett merged commit 9d64260 into home-assistant:master Jul 14, 2023
4 checks passed
@jpelgrom jpelgrom deleted the single-entity-picker branch July 14, 2023 19:34
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.

None yet

3 participants