Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Performance issue with entity refresh often #1559

Open
3 tasks done
roumano opened this issue Oct 12, 2024 · 2 comments
Open
3 tasks done

[Bug]: Performance issue with entity refresh often #1559

roumano opened this issue Oct 12, 2024 · 2 comments

Comments

@roumano
Copy link

roumano commented Oct 12, 2024

Requirements

  • I checked the troubleshooting section in the README to verify that I have the latest Mushroom version.
  • I did a search to see if there is a similar issue or if a pull request is open.
  • I have read the state of card mod support (in pin issues) and understand card mod support is not provided in this repository.

Current Behavior

Since i've created 4 new (complex) badge for my solar system, my web-browser is frequently (but not all the time) very slow in home assistant dashboard where i've created these badge.
In Firefox about:processes, it's say it's home assistant using 100% of the CPU.

most of sensor used are refreshing very often (like every 1-2 secondes )

Display all of these sensor in entities card, don't make my web-browser slow, only with badge (it's on different dashboard)

Expected Behavior

No response

Steps To Reproduce

No response

Context

YAML state

title: Home
views:
  - path: default_view
    icon: mdi:home-assistant
    title: Home
    badges:
      - type: custom:mushroom-template-badge
        content: '{{ states(entity) | int(default=0) | abs }}w'
        icon: >-
          {% set pourcent = states('sensor.victron_battery_soc') |
          int(default=0) %}

          {% if states(entity) | float(default=0) <= 0 %}
            {% if pourcent < 10 %}
              mdi:battery-alert-variant-outline
            {% elif pourcent < 20 %}
              mdi:battery-10
            {% elif pourcent < 30 %}
              mdi:battery-20
            {% elif pourcent < 40 %}
              mdi:battery-30
            {% elif pourcent < 50 %}
              mdi:battery-40
            {% elif pourcent < 60 %}
              mdi:battery-50
            {% elif pourcent < 70 %}
              mdi:battery-60
            {% elif pourcent < 80 %}
              mdi:battery-70
            {% elif pourcent < 90 %}
              mdi:battery-80
            {% elif pourcent < 99 %}
              mdi:battery-90
            {% elif pourcent >= 99 %}
              mdi:battery
            {% else %}
              mdi:battery-unknown
            {% endif %}
          {% else %}
            {% if pourcent < 10 %}
              mdi:battery-alert-variant-outline
            {% elif pourcent < 20 %}
              mdi:battery-charging-10
            {% elif pourcent < 30 %}
              mdi:battery-charging-20
            {% elif pourcent < 40 %}
              mdi:battery-charging-30
            {% elif pourcent < 50 %}
              mdi:battery-charging-40
            {% elif pourcent < 60 %}
              mdi:battery-charging-50
            {% elif pourcent < 70 %}
              mdi:battery-charging-60
            {% elif pourcent < 80 %}
              mdi:battery-charging-70
            {% elif pourcent < 90 %}
              mdi:battery-charging-80
            {% elif pourcent < 99 %}
              mdi:battery-charging-90
            {% elif pourcent >= 99 %}
              mdi:battery-charging-100
            {% else %}
              mdi:battery-unknown
            {% endif %}
          {% endif %}
        color: |-
          {% set battery = states(entity) | int(default=0) %}
          {% if battery < -3000 %}
            red
          {% elif (battery > -3000 and battery <= -2000) %}
            orange
          {% elif (battery > -2000 and battery <= -600) %}
            yellow
          {% elif (battery > -600 and battery <= 600) %}
            yellowgreen
          {% elif (battery > 2000 ) %}
            blue
          {% else %}
            green
          {% endif %}
        entity: sensor.filtered_battery_power
        label: |-

          {% if states(entity) | float(default=0) <= 0 %}
            Décharge
          {% else %}
            Charge
          {% endif %}
        tap_action:
          action: more-info
        hold_action:
          action: navigate
          navigation_path: /dashboard-electricite/solaire-excedent
        double_tap_action:
          action: navigate
          navigation_path: /dashboard-electricite/solaire-excedent
      - type: custom:mushroom-template-badge
        content: |-
          {%- set time = states(entity) | int (default=0) -%}
          {%- set minutes = ((time % 3600) / 60) | round | int -%}
          {%- set hours = (time / 3600 ) | int -%}
          {{ '{:01}h{:02}m'.format(hours, minutes) }}
        icon: mdi:timer-sand
        color: >-
          {%- set hours = ( states(entity) | int (default=0) / 3600 ) | int -%}

          {% set diff = states('sensor.filtered_battery_power')|
          float(default=0) %}

          {% if diff <= 0 %}
            {# en decharge #}
            {% if hours < 3 %}
              red
            {% elif hours < 10 %}
              orange
            {% elif hours < 20 %}
              yellow
            {% else %}
              green
            {% endif %}
          {% else %}
            {# en recharge #}
            {% if hours < 2 %}
              darkblue
            {% elif hours < 4 %}
              blue
            {% elif hours < 6 %}
              dodgerblue
            {% elif hours < 10 %}
              green
            {% else %}
              springgreen
            {% endif %}
          {% endif %}
        entity: sensor.batterie_duration
        tap_action:
          action: navigate
          navigation_path: /dashboard-electricite/victron
        hold_action:
          action: navigate
          navigation_path: /dashboard-electricite/victron
        double_tap_action:
          action: navigate
          navigation_path: /dashboard-electricite/victron
      - type: custom:mushroom-template-badge
        content: '{{ states(entity) | int(default=0) }}mV'
        icon: mdi:alpha-v-box-outline
        color: |-
          {% set diff = states(entity) | int(default=0) %} {% if diff > 50 %}
            red
          {% elif (diff > 30) %}
            orange
          {% elif (diff > 20 ) %}
            yellow
          {% else %}
            green
          {% endif %}
        entity: sensor.victron_battery_diff_cell_voltage
        label: Déviation
        visibility:
          - condition: numeric_state
            entity: sensor.victron_battery_diff_cell_voltage
            above: 15
      - type: custom:mushroom-template-badge
        content: >-
          Produit {{ states('sensor.victron_pv_yeld_today') | int (default=0) |
          round (0) }}kWh, 

          restant {{
          states('sensor.solcast_pv_forecast_forecast_remaining_today') | int
          (default=0)}}kWh
        icon: mdi:approximately-equal
        color: >-
          {% set restant = states('sensor.solcast_pv_forecast_forecast_today')|
          float(default=0) %}

          {% if restant < 10 %}
            red
          {% elif restant < 15 %}
            orange
          {% elif restant < 20 %}
            yellow
          {% else %}
            green
          {% endif %}
        label: >-
          prévision {{ states('sensor.solcast_pv_forecast_forecast_today') | int
          (default=0) }}kWh, demain {{
          states('sensor.solcast_pv_forecast_forecast_tomorrow') | int
          (default=0) }}kWh
        entity: sensor.solcast_pv_forecast_forecast_today

Environment

- Browser: Firefox 131.0 (64 bits)
- HA Version: 2024.10.1
- Mushroom: v4.0.7

Anything else?

No response

@roumano roumano added the bug Something isn't working label Oct 12, 2024
@roumano
Copy link
Author

roumano commented Nov 7, 2024

Hi,
I still have the same bad behavior in the lastest version :

  • Browser: Firefox 132.0 (64 bits)
  • HA Version: 2024.11.0
  • Mushroom: v4.0.8

@piitaya
Copy link
Owner

piitaya commented Nov 13, 2024

You are using template, it's not really recommended if your entity refresh too often because it will need to recompute the template and the card/badge every 1/2 sec.

@piitaya piitaya added question Further information is requested and removed bug Something isn't working question Further information is requested labels Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants