This came up in the 2022 WTH but I’ll bring it up again because it remains an unmet need.
Right now it’s possible to define custom:button-card templates that can be reused throughout the dashboard on multiple buttons. Unfortunately, all of the button definitions have to be stuffed into the “raw configuration editor” that does not allow spacing or comments.
Similarly, I use card-mod a fair amount for some cards that I want to look similar to each other but different from others, and every time I want to use it, I have to copy-paste the entire thing from another card because I can’t import a consistent definition from anywhere. And then when I make a change? I have to change every single card. (Yes, I know card-mod styles can be defined in a theme, but I don’t want to do that - I just want some cards styled the way I want.)
In storage mode, a dashboard is stored as json. I am not sure that json supports including other jsons.
All yaml-related technics like “include”, “yaml-anchors” are YAML THINGS. So, if you need to use them - use yaml.
That’s the technical reason behind this, but not a solution to the problem outlined.
wixoff is absolutely right, I would also love to use the GUI editor to place cards on the dashboard and rearrange them. But there’s some cards which just make much more sense to build up from code. And a lot of cases in which it would be nice to reuse code.
Currently, that means I need to move the entire project into YAML. (Even then, code reuse is a struggle, but that’s a different challenge.) We really should find a way to bridge the gap and make this possible.
Yes, I am certain there are ways to enable this even if JSON doesn’t support includes natively. There are some advantages to using the GUI dashboard builder (for me, highest among them being the ability to quickly modify something on-the-fly if circumstances call for it.)
Plus it helps bridge the gap between the powerful-but-tedious YAML approach and the (perhaps) overly simple GUI approach. It shouldn’t cause basic GUI users much of a problem, because they probably shouldn’t be in the raw config editor anyway!
And btw., if I remember correctly, official YAML also doesn’t have all these !include directions either. Those are all standard-violating extensions by HA or the libraries it is using. (And I’m very thankful they exist! Just saying “the standard doesn’t support it” is not very applicable excuse here.)
The title of this WTH is about using “!include” directive in a storage-mode dashboard.
You were explained that “!include” may only work in yaml-mode dashboards.
But yet you are saying that it is a technical side which you do not bother as a customer.
Then I would suggest to rename this WTH to smth like “WTH not possible to reuse a code in storage-mode dashboard” - then this WTH will be fortunately merged with other similar WTH which is present here.
I did not intend the title of the post to state the entirety of the issue; it is phrased as my personal pain point that others might share. It’s not quite the same issue as reusing cards or sections in other views or dashboards.
I’m voting for as many of those other ones I can find too, as I hope others will. From the number of votes I’m seeing on related issues hopefully this is understood to be a fairly widespread concern - I know it’s being worked on for practically every release, but the GUI dashboard editor really does need some tuning up.
I understand your desire to keep using storage-mode dashboard.
Some users use storage-mode only for quick testing some solutions; then they place a ready solution into their yaml-mode dashboards for advantages like reusing a code, version control, packages. I am not saying that everyone should do it as well.
As a person with dashboard consisting of 7000+ lines if I would have it in the raw configurator (removed all comments and empty lines as they are not allowed either) I see this not only as a code-reuse request but an organization request as well.
I would love to be able to separate button-card- or decluttering-templates and different views as separate files even if I use the GUI configuration.
And since everytime you press the button to show the raw configuration, it has to convert the json-data into yaml, it should be feasable in the conversion step to separate specific json-objects as separate yaml files.