Custom Button Card Templates and Jinja Macros

Hi,

I am working on the software for a large Home Assistant installation. There will be custom dashboards in each room to control lights, shutters, etc and whatever else as time goes on. This results in a lot of repetitive code. I am an experienced software developer but still somewhat new to HA.

  1. After much head knocking, I have finally begun (emphasize begun) to crack templates in Custom Button Card. I have placed them in the Raw Configuration Editor. This requires that I add them to each dashboard and deal with the consequences of maintaining a lot of duplicate code, Is there any way to add them a central place in HA where all the dashboards could access them?

  2. Jinja macros are quite useful. Is there a way or will there be a way in the future to access Jinja templates in custom button card? This would eliminate a lot of duplicate scripts in my installation. I understand that custom button card uses Javascript. Will there be some kind of translator?

The HA Community is amazing in the tools provided and the information shared.

Thank you.

For a large installation and for someone with dev skills I’d say do as much as possible via YAML. This will allow you to use YAML anchors.

The custom button card supports its own kind of templates.

Also look at card-mod and its themes.

Thanks for your suggestions. I am still learning daily.

The work I am doing currently is tocused on the user interface. Look and feel are critical. As well as simplicity. I am finding a combination of layout card/grid and custom button card gives me good control over the entire tablet screen.

I am using Fully Kiosk Browser (provisioned) to shield the user from Android layers and the HACs Kiosk plug-in to shield the user from the HA sidebar and header bar. I also avoid More-Info as it can lead the user into to many rabbit holes. This means I have to manually create navigation controls and sub views for setting brightness, etc.

I am trying to create something that will be maintainable by someone other than me.

Bert – (only half jokingly) If you figure out how to do this in HA please share! :wink:
-David