I have a floorplan laid out (using picture-elements) as a custom card to control core parts of the house. However, I want to use this on multiple different dashboards.
Currently I am duplicating the floorplan code in 3 different places. Is there a way to simplify this duplication?
I am hoping to have something like one version in a separate lovelace.yaml and some sort of include: function to include that in the other dashboards? I tried this using iframe cards, but it was a bit slow to load.
I was hoping to re-use a specific card rather than a full ‘view’. Something more like this:
cards:
- !include floorplan.yaml
Any suggestions, or is a ‘webpage card’ the only real option for this?
edit
When I try this approach to call a card from a separate file, I get this error. It’s a ‘no card type configured’ even though the error is clearly showing it’s picked up all the right content.
Keep in mind that changes to files included from ui-lovelace.yaml won’t be recognized unless you also change/touch ui-lovelace.yaml. Because of this quirk, I generally avoid using !includes for anything that changes regularly. I’ve used it successfully for less than a full view - what indentation does your included file have? In my case, I think I had something like cards: !include cards.yaml, and that’s different from what you’re doing.
Thanks for the heads up on the refresh thing. I didn’t understand what you meant until I got it working and found it had cached the old include: card content and wouldn’t update unless I edited the main lovelace.yaml. Suddenly the penny dropped.
Glad it’s working now. Yeah, I spent quite a long time puzzling over why my changes weren’t reflected in the UI and eventually found a forum post about it. I could probably set up a macro or something in VSCode to automate the “touch”, but I just generally avoid includes for Lovelace.
Another gotcha with includes is that YAML anchors are file-scope, so if you try to collect a bunch of YAML anchors in a separate file for instantiation elsewhere, it won’t work.
Given the limitations I think I’ll only use it for the floorplan, as that is over 1000 does lines and was duplicated twice in my main dashboard (small view and selectable large view) and again on other dashboards for specific devices.