Outsource YAML dashboard code for reuse?

I use custom yaml card configurations with decluttering-card on my dashboards:

decluttering_templates:
  template1:
    (...)
  template2:
    (...)
view:
  (...)

Now I do not want to copy that code on top of every dashboard. So I was thinking to add it as a resource to dashboards. I created MASTER.yaml (local/www/master.yaml) that includes the decluttering_templates code part and tried to add it to my resources as stylesheet:

But that does not seem to work.

When using UI-driven dashboards - you have to paste SAME decluttering templates on a top of “raw yaml” page. After save, this “raw yaml” is converted to json; after reopening “raw yaml” page - converted to yaml and so on.
When having yaml-driven dashboards - you may share same decluttering templates stored in some yaml-file(s) between many dashboards. Details.
Many advanced users have yaml-driven dashboards for “main use”, and UI-driven dashboards - for testing only (and manually paste a decluttering template into “raw yaml” page when it is needed for initial testing).
I know no way you can use an external yaml file(s) in UI-driven dashboards.

1 Like

Ah ok … so I can either:

  1. Use the UI raw editor and have to copy the decluttering code to every dashboard where I intend to use it.
  • or -
  1. Use .yaml file-only.

Thanks for clarification.

Would including it from a separate file not work? just…

decluttering_templates:
  !include /path..../declutter.yaml

Try with

decluttering_templates:  !include /path..../declutter.yaml

where the source file contains:

template_1:
  ....
template_2:
  ....
template_3:
  ....
1 Like

Ahh sorry I was suggesting this to OP, wasn’t clear enough, this is from my config and working :slight_smile: