📝 100% Templatable Lovelace Configurations

I think this was a bit confusing release note)))))
It was already possible to refer variables in this way)

Hello, I’d like to combine template lovelace with fluid-level-baground-card but can’t get it to work.
This is mycode so far:

type: horizontal-stack
cards:
  - type: custom:config-template-card
    entities:
      - sensor.ibc_mitte
    card:
      type: custom:fluid-level-background-card
      graph: none
      type: sensor
      entity: sensor.ibc_mitte
      detail: 1
      full_value: "1000"
      severity: []
      fill_entity: sensor.ibc_mitte
      name: "{{ states('sensor.ibc_mitte') }}"  # Dynamischer Name basierend auf dem Wert von sensor.ibc_mitte
  - type: custom:config-template-card
    entities:
      - sensor.ibc_oben
    card:
      type: custom:fluid-level-background-card
      graph: none
      type: sensor
      entity: sensor.ibc_oben
      detail: 1
      full_value: "1000"
      severity: []
      fill_entity: sensor.ibc_oben
      name: "{{ states('sensor.ibc_oben') }}"  # Dynamischer Name basierend auf dem Wert von sensor.ibc_oben

Making a sandwich only to change a “name”?
In general, the code which you use in templates is wrong. You are trying to use jinja, the card supports JS. Check examples in docs.

Thank you, I’m new to this stuff.

Ok, I see… I changed my code but it doesn’t work…

type: horizontal-stack
cards:
  - type: custom:config-template-card
    variables:
      IBC: states['sensor.ibc_mitte'].state
    entities:
      - sensor.ibc_mitte
    card:
      type: custom:fluid-level-background-card
      graph: none
      type: sensor
      entity: sensor.ibc_mitte
      detail: 1
      full_value: "1000"
      severity: []
      fill_entity: sensor.ibc_mitte
      name: "${IBC}"  # Dynamischer Name basierend auf dem Wert von sensor.ibc_mitte
  - type: custom:config-template-card
    variables:
      IBC2: states['sensor.ibc_oben'].state
    entities:
      - sensor.ibc_oben
    card:
      type: custom:fluid-level-background-card
      graph: none
      type: sensor
      entity: sensor.ibc_oben
      detail: 1
      full_value: "1000"
      severity: []
      fill_entity: sensor.ibc_oben
      name: "${IBC2}"  # Dynamischer Name basierend auf dem Wert von sensor.ibc_oben

I would suggest you to test with a stock Entity card first.

`Hello together,

I would like to use your map to automatically read out HUE scenes in the attributes and then display them as buttons in a horizontal slider or as a grid.
The aim is to automatically display newly created scenes with the hue app in the HA dashboard

Example entity:
light.jan_az_2

Attribute:
  min_color_temp_kelvin: 2202
  max_color_temp_kelvin: 6535
  min_mireds: 153
  max_mireds: 454
  supported_color_modes: color_temp, xy
  color_mode: color_temp
  brightness: 255
  color_temp_kelvin: 4000
  color_temp: 250
  hs_color: 26.812, 34.87
  rgb_color: 255, 206, 166
  xy_color: 0.42, 0.365
  is_hue_group: true
  hue_scenes: Color Burst, Nordlichter, Hell, Verträumter Sonnenuntergang, Nachtlicht, Unter dem Baum, Ruhephase, Krokus, Kühl hell, Natürliches Licht, Miami, Rio, Entspannen
  hue_type: room
  lights: Hue Play 1, Hue Play 2, Jan AZ
  entity_id: light.hue_play_2, light.jan_az, light.hue_play_1
  dynamics: false
  icon: mdi:lightbulb-group
  friendly_name: Jan AZ
  supported_features: 40

the following code correctly lists the scenes:

type: markdown
entity_id: light.jan_az_2
content: "{{ states.light.jan_az_2.attributes.hue_scenes }}"

Result:
Color Burst,Nordlichter,Hell,Verträumter Sonnenuntergang,Miami,Nachtlicht,Unter dem Baum,Ruhephase,Krokus,Natürliches Licht,Kühl hell,Rio,Entspannen

I currently use the following code in the dashboard (manuell)

  type: vertical-stack
  cards:
    - square: false
      type: grid
      columns: 3
      title: Szenen
      cards:
        - type: tile
          entity: scene.jan_az_naturliches_licht
          hide_state: true
          tap_action:
            action: toggle
          name: Natürliches Licht
          vertical: true
        - type: tile
          entity: scene.jan_az_hell
          hide_state: true
          tap_action:
            action: toggle
          name: Hell

So far I have only received code errors or blank cards. Can you help me here? Thanks a lot for helping

type: 'custom:config-template-card'
variables:
 
  SCENES: states['light.jan_az_2'].attributes.hue_scenes
    ? states['light.jan_az_2'].attributes.hue_scenes.split(',')
    : []
entities:

  - light.jan_az_2

card:
  type: vertical-stack

  cards: >
    ${SCENES.map(scene => `
    - type: tile
      # Wir bauen den Scene-Entity-Namen, z.B. "scene.jan_az_color_burst"
      entity: scene.jan_az_${scene.trim().toLowerCase().replace(/ /g, "_")}
      name: "${scene.trim()}"
      tap_action:
        action: toggle
      vertical: true
    `).join('')}

Nevermind. I just modified the integration to create the sensors even when not used and it will solve my problem.

If this is a repeated question, please let me know where to find the answer. I could not find it. If a new thing, any clue on what should be done to solve the situation I will report below?

I have a complex card panel using the config-template-card and this helps me a lot to dynamically load my entities based on the value set for a SELECT entity. Amazing.

My problem occurs when some of these entities don’t exist for the selected value.
To make it clear:
The entities are created by a MQTT integration. Sometimes some of the expected entities for this panel may not be created and the entity will no longer exists.

When it happens, if two or more entities are missing, the config-template-card just does not load anything. Just a blank card.

This is a useful scenario “create a list of cards dynamically”.
Use this example as a starting point:

  - type: custom:config-template-card
    variables:
      LIGHTS: |-
        Object.keys(states).filter(
          k => k.startsWith('light')
        )
    entities: ${LIGHTS}
    card:
      type: grid
      title: xxx
      square: false
      columns: 3
      cards: >-
        ${
          let cards = [];
          LIGHTS.map(entity =>
            cards = cards.concat(
              {
                'type':'tile',
                'entity':entity
              }
            )
          );
          cards;
        }

P.S. Tested with beta 3.17.