How to adjust (avoid?) repainting of the whole dashboard while monitoring entities?

Hello Community.

I have a dashboard with a custom:button-card and many gif-overlays shown in several conditions, this is the beginning as an introduction:

views:
  - title: Home
    type: custom:button-card
    show_state: false
    tap_action:
      action: none
    custom_fields:
      house:
        card:
          border: none
          border-width: 0px !important;
          image: /local/grey.jpg
          panel: true
          type: picture-elements
          elements:
            - type: conditional
              conditions:
                - entity: input_select.tabletviewhelper
                  state: House
              elements:
                - type: conditional
                  conditions:
                    - entity: sun.sun
                      state: above_horizon
                  elements:
                    - type: conditional
                      conditions:
                        - condition: state
                          entity: switch.pillars
                          state:
                            - 'off'
                            - unavailable
                      elements:
                        - type: image

The gifs shown at the foremost layer are updated when the condion has changed and ONLY this gif is updated. In the following example I can see sometimes a minor “flicker” when I switch entity: switch.wallbigdoor from on to off and vice versa:

                    - type: conditional
                      conditions:
                        - entity: switch.wallbigdoor
                          state: 'on'
                      elements:
                        - type: image
                          image: >
                            [[[
                              return ('/local/blenderhouse/outside_wall_big_door_day_nolamp_' +
                             Math.trunc(states['input_number.bigdoormotion'].state).toString() +
                             '.gif');
                            ]]]
                          style:
                            top: 267px
                            left: 400px
                            width: 800px
                            height: 534px
                    - type: conditional
                      conditions:
                        - entity: switch.wallbigdoor
                          state: 'off'
                      elements:
                        - type: image
                          image: >
                            [[[
                              return ('/local/blenderhouse/outside_wall_big_door_day_nolamp_' +
                             Math.trunc(states['input_number.bigdoormotion'].state).toString() +
                             '.gif');
                            ]]]
                          style:
                            top: 267px
                            left: 400px
                            width: 800px
                            height: 534px

In the example above I have now a javascript to build the name of a gif, I want to make an animation of 30 different gifs.

My problem is that the whole DASHBOARD! is updated when input_number.bigdoormotion has changed. Including alle the other cards on the right and bottom. A complex task. (I have attached the screenshot)

To me it seems like there is some kind of, let’s call it a “tree” of components/images and a monitor is registered on a level so that only the relevant elements are updated. But the helper-entity in the js is registered on the root.

Is it a valid description of the behaviour I experienced? I hope somebody can follow me.

The update of the whole thing makes the dashboard so “nervous flickering” that I cannot use it. As an alternative I can use conditions 0 to 30 for each gif, then the update is only done in that area. But… that may mean 31 x NNN mor e lines of code on 4 locations and sounds to me like some stupid overhead.

Is there a way to influence the level of monitoring entity-changes (just in case my assumptins are correct :flushed:)

Thanks in advance, kindest regards Jörg

Do not place picture-elements inside button-card.
If you did this only to use js templates inside picture-elements - that was wrong.
Consider other ways.

In general HA is a backend application with very little frontend functionality.
That means the HTML code to show your dashboard is made on the server and then sent to the frontend.
After that the frontend pretty much lives its own life until a refresh, either from the update timer or an user action, occur, at which point the process starts over.

Do not place picture-elements inside button-card.
Why?

If you did this only to use js templates
No. js can be used anyway. picture-elements or not.
Jinja-templating cannot be used in custom-button-cards.

Kindest regards Jörg

For me, avoiding creating sandwiches from cards with no reason is an obvious thing.
Why placing picture-elements inside button-card?
Do you completely understand how button card processes events from hass?

Maybe not. But that is one of the reasons why I am here and sending questions.

And that is why I am telling you that you should not create a sandwich with no reason.
Avoid placing complex cards (like picture elements) inside a button-card.