Config template card to customer create cards, but how?

sensors of the same manufacturer, fits certain patterns well. i want to produce cards using functions that leverage the patterns. I also want to use the multiple-entity-row card for each device.

how can i manage this with templates?

so far i created a macro in custom_templates:

{%- macro format_thermometer(term,nice_name) -%}
entity: sensor.{{term}}_temperature
type: custom:multiple-entity-row
name: {{nice_name}}
secondary_info: last-changed
state_header: temperature
entities:
  - entity: sensor.{{term}}_battery
    name: battery
  - entity: sensor.{{term}}_humidity
    name: humidity
{%- endmacro -%}

this way,

{% from 'kshort.jinja' import format_thermometer %}
{{ format_thermometer('t_bedroom','Bedroom') }}

produces a card that might work:

entity: sensor.t_bedroom_temperature
type: custom:multiple-entity-row
name: Bedroom
secondary_info: last-changed
state_header: temperature
entities:
  - entity: sensor.t_bedroom_battery
    name: battery
  - entity: sensor.t_bedroom_humidity
    name: humidity

only if i knew how to put this together…

I imagine a vertical stack that has something like:


{% from 'kshort.jinja' import format_thermometer %}
{{ format_thermometer('t_bedroom','Bedroom') }}
{{ format_thermometer('t_girl','Lale') }}
{{ format_thermometer('t_boy','Ali') }}

I think config-template-card is the way to go, but i cant find a juicy tutorial, only reference documentation. Kindly for your advise,
Koray

No, it uses JS instead of jinja.

Your method may only be used to generate a code in Dev tools → Template - and then manually copy/paste the generated code into yaml.
I’m using a similar method to generate many similar sensors/helpers/etc.

Check “Lovelace gen” - it allows to generate UI. (never used myself)