thomasloven / lovelace-auto-entities

🔹Automatically populate the entities-list of lovelace cards
MIT License
1.29k stars 116 forks source link

Sort: area not working? #347

Open kylepyke opened 1 year ago

kylepyke commented 1 year ago

I've successfully created a list of entites, and all sort methods work except for area, which returns an empty list. Reverting the sort to name or any other method works correctly. Can anyone advise?

ildar170975 commented 1 year ago

No code posted = no advices(( Also, check this https://github.com/thomasloven/lovelace-auto-entities/issues/345

kylepyke commented 1 year ago

Sorry!

Here is my code:

type: entities
entities:
  - type: custom:auto-entities
    show_empty: false
    card:
      type: entities
    filter:
      include:
        - domain: light
      exclude:
        - hidden_by: user
        - state: 'off'
        - entity_id: light.*_lights
    sort:
      method: last_changed

This works, but changing the last line to method: area produces an empty card.

ildar170975 commented 1 year ago

Confirm a problem here.

Here the 2nd card (sort by area) is not displayed: изображение

Here the 2nd card is displayed and keeps being displayed after F5 (page refresh) - but sort is wrong: изображение

kylepyke commented 1 year ago

Thank you for confirming I am not crazy! @thomasloven, are you aware of this bug?

ildar170975 commented 1 year ago

Managed to achieve it by using a template option:

  - type: custom:auto-entities
    show_empty: false
    card:
      type: entities
    filter:
      template: >-
        {% set ns = namespace(entity_and_area=[]) -%}
        {%- for entity in states.light -%}
          {%- set entity_id = entity.entity_id -%}
          {%- set area = area_name(entity.entity_id) -%}
          {%- set entity_and_area = ({'entity_id':entity_id,'area':area}) -%}
          {%- set ns.entity_and_area = ns.entity_and_area + [entity_and_area] -%}
        {%- endfor -%}
        {%- set sorted_list = (ns.entity_and_area) | sort(attribute='area') -%}
        {{ sorted_list | map(attribute='entity_id') | list }}

The code may be not optimal, asked here about possible improvements.

kchiem commented 1 year ago

I can confirm this problem as well. Also, would it be possible to have an option to have a header printed for each area that entities are grouped under?

seblu commented 1 year ago

I can confirm. Sorting is not working. In my case, it looks like area of the device is used while it's redefined in the entity itself.

ncd7 commented 10 months ago

I can confirm this problem as well. Also, would it be possible to have an option to have a header printed for each area that entities are grouped under?

This would be amazing but I think it warrants a separate feature request. At that point, it becomes sort of a "group by" request where each group can have its own heading. Of course, it could be accomplished by other means so the owner of this AMAZING card might not be willing to implement it.

A collapsible group-by would be truly amazing :P.

gh0st125 commented 8 months ago

any news on this? I also can't sort by area, still gives me an empty list when entering

sort:
  method: area

It is also not available in the dropdown-list via the visual editor:

image

400HPMustang commented 5 months ago

Hello I just found this and I am having the same issue. I'm hoping there will be a fix soon.

Area is missing from the sort drop down in the UI editor, manually coding area sort will not show the card.

image
lenne0815 commented 3 weeks ago

Same problem here unfortunately.