lovelace-home-feed-card icon indicating copy to clipboard operation
lovelace-home-feed-card copied to clipboard

The card slows down the browser with huge number of requests

Open InToSSH opened this issue 3 years ago • 7 comments

Hello, I used this card in my lovelace, but if I add include_history: true, it produces a huge number of requests. After adding the card, I could no longer open the "Edit dashboard", the "Edit" buttons under each card were not loading. After refresh, the browser (Chrome) said "Waiting for available sockets" and nothing on that dashboard view was loading. I checked the Developer tools and noticed huge number of requests being made by this card. These are my settings:

type: 'custom:home-feed-card'
title: Home Feed
card_id: main_feed
id_filter: ^home_feed_.*
more_info_on_tap: true
state_color: true
entities:
  - entity: lock.front_door_lock
  - entity: binary_sensor.doods_entry_person_detected
    content_template: Person detected at Front Door
    max_history: 3
    include_history: true
    exclude_states:
      - 'off'
  - entity: binary_sensor.doods_frontyard_person_detected
    content_template: Person detected at Front Yard
    max_history: 3
    include_history: true
    exclude_states:
      - 'off'
  - entity: binary_sensor.entry_door_contact
  - entity: binary_sensor.backyard_door_contact
  - entity: binary_sensor.vestibule_motion
  - entity: input_boolean.home_occupied

I noticed this happens only if I have the include_history: true set. With no history it is ok.

HA version: 2020.12.2

chrome_2021-01-06_02-27-44

InToSSH avatar Jan 06 '21 01:01 InToSSH

I thought it was only causing a problem if you had 2 entities with "include_history: true", as I have had a home feed card with only 1 entity with "include_history: true" for some time and I hadn't noticed any problems.

Today I added a card with 2 entities with "include_history: true" and my system froze up. The following graph shows cpu for the homeassistant container: home feed card The picture above is in 4 sections - ignore section 1, section 2 is with 2 entities with "include_history: true", section 3 with 1 entity with "include_history: true", and section 4 with none.

So my original home feed card was causing problems, but not so much that I noticed. As soon as I added 2 entities with "include_history: true" then my CPU really went up, and I noticed! For completeness here is my card with 2 x "include_history: true":

  - type: 'custom:home-feed-card'
    title: Showers taken today
    max_item_count: 10
    # history_days_back: 1
    # show_empty: false
    more_info_on_tap: true
    state_color: true
    # id_filter: ^home_feed_.*
    entities:
      - entity: binary_sensor.shower_in_use
        format: time
        include_history: true
        remove_repeats: false
        max_history: 10
        content_template: 'Shower'
        exclude_states:
          - "off"
          - "unknown"
      - entity: sensor.hotwater_state
        format: time
        include_history: true
        remove_repeats: false
        max_history: 2
        content_template: 'Hot Water {{state}}'
        exclude_states:
          - "unknown"

redpizza69 avatar Jun 17 '21 14:06 redpizza69

Can you please try this with the latest beta version, 0.6.1b1, which has an improvement to the history support so that it only calls the API to get the history if the state of any of the entities for which you have include_history set are changed.

Previously, a change in any state in Home Assistant (even ones you don't have in the feed card) could cause it to call the API.

gadgetchnnel avatar Jun 19 '21 10:06 gadgetchnnel

image

I really like this card, but the times the browser usues it, my processor usage rockets sky high, sending all my HA down, to a restart. removed the "history = true" and it's fine, but not nearly as usefull. Great card, hope you can work around this! All this "peaks" in processor usage are due to this.

FragMenthor avatar Jun 19 '21 19:06 FragMenthor

Can you please try this with the latest beta version, 0.6.1b1, which has an improvement to the history support so that it only calls the API to get the history if the state of any of the entities for which you have include_history set are changed.

Previously, a change in any state in Home Assistant (even ones you don't have in the feed card) could cause it to call the API.

PS: using this beta in the results above.

FragMenthor avatar Jun 19 '21 22:06 FragMenthor

@FragMenthor Have you tried clearing the browser cache after updating to the beta version? This is sometimes necessary to ensure you are running the latest version of the code.

If you have already tried that, can you please let me know:

  • Your Home Assistant version
  • The database you use for Home Assistant - the default SQLite (home-assistant_v2.db) or something else like MariaDB?
  • Do you get the same high CPU and hangs if you access the History or Logbook from the sidebar or only with this card?

gadgetchnnel avatar Jun 20 '21 09:06 gadgetchnnel

I've downloaded the beta (0.6.1b1) and it is a lot better. I still get a spike to around 100% cpu when the card loads, but it then falls back to normal. Previously it went a lot higher and then stayed high, so definitely an improvement but still not sure why I get the spike.

image

redpizza69 avatar Jun 21 '21 09:06 redpizza69

Hello again! Answering to your questions:

  • Absolutly sure I cleaned the browser cache, this happens even in incognito mode
  • Didn't tell before, but I had 4 entities with "include_history: true", all 4 with "max_items: 4". Using only one entity does not send the HA down, but still spikes the processor usage at 100% for 5-10sec while the card loads. Now I have the same entities, but with "include_history: false" ald no spike in usage.
  • Using core-2021.6.5 in a Windows10 VM
  • Using the default SQLite database
  • Only hangs with the card, not entity history.

Thanks for your great work!

FragMenthor avatar Jun 21 '21 14:06 FragMenthor