📝 100% Templatable Lovelace Configurations

Wrong “entities” option may NOT show an error. You will find out this error only when you start testing the card.

No, it does not))))
Read above.
Check this example, here you may find a solution:

type: vertical-stack
cards:
  - type: entities
    entities:
      - entity: input_boolean.test_boolean
  - type: custom:config-template-card
    variables:
      INPUT_BOOLEAN: states['input_boolean.test_boolean']
    entities:
      - ${INPUT_BOOLEAN.entity_id}
    card:
      type: entities
      entities:
        - entity: ${INPUT_BOOLEAN.entity_id}
          name: ${INPUT_BOOLEAN.state}

image

I’m currently using this card like this

type: custom:config-template-card
variables:
  - states['binary_sensor.waze_car_live_url'].attributes.url
entities:
  - binary_sensor.wave_car_live_url
card:
  type: iframe
  url: ${ vars[0] }

Is there any way of making this bigger and resize it ? Currently it’s coming out a bit small dimension wise.

Making bigger what?

The card, i would like it to up more dashboard space, or even an entire page.

So, are you talking about increase a size of the card?
Then this question is not related to config-template-card.
To fill the whole page - use a panel mode of the view.

I am looking for solution where I can use states of different entities depending on a switch state.

type: 'custom:config-template-card'
variables:
  SWITCH: states['binary_sensor.switch'].state
  VAR1: states['sensor.sensor1'].state
  VAR2: states['sensor.sensor2'].state
card:
  entities:
    - entity: sensor.magazyn_energii
      type: custom:bar-card
      target: '${ SWITCH === ''on'' ? VAR1 : VAR2 }'

Is it possible to use that construction at all? i did try VAR1, ${VAR1}, `${'VAR1}…

Static version
target: '${ SWITCH === ''on'' ? 500 : 1000 }'
does work

The other solution could be templating variables, but

...
variables:
  TARGET: >
    {% if is_state('binary_sensor.switch', 'on') %}
       states('sensor.sensor1')
     {% else %} 
        states('sensor.sensor2')
     {% endif %}
...
      target: '${TARGET}'

Even with quotes for {...} Do not work as well.

What am I doing wrong?

Can’t be since the card’d code is wrong.

Type of the card not specified.

No monitored entities specified.

Ok, that was a shortened example version to show only the most important parts, additionally with simplified names. To make the code more clear.

If the rest of structure will be ok this line should work?:

target: '${ SWITCH === ''on'' ? VAR1 : VAR2 }'

Let say this is the full code (still with simplified names):

type: 'custom:config-template-card'

variables:
  SWITCH: states['binary_sensor.switch'].state
  VAR1: states['sensor.sensor1'].attribute.attr1
  VAR2: 1000

entities:
  - binary_sensor.switch
  - sensor.sensor1
  - sensor.sensor_main

card:
  type: entities
  entities:
    - entity: sensor.sensor_main
      type: custom:bar-card
      target: '${ SWITCH === ''on'' ? VAR1 : VAR2 }'

The code seems OK

Great. But is not working. At least is not working as expected. The only visible effect is that card become not visible at all.

Then probably there is smth else in the code which was not posted

And You were right. One letter too much.
Thank You, Your answer gave me necessary motivation for looking for the bug :slight_smile:

on the config-template-card, I d like to use the following title:

        header:
          show: true
          title: Prijzen voor de komende ${span_hours} in (€/kwh)

where the span_hours is 24h or 48h. This doesnt work however, (the whole card is not showing), while

        header:
          show: true
          title: ${span_hours}

works just fine. Is there some setting I am missing?

  - type: entities
    entities:
    - type: custom:config-template-card
      entities:
        - input_select.apex_span_hours
      variables:
        span_hours: states['input_select.apex_span_hours'].state
      card:

        type: custom:apexcharts-card
        card_mod:
          style: |
            ha-card {
              box-shadow: none;
              margin: -8px -16px -16px -16px;
              padding: 0;
            }
        graph_span: ${span_hours}
        span:
          start: day
        now:
          show: true
          label: Now
        header:
          show: true
          title: ${span_hours} # this works ok, the longer text doesnt
        experimental:
          color_threshold: true
header:
  show: true
  title: Prijzen voor de komende ${span_hours} in (€/kwh)

On phone so not tested but the whole line needs to be the template… Something like…

header:
  show: true
  title: ${"Prijzen voor de komende " + span_hours + " in (€/kwh)"}

Would someone please help me out?

I am trying to define the name per series and the series is created using auto-entities.
But I think this is a config-template-card issue.

type: custom:config-template-card
entities:
  - input_datetime.*
  - sensor.xiaomi_humidity*
card:
  type: vertical-stack
  cards:
    - type: custom:auto-entities
      sort:
        method: friendly_name
      filter:
        include:
          - entity_id: sensor.xiaomi_humidity_*
            options:
               name: ${ states['this.entity_id'].attributes.friendly_name }

(The two entities I am defining in the beginning are being used later in the card.)

You should do only things specified in the docs.
And you have not defined a card for auto-entities.

Docs just say that templating is supported.
What would be correct then, please?

CTC does not support * for entities.

I could not find what it does support. Docs are very limited for ctc.

List of entity strings that should be watched for updates. Templates can be used here

Used it because it seemed to work for input_datetime
They seem to be working correctly

Again, not supported in the docs for auto-entities.

1 Like