lovelace-auto-entities icon indicating copy to clipboard operation
lovelace-auto-entities copied to clipboard

Sort: area not working?

Open kylepyke opened this issue 2 years ago • 11 comments

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?

kylepyke avatar Mar 01 '23 05:03 kylepyke

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

ildar170975 avatar Mar 01 '23 19:03 ildar170975

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.

kylepyke avatar Mar 02 '23 00:03 kylepyke

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: изображение

ildar170975 avatar Mar 02 '23 00:03 ildar170975

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

kylepyke avatar Mar 02 '23 00:03 kylepyke

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.

ildar170975 avatar Mar 02 '23 02:03 ildar170975

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?

kchiem avatar Apr 21 '23 04:04 kchiem

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.

seblu avatar Sep 16 '23 11:09 seblu

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.

ncd7 avatar Jan 01 '24 23:01 ncd7

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

gh0st125 avatar Feb 13 '24 10:02 gh0st125

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

400HPMustang avatar May 24 '24 16:05 400HPMustang