thomasloven / lovelace-auto-entities

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

Using a device filter slows down a performance #379

Open madasus opened 10 months ago

madasus commented 10 months ago

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
ildar170975 commented 10 months ago

Test with last-changed.

madasus commented 10 months ago

@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.

ildar170975 commented 10 months ago

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.

madasus commented 10 months ago

@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'
ildar170975 commented 10 months ago

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.

madasus commented 10 months ago

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?

ildar170975 commented 10 months ago
  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.
madasus commented 10 months ago

Thanks - updated both.

mash2k3 commented 6 months ago

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.