Skip to content

Add entities via labels to entities card #25438

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

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

karwosts
Copy link
Contributor

@karwosts karwosts commented May 12, 2025

Proposed change

Add a new row type (type: label type: filter) to entities card, by which a label is auto-expanded to draw a row per entity with that label.

image

I also considered other approach like using a target selector instead, but that didn't seem like a natural fit for entities card with its plethora of other custom row types.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@piitaya
Copy link
Member

piitaya commented May 12, 2025

I tried to do something similar by creating sections strategies : #24607
I wonder if we should build a "target selector" for front-end card so it can be reused in different place (to achieve something similar to entities-card)

@karwosts
Copy link
Contributor Author

I think it would be somewhat tricky to come up with a one-size-fits-all selector that could work for any type of card, given that the things we select need to be munged in a list with other items that vary based on the type of card (entities card has entities and labels intermixed with other special row types), and each selected item may or may not need its own submenu to configure properties that may differ from card to card.

As (and if) we keep expanding labels to more use cases, I would just focus on making sure there are at least good helper functions that minimize the overhead, but I don't think of a good UI design that can handle all that special behavior.

Even for now this is just a yaml-only thing, but might revisit UI improvements if this is favorable.

@bramkragten bramkragten added the Needs UX Pull requests requiring a review from the Home Assistant design team label May 13, 2025
@bramkragten
Copy link
Member

I do think this could/should use the same syntax as the filter in #24607.

That way we dont have to re-invent the wheel.

Also, if we are going forward with this, we also need to update the size logic of the entities card, as now every item in entities renders 1 row, and with this PR and item in entities could render multiple rows.

I wonder if we should instead add strategy support to the entities card, maybe that is overcomplicating things, but...

@karwosts
Copy link
Contributor Author

I do think this could/should use the same syntax as the filter in #24607.

Not sure how that maps to entities-card syntax exactly. Something more like this?

entities:
  - sun.sun
  - type: filter
    filter:
      label: weather
  - type: filter
    filter:
      label: air_quality

@bramkragten
Copy link
Member

bramkragten commented May 26, 2025

yes, exactly that

Funny thing is, we had something like this at the beginning of Lovelace, and we then decided to remove it 🙃

@karwosts
Copy link
Contributor Author

karwosts commented May 26, 2025

Also, if we are going forward with this, we also need to update the size logic of the entities card, as now every item in entities renders 1 row, and with this PR an item in entities could render multiple rows.

I thought perhaps we would just ignore it. I thought size was only determined directly from the config, without hass. Similar to how history card doesn't know the right size either, since it doesn't know how it will load. I didn't think we would defer it until we load all the registry and do all the calculations.

@bramkragten
Copy link
Member

Maybe we should, as it is only for the masonry view...

@karwosts
Copy link
Contributor Author

karwosts commented May 26, 2025

Renamed and replaced type: label with type: filter, to better match the other syntax. label is the only supported key under filter for now, you can let me know if that's sufficient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed Needs UX Pull requests requiring a review from the Home Assistant design team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants