Include template

Hello

HA Core in docker container
Change to Yaml mode.
I’m trying for 2 day’s now to include my template but it’s not workng
in my configuration;yaml i add

lovelace:
  mode: yaml
  dashboards: !include dashboard/Dashboards.yaml

this is working

Then i create a folder in my config folder templates/button-card/
in that folder is have a file button_card_templates.yaml

button_card_templates:
  CarButtons:
    show_state: true
    show_name: false
    styles:
      card:
        - background: rgb(0,0,0);
        - background: linear-gradient(0deg, rgba(0,0,0,1) 0%, rgba(17,17,186,1) 61%);
      name:
        - text-transform: uppercase
        - color: var(--primary-background-color)
        - justify-self: start
        - font-weight: bold
      state:
        - color: white
        - font-size: 12px
  CarButtons_OK:
    template: CarButtons
    styles:
      icon:
        - color: |
            [[[ if (entity.state = 'Ok') return "#6cff00" ;
              else return "#ff0000"; ]]]
  CarButtons_Aan:
    template: CarButtons
    styles:
      icon:
        - color: |
            [[[ if (entity.state = 'uit') return "#6cff00" ;
              else return "#ff0000"; ]]]

I add these line to my home.yaml dashboard

button_card_templates: !include_dir_named /templates/button-card/
views:
  - title: Home

but i still get a error

Button-card template 'CarButtons' is missing
type: custom:button-card
template: CarButtons

What do i wrong?

Don’t use capital letters in your template slugs:

Not this

button_card_templates:
  CarButtons:
    show_state: true
    show_name: etc...

This

button_card_templates:
  car_buttons:
    show_state: true
    show_name: etc...

change my template to

button_card_templates:
  car_buttons:
    show_state: true
    show_name: false
    styles:
      card:
        - background: rgb(0,0,0);
        - background: linear-gradient(0deg, rgba(0,0,0,1) 0%, rgba(17,17,186,1) 61%);
      name:
        - text-transform: uppercase
        - color: var(--primary-background-color)
        - justify-self: start
        - font-weight: bold
      state:
        - color: white
        - font-size: 12px
  car_buttons_ok:
    template: car_buttons
    styles:
      icon:
        - color: |
            [[[ if (entity.state = 'Ok') return "#6cff00" ;
              else return "#ff0000"; ]]]
  car_buttons_aan:
    template: car_buttons
    styles:
      icon:
        - color: |
            [[[ if (entity.state = 'uit') return "#6cff00" ;
              else return "#ff0000"; ]]]

Change my template to

                    - type: horizontal-stack
                      cards:
                      - type: custom:button-card
                        template: car_buttons
                        entity: binary_sensor.1fgc568_park_brake_status

Still got the same error :frowning:

this is the pad of the template
/hass-config/templates/button-card/button_card_templates.yaml

And this is the pad of the dashboard yaml file
/hass-config/dashboard/Home.yaml

Try dropping the leading slash (/)

button_card_templates: !include_dir_named templates/button-card/

Already did that before

button_card_templates: !include_dir_named templates/button-card/
button_card_templates: !include_dir_named /templates/button-card/
button_card_templates: !include_dir_named ../templates/button-card/

Non of these works :slight_smile:

I’m out of ideas. Hopefully someone else can help.

1 Like

N0nick , suggest to ask similar questions in the dedicated button-card thread.
Besides, “Include template” is a rather confusing title. Should have mentioned “button-card” there - which is a CUSTOM component not commonly used.

And try using this:

button_card_templates: !include_dir_merge_named templates/button-card/

w/o leading “/”.
And the “button_card_templates.yaml” (which you placed in “templates/button-card/”’ folder) must NOT contain the “button_card_templates” line.
Also, the whole idea of “!include_dir_merge_named” is keeping MANY files in the “button-card” folder - like “one file per one template” or “one file for many related templates”.