WTH - Adding native support to reusable sections with substitution parameters (Lovelace_gen but easier)

I refrained from using the word Template here to avoid confusion.

I have a huge section of my dashboard that is replicated to 4 different users with just one or 2 parameter changed through it. Really difficult to maintain.
I basically do this: https://youtu.be/IYdr2CIu6oc?si=4WYpznBc3BJyFsBW&t=281)

I’d like to have a native way for doing Lovelace_gen like templating, which is a very hardcore approach, forcing everything to be done in YAML instead of the Visual Editor.

A new Reusable Section could take input parameters that would replace placeholders.

We could do it by introducing a new Bracket Tag: something like {#placeholder_name#} or {$placeholder_name$}.

On the Editor, we’d have all parameters with a Default value for editing purposes (to make it a valid section and render it).

Example:

reusable_section_person:

...
  cards:
    - type: entity
      entity: {#person_ent#}
    - type: entity
      entity: {#person_sensor#}

Then one could have it instantiated like:

{$ reusable_section_person
     person_end={{person.marcus}}
     person_sensor={{sensor.selected_area_marcus}}
$}

Resulting in:

...
  cards:
    - type: entity
      entity: person.marcus
    - type: entity
      entity: sensor.selected_area_marcus

Then a second instantiation like:

{$ reusable_section_person
     person_end={{person.bob}}
     person_sensor={{sensor.selected_area_bob}}
$}

Resulting in:

...
  cards:
    - type: entity
      entity: person.bob
    - type: entity
      entity: sensor.selected_area_bob

Then on the UI, one could edit the reusable section, which would show parameters:

  • person_ent - defaults to person.marcus
  • person_sensor - defaults to sensor.selected_area_marcus.

And the example would render just like the first instance above, which is a valid snippet.

Might be fun to take this further and have ‘blueprint’ lovelace dashboard pages, either self or community made. I appreciate dashboards are a very personal thing, but it would be a great head start for common dashboard use cases for people who dont want to spend ages designing.

1 Like

Just heard about this:

I wish this would become part of HA itself, with better integration, like editing the templates from the UI (like I described in the OP).

My request could be merged with

This is similar to my feature request from a while back:

1 Like