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

Using a device filter slows down a performance

Open madasus opened this issue 1 year ago • 9 comments

Hello,

I've been trying to figure out why my fire tablets are running slowly (i know - they are always slow) but i believe it is being caused by the auto-entities card. When I remove it from my dashboard the performance returns to normal.

I am running v1.12.1

Here is my YAML. Any ideas why this might be causing slowness? I have a lot of entities in my instance and the goal of this it to show me open security related items (doors, windows, garage doors, etc)

Is there a good way to optimize?

Thank you

M

type: custom:auto-entities
card:
  type: entities
  title: House Security
filter:
  include:
    - device: omnilink
      domain: binary_sensor
      state: 'on'
    - domain: cover
      state: open
    - domain: lock
      state: unlocked
    - domain: lock
      state: locking
  exclude:
    - domain: binary_sensor
      attributes:
        device_class: motion
    - entity_id: binary_sensor.light_sensor
    - entity_id: binary_sensor.generator_on
    - entity_id: cover.*somfy_shade*
sort:
  method: last_updated

madasus avatar Aug 29 '23 00:08 madasus

Test with last-changed.

ildar170975 avatar Aug 31 '23 02:08 ildar170975

@ildar170975 minor improvement in speed but still causes the tablet to respond slowly.

Example - When that component is disabled in the dashboard selecting another tab in the dashboard responds almost immediately. With the original config above it takes probably 20-30 seconds to response. With last-changed it takes 10-20 seconds.

madasus avatar Aug 31 '23 12:08 madasus

What about a normal desktop PC? Does it have slow performance too? Also, test w/o "device" entities (just in case).

In my experience, I may notice slow performance only when number of rows is large.

ildar170975 avatar Aug 31 '23 12:08 ildar170975

@ildar170975 The performance issues are not noticeable on my desktop.

I removed the device rows (the three below) and the performance does appear much better. Is this expected?

- device: omnilink
  domain: binary_sensor
  state: 'on'

madasus avatar Aug 31 '23 12:08 madasus

are not noticeable on my desktop.

My experience: -- iPhone 5S - works, but slowly; -- iPad Air 2 - works more-or-less ok; -- iPhone 12 - ok (but slower than a PC). And ofc it depends on a server's hardware.

Is this expected?

No idea.... To test it, here is what you can do: -- assume some device XYZ has some binary_sensor entities; -- rename these entities into smth like binary_sensor.test_xyz_*; -- then compare two cards: with filtering by the device option & by filtering by the entity_id option.

ildar170975 avatar Aug 31 '23 12:08 ildar170975

I think your on to something.

I switched to try sensor instead of binary_sensor (as my alarm panel has both) and the performance issue was still there when using the device filter.

Then I switched to this

type: custom:auto-entities
card:
  type: entities
  title: House Security
filter:
  include:
    **- domain: sensor
      state: Not Ready**
    - domain: cover
      state: open
    - domain: lock
      state: unlocked
    - domain: lock
      state: locking
  exclude:
    - domain: binary_sensor
      attributes:
        device_class: motion
    - entity_id: binary_sensor.light_sensor
    - entity_id: sensor.generator_on
    - entity_id: cover.*somfy_shade*
sort:
  method: last_changed

Basically removed the device filter and just said to include the sensor domain and the performance is really good again (even though I have extra items being returned that I don't want). Is there just a bug with how the device filter is applying? or is this a known performance issue?

madasus avatar Aug 31 '23 12:08 madasus

  1. The code you posted is unformatted. Suggest to edit it.
  2. Rename the issue into smth like "Using a device filter slows down a performance" if you think that this is a reason.

ildar170975 avatar Aug 31 '23 14:08 ildar170975

Thanks - updated both.

madasus avatar Aug 31 '23 14:08 madasus

Yes this is correct, been having same performance issues. I was able to improve it by minimizing how many entities i have on the exclude filter. I was able to accomplish this by using - hidden_by: '*' filter and disabling visibility on entities i dont want showing up in auto-entities. It was especially slow when editing auto-entities cards now it is much better.

mash2k3 avatar Dec 26 '23 15:12 mash2k3