config-template-card icon indicating copy to clipboard operation
config-template-card copied to clipboard

Automatic layout doesn't work

Open ildar170975 opened this issue 4 years ago • 10 comments

Checklist:

  • [ X ] I updated to the latest version available
  • [ X ] I cleared the cache of my browser

Release with the issue: 1.2.0

Last working release (if known):

Browser and Operating System: Win10x64 Firefox 81.0.1

Description of problem:

Found a problem with config-template-card. Two or more cards are not distributed properly on the screen - all of them are placed in one column.

How to reproduce:

  1. Add Speedtest integration.
  2. Create an empty tab.
  3. Add a new card:
type: 'custom:config-template-card'
entities:
  - sensor.speedtest_download
  - sensor.speedtest_upload
  - sensor.speedtest_ping
card:
  type: vertical-stack
  cards:
    - type: history-graph
      entities:
        - entity: sensor.speedtest_download
      hours_to_show: 24
    - type: history-graph
      entities:
        - entity: sensor.speedtest_upload
      hours_to_show: 24
    - type: history-graph
      entities:
        - entity: sensor.speedtest_ping
      hours_to_show: 2
  1. The created card is like this: https://community-assets.home-assistant.io/original/3X/f/4/f400502463965a9d1875027ed469efee6999dfa8.jpeg

  2. Then duplicate this card. Two…three cards are enough to see the issue. All cards are placed in one column.

Note, in this example there is no “variables” section - my actual code was like this:

...
variables:
  - 'states[''input_select.graph_hours_to_show_speedtest'']'
...
card:
  type: vertical-stack
  cards:
    - type: history-graph
      entities:
        - entity: sensor.speedtest_download
      hours_to_show: '${vars[0].state}'

I excluded that variable just to simplify the case.

Javascript errors shown in the web inspector (if applicable):


Additional information:

ildar170975 avatar Oct 08 '20 11:10 ildar170975

All your cards are in a vertical stack, why would you expect anything else?

iantrich avatar Oct 08 '20 21:10 iantrich

All your cards are in a vertical stack

I have THREE cards. Each has vertical-stack inside. But they are three SEPARATE cards. That's why these cards are supposed to be in different columns.

If I exclude "config-template-card" from each card and specify just "history-graphs inside vertical-stack" (i.e. without templates) - then these cards will be in three columns (https://community-assets.home-assistant.io/original/3X/e/7/e76407ff93818313f6e43a157fe2a5c3f7a5fbe3.jpeg):

type: vertical-stack
cards:
  - type: history-graph
    entities:
      - entity: sensor.speedtest_download
    hours_to_show: 24
    refresh_interval: 0
  - type: history-graph
    entities:
      - entity: sensor.speedtest_upload
    hours_to_show: 24
  - type: history-graph
    entities:
      - entity: sensor.speedtest_ping
    hours_to_show: 2

Currently with "config-template-card" I found only one reliable way to place in separate columns - custom:layout-card with "view: panel mode":

type: 'custom:layout-card'
layout: vertical
cards:
  - type: 'custom:config-template-card'
    entities:
      - sensor.speedtest_download
      - sensor.speedtest_upload
      - sensor.speedtest_ping
    card:
      type: vertical-stack
      cards:
        - type: history-graph
          entities:
            - entity: sensor.speedtest_download
          hours_to_show: 24
        - type: history-graph
          entities:
            - entity: sensor.speedtest_upload
          hours_to_show: 24
        - type: history-graph
          entities:
            - entity: sensor.speedtest_ping
          hours_to_show: 24
  - break
  - type: 'custom:config-template-card'
    entities:
      - sensor.speedtest_download
      - sensor.speedtest_upload
      - sensor.speedtest_ping
    card:
      type: vertical-stack
      cards:
        - type: history-graph
          entities:
            - entity: sensor.speedtest_download
          hours_to_show: 24
        - type: history-graph
          entities:
            - entity: sensor.speedtest_upload
          hours_to_show: 24
        - type: history-graph
          entities:
            - entity: sensor.speedtest_ping
          hours_to_show: 24
  - break
  - type: 'custom:config-template-card'
    entities:
      - sensor.speedtest_download
      - sensor.speedtest_upload
      - sensor.speedtest_ping
    card:
      type: vertical-stack
      cards:
        - type: history-graph
          entities:
            - entity: sensor.speedtest_download
          hours_to_show: 24
        - type: history-graph
          entities:
            - entity: sensor.speedtest_upload
          hours_to_show: 24
        - type: history-graph
          entities:
            - entity: sensor.speedtest_ping
          hours_to_show: 24

ildar170975 avatar Oct 08 '20 22:10 ildar170975

My guess would be that the stack is not returning the card size in time. Might have to await for the element to resolve first...ugh

iantrich avatar Oct 09 '20 01:10 iantrich

I wonder why it works fine with case "vertical-stack + non-template-card" and doesn't with case "vertical-stack + config-template-card". May be some issues about templating.

ildar170975 avatar Oct 11 '20 21:10 ildar170975

I have almost the same issue, created a variable vpd_graph_duration, using it to set the

hours_to_show: '${vars[4]}'

of one of my mini-graph-card, it works but i have to manually trigger the ui update or else it will keep the initial value, i guess it's because config-template-card only initialize variable at startup

sicknesz avatar Dec 08 '20 16:12 sicknesz

I got it to work, in my case it was the entity list not having all the entities i needed to have updated, used the devtools and figured it out.

sicknesz avatar Dec 08 '20 18:12 sicknesz

Now I have to admit that the problem also happens without vertical-stack card. It happens at least with Entities Card:

type: 'custom:config-template-card'
entities:
  - sun.sun
card:
  type: entities
  entities:
    - sun.sun
    - sun.sun
    - sun.sun
    - sun.sun
    - sun.sun
    - sun.sun
    - sun.sun
    - sun.sun
    - sun.sun
    - sun.sun
    - sun.sun
    - sun.sun

Add three same cards - all of the will be in one column. изображение

ildar170975 avatar Mar 02 '21 13:03 ildar170975

The problem is that core is not waiting for the card to resolve the size before determining the layout. Could possibly add a config option as a crude workaround.

iantrich avatar Mar 15 '21 22:03 iantrich

I managed to bypass the issue by using custom:layout-card with vertical-layout and layout-break.

ildar170975 avatar Oct 22 '21 00:10 ildar170975

The bypass do works. It could be temporary solution.

QbaF avatar Oct 22 '21 08:10 QbaF