Dumb question: multiple include files in lovelace:

Can anyone please tell me what’s wrong with the opening lines on a single lovelace dash UI yaml file, please?

Error is: Button-card template ‘riverlevel’ is missing! (similar repeated for every button-card)

This works if all the template yaml is put into just one !include file
I know it’s reading both files, as if I corrupt the path name, it breaks with a clear file reading error.

mobile-dev.yaml :

  - !include templates/mobile-sizes.yaml
  - !include templates/mobile-controls.yaml

title: Squidville

I can get a single include to work, but not multiple includes under the same header. This works:

decluttering_templates: !include lovelace-templates-decluttering.yaml
button_card_templates: !include lovelace-templates-button-card.yaml
title: Home
  wrap: true
  animate: swipe
# Main
  - title: Main
1 Like

Thanks Russell. It’s a limitation, but if I know it is so, at least I can work around it. Perhaps the C #include pragma might have been an alternative approach - more intuitive.

You can include that way but you have to remove the - inside your files. The - is either outside on the single file line and the file contains 1 template, or the include is on the full field and multiple templates are in the file. Not both. Because it didn’t work for you, you must have had the dash in both places.

So, petro, just to clarify, this should also work:

  !include lovelace-templates-decluttering-1.yaml
  !include lovelace-templates-decluttering-2.yaml
  !include lovelace-templates-button-card-1.yaml
  !include lovelace-templates-button-card-2.yaml
title: Home
  wrap: true
  animate: swipe
# Main
  - title: Main

and the include files start something like this:

    color_type: card
    size: 80%
      action: more-info
        - padding: 0.2em
        - '--mdc-ripple-color': yellow
        - '--mdc-ripple-press-opacity': 0.5
# etc, etc, etc...

That’s not working for me - although it looks like it should…

That won’t work. They are keyworded, not a list. And even if they were a list, you’d need the list indicator, -. You can only map to the entire field.

Your method would work if you added a keyword: before your includes.

I can’t post an example because I’m on mobile


Thank you Petro.

Wait - might have a solution:

This seems to work:

button_card_templates: !include_dir_merge_named templates

Inside templates/ are 2 yaml files, one of which references templates in the other.

So a possible solution is to restructure as:


And in the lovelace dash yaml:

button_card_templates: !include_dir_merge_named templates/mobile-1/

I’m just off to confirm if that works… It would do me. If I find I have shared files (between entirely different template sets), a good old linux symlink or hardlink should do the job…

I think I have a solution I like:

The Lovelace dash is /config/local/dashboards/mobile-dev.yaml

It brings in everything recursively under …/local/templates/mobile-compact/

sizes/ has the layout pixel/%/etc settings
cards/ has the card tempates for button-card

The idea is that I can symlink/hardlink**
…/local/templates/mobile-compact/cards/ → …/local/templates/pad-compact/cards
and employ a local sizes/ directory with different scalings.

** Can’t hardlink dirs - but could do so to the files - just noted for the purists :smiley:

Yes, I know - I should write the ultimate layout that scales for everything nicely - but it’s easier just to pixel customise a couple of dashboards so they look super crisp on the devices my family use.

But either way - I hope this general idea might be useful or adaptable for others :+1:

The image is no longer available. Would you mind to paste directly in the message?


Like this

sensor: !include beukenbos/sensors/beukenbos_sensors.yaml
sensor: !include beukenbos/sensors/afvalbeheer_sensors.yaml
sensor: !include beukenbos/sensors/siemens_session_token.yaml

but that isn’t working for me either

because you cant have the same key 3 times. If you’re trying to map that, there’s a whole section in the docs for breaking up your config. That requires a !include_dir_merge_list.

sensor: !include_dir_merge_list beukenbos/sensors

I’m aware of the !include_dir_merge_list and used that before but I don’t want all files in the directory to be included, hence I change to listing the individual files.

You can’t do that. You either include them all, or list them individually. However if you list them individually, the individually listed files can only contain 1 sensor.