-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Order automation devices in pickers based on automation usage #27477
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
base: dev
Are you sure you want to change the base?
Order automation devices in pickers based on automation usage #27477
Conversation
…origualada/frontend into order-automation-devices-in-pickers
| Object.values(this._configSubscriptions).forEach((sub) => | ||
| sub(this._config) | ||
| ); | ||
| const ctx = buildAutomationLocalContext( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to prevent this from re-creating everything when the automation changes, as it will trigger the other memoized functions to also recalculate. Can we make sure to only update those parts that actually changed? So if no devices changed, we don't recreate used.devices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a signature to the context that we can compare on change updates to not update the context object.
|
|
||
| const suggestedPrefix = suggestedDevices?.includes(device.id) | ||
| ? "0|" | ||
| : "1|"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bramkragten This is hacky but I didn't want to increase the scope of the PR nor know how you would approach an alternative. In my mind this would be replaced by a proper grouping like “Suggested” and “All devices” or something similar.
Proposed change
This PR adds the ability to reorder the device picker in automations based on the automation context. My idea was to follow the locality principle to allow faster automation creation.
It adds a Lit context to store the automation devices, entities and areas in order to pass down those values to the pickers so the lists can be reordered based on them.
I added a bigger context schema than needed for this PR just to discuss how it could be extended. This is intended as a minimal feature.
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: