I have a fairly complicated whole-house setup with a lot of devices, and more are likely.
To make things easier for family members, I’ve created a “Personal” dashboard, where each person gets their own pane, made visible only to them, and configured with the things they’re most likely to use.
Turns out there’s quite a bit of duplication — everyone wants quick access to the light and climate controls for the living room, for example. Rather than cutting and pasting, is there a way to simply define a card as a mirror of (or, conceptually, a “symbolic link” to) another card?
That will make a copy of the card. But after making the copy if you edit one of them it does not change the other.
Imagine you have a weather card that you use in all your dashboards and then being able to just edit the “master copy” and all the cards in all the other dashboards get updated too. Rather than having to edit each and every copy individually.
I know a number of custom cards use templates in the dashboard to set up default attributes for multiple card instances. I wonder if it’s possible to do something similar with an overly specific template which is basically an entire card.
But also, I know those templates go in the root of the dashboard file, and I’m not sure if you’re actually looking for something to span across multiple dashboards, or just tabs (which could be hidden per user).
I’ve been using shell scripts to assemble Lovelace dashboards based on data definitions.
So for this use case, define those common cards once, and use the shell scripts to put them into the dashboards. Yes, you’ve duplicated them, but since they are derived from the common, you can change the common and rerun the scripts.
Very cool Yeah I’ve though that python would be better for assembling the cards. Shell script is non optimal. Post a links to your example? I have a card assembly project coming up.
Tips?
I put the source and the output into a github private repo. This way when I change stuff, I can see the differences in the output before deploying into HASS
I generate a lot of packages and automations from scripts. Here’s an example for zwave health. GitHub - PeteRager/hass_templates One problem I have is the generated packages / automations end up in the same HASS folder as the non generated ones which creates clutter. Ideally I’d have a separate folder structure for generated vs non-generated. This way you could delete the entire content of generated and regenerate all.
That’s interesting. I hadn’t come across that, or any of the other (decluttering-card,lovelace_gen,or YAML node anchors) mentioned therein. I’ll have to explore them some more.
My templating approach is similar to !include, but I allow includes that reference another piece of yaml code (like a sub-hierarchy), and I flatten everything into a target .yaml file.
Here, I’ve defined two templates. (I have more but have omitted a bunch to make this post easier to understand.) Templates can even reference other templates. So the battery_custom_button template references the generic_custom_button template.
In my dashboard’s YAML, I have:
Note how each button is only 4 lines long but has all the settings from the template. Any settings in the defined within the button override whatever is in the template.So, even though the template has a defined entity, the entity for the button is used. (Also, the battery template does not have a border around the card.) Only small adjustments are needed for each card and by modifying the template it is way easier to make changes without having to adjust each and every card individually.
This is the result:
@kctx I would buy you a coffee if you could finish this! I have been considering having a touchpad at the doors to each room and a cutoff from my dashboard representing each of my room buttons but without the ability to mirror part of the dashboard it will only cause plenty of problems.
Does anyone know if there’s a way to make this work inside another card? I’ve got an Alexa Media Player card wit 50 radio stations - mirrored for each Alexa device at home. Is there a way to change on set of code when the radio stations change instead of 5?