Templates in card config


I am trying to develop a custom card, but I want to use templated values in the config of the card.
E.g. I want to be able to do stuff like

- type: custom:my-card
  title: Test card
  min_value: {{ states('input_number.card_min_value') }}
  max_value: {{ states('input_number.card_max_value') }}

This does not work out of the box, as it only results in the jinja-code being set as the values, not the states from the input_numbers.
I was then hoping that “_template” was some kind of magic word, and tried

- type: custom:my-card
  title: Test card
  min_value_template: {{ states('input_number.card_min_value') }}
  max_value_template: {{ states('input_number.card_max_value') }}

But that only gave “undefined” in the card code.

The card is parsing the coifig like this:

    set hass(hass) {
        const config = this.config;

        var _max = config.max_value;
        var _min = config.min_value;

What is the cleverest trick I can use to use jinja-templates and values from other parts of HA in my card config?

use one of the many custom template cards.

Thanks Used the custom:card-templater and that works.
It would be nice though if the “_template”-magic of that card worked out of the box on everything in home assistant by default.

1 Like