Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95944

Templates in card config

$
0
0

@Olen wrote:

Hi,

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?

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95944

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>