lovelace-auto-entities: filter on include: label causes lag and grinds the view

HA 2024.4.2 Auto-entities 1.13.0

Glad the new labels are implemented in the auto-entities config options (thanks!). However, something is causing a huge lag, so much so, it practically stops the view from responding. Ive moved the testing configs for this from UI dashboards to yaml dashboards, as the editor simply wont open.

Als there seems to be a memory increase (see far right for the sudden spike on editing an auto-entities card with the option label filter)

Scherm­afbeelding 2024-04-09 om 10 35 45

though that is of lesser importance, and not 100% reproducible

The Frontend Lag is, I am afraid.

using a template filter is fine:

card:
  type: entities
filter:
  template: |
    {{label_entities('Theater')}}

but using the label include makes the card drag the view down:

type: custom:auto-entities
card:
  type: entities
  title: Auto label
filter:
  include:
    - label: theater

or

type: custom:auto-entities
card:
  type: entities
  title: test filter label auto entities
filter:
  include:
    - label: intercom_speler
  exclude:
    - state: unavailable

or a config like this, using the card_param:

            - type: custom:auto-entities
              card_param: cards
              filter:
                include:
                  - label: hub
                    options:
                      type: tile
              card:
                type: grid
                columns: 2
                square: false

they all show the correct entities, so the label include does work in itself.

That’s why I opened this separate issue from another open issue

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 1
  • Comments: 29

Most upvoted comments

@amaisano @Mariusthvdb I have spent some time looking at this. My hypothesis is the underlying performance can still be improved. Currently, reigstry cache (entities, areas, floors, devices, labels) are queried using Array.find() with a callback. I have submitted a PR (#559) that stores the cache via the registry lookup id, so rather than being a numeric indexed array, it is indexed by the registry lookup id. Accessing the cache is then by direct index, rather than using find().

This is quite a large code change, but small as to change of method, so all should work as before.

I have a branch in my fork where I have a build while includes both this change, and the change for working around cards with errors. See https://github.com/dcapslock/lovelace-auto-entities/tree/dcapslock-version. You can take the auto-entities.js file form there. Alternatively, add my fork as custom repository to HACS and use the different version download mechanism to download the pre-release version. Version is 1.16.1-dcapslock.1.

Check in your console that you are running correct version. Should list as per below.

AUTO-ENTITIES 1.16.1-dcapslock.1 IS INSTALLED

It will be interesting to see how this goes. Hopefully good. 🤞

there’s something I just noticed while adding a new auto-entities card via the UI flow (I didnt yet do that before, using all yaml, or just pasting yaml in the UI editor before):

seems like it pre-loads all entities in the editor, just like dev tools states does. Since I have a lot of entities, dev tools states has been the worst view by far in the system since forever. Could it be auto-entities now is also bugged by this, now the label option has been added? Maybe not only in there UI editor, but now also in the final Dashboard itself?

So it seems to be OK on desktop but not devices? If so then that will be caching issue. So either update the dashboard resource URL to make it different, say add a digit to hacstag or clear caches in devices via debugging menu.

If you can PR that successfully it would fix 2 years trouble 😉

PR Submitted: https://github.com/home-assistant/frontend/pull/26153

1 more comment: I have several entities that update up to a couple of times per second. Caused by my smart meter, and injected into HA via MQTT, so nothing we can do about that frequency. Add that to a couple of templates based on that, and the recorder DB fills rather swiftly, if you know what I mean…

I did some testing to take those fast changing entities out for a while, but couldnt really note a progress in the helpers. Still, it might be worth the effort to check, now you are so close to nailing this?

from DBStats: dont get me wrong: if this is unrelated, ignore. It’s just that I want you to have all info that could possibly help reducing those lags in the auto-entities and helpers overviews.

Image Image

Magician!

And yes, what you describe is exactly what I returned as testing feedback during the betas and afterwards in raising issues… somehow the devs can’t find that, or don’t bother.

If you can PR that successfully it would fix 2 years trouble 😉

Again: magic .

makes me think, maybe this can also help the issue on the helpers page in HA ui? https://github.com/home-assistant/frontend/issues/21530

it’s been going on for a long time, and at first I had hoped a fix there would help auto-entities… but now you fixed auto-entities, I wouldnt mind you checking the Helpers issue 😉

That’s absolutely the best feedback. Great to be able to tick off another issue 😃

Image

wow. just wow.

this is another world! “saya melihat dunia lain” as my Indonesian friends would say.

The card flies by in UI mode, and presents the available labels in the dropdown without any hiccup. Any of the other filters works like magic too now, and in Editor, or in real Browser window, the page has no delay any longer.

I still have a few auto-entities under a fold-entity-row that take a second to show, but I suspect that is by design and caused by the animation in the custom plugin…

Image

for comparison on how it was lagging check this screen video

Same issue. I have about 500 devices, and 5000 entities. Only a few are actually labeled however. When I added 20 different AE cards each asking for a different Label, the page crashed. I removed a few and it was still too slow to edit.

Thomas, if you see this:

could you please check the PR in the mentioned HA issue above? That tries to add a throttler to the /config pages, because the frontend was unable to cope with the state changes constantly being evaluated and, well, changing…

It was only with that discussion, I realized it might be related to the issue here, being the exact same user experience.

Could it be that filtering the label in auto-entities is also seeing this same issue? and a throttles a la that Pr would be useful?