Maintaining consistem complex buttons across several GUI managed dashboards?

Thinks like Mushroom Template for example, where you might have icon colour states for say ranges of fridge temperatures etc and other complex templating setups.

Now how to manage changes to these when copies appear on several dashboards?

Best I can come up with is have an Admin only Master Template Dash that is where buttons are designed and live, and Copy+Paste the button YAML over to all dashboards that use them.

But I was wondering if there was a way to #include the config for one in its entirety from a central store? I don’t think there is, but maybe I missed it…

Or whether anyone had other strategies they use?

ALSO: Why does the lovelace editor have “Cut/Copy” option on the buttons in the GUI but no apparent Paste option anywhere?

Addendum:

Well, so far I’ve come up with this:

Template Sensor to pull from the various sensors that the Bosch Home Connect integration exposes from a washing machine:

- sensor:
    # Washing Machine primary
    # Primary state is a hint to display or hide as Visibility can only be set based on state, not attributes
    - name: "Dash Washer"
      unique_id: dashtemplate_washer
      icon: mdi:washing-machine

      state: >- 
        {%
        set opStateDisplay = 
        { 
          'run': true,
          'delayedstart': true,
          'finished': true,
          'actionrequired': true,
          'error': true,
          'aborting': true,
          'pause': true,
        }
        %}
        {% set displayState = opStateDisplay.get(states.sensor.washy_mcwashface_operation_state.state, false) %}
        {{ displayState }}

      attributes:
        primary: Washer

        secondary: >-
          {%
            set opState = 
            { 
              'run': 'Running',
              'ready': 'Ready to Start',
              'inactive': 'Ready to Start',
              'delayedstart': 'Delayed Start',
              'finished': 'Finished',
              'actionrequired': 'Problem!',
              'error': 'Problem!',
              'aborting': 'Cancelled',
              'pause': 'Paused',
            }
          %}
          {% set primInfo = opState.get(states.sensor.washy_mcwashface_operation_state.state, 'Unknown') %}
          {% set finish = '' %}
          {% set prefix = 'Finish:' %}
          {% if states.sensor.washy_mcwashface_operation_state.state == 'finished' %}
          {% set prefix = 'at' %}
          {% endif %}

          {% if states.sensor.washy_mcwashface_programme_finish_time.state == 'unavailable' %}
          {{ primInfo }}          
          {% else %}
            {{ primInfo }} {{ states.sensor.washy_mcwashface_programme_finish_time.state | as_datetime | as_timestamp | timestamp_custom(prefix + ' %H:%M') }}
          {% endif %}

        icon_colour: >-
          {%
            set opState = 
            { 
              'run': 'yellow',
              'ready': 'green',
              'inactive': 'green',
              'delayedstart': 'yellow',
              'finished': 'blue',
              'actionrequired': 'red',
              'error': 'red',
              'aborting': 'yellow',
              'pause': 'yellow',
            }
          %}
          {% set highlightColour = opState.get(states.sensor.washy_mcwashface_operation_state.state, 'Unknown') %}
          {{ highlightColour }}

        badge_icon: None
        badge_colour: white
        picture: None

And the associated button:

type: custom:mushroom-template-card
secondary: "{{ state_attr(entity, 'secondary') }}"
icon_color: "{{ state_attr(entity, 'icon_colour') }}"
grid_options:
  columns: 12
  rows: 1
primary: "{{ state_attr(entity, 'primary') }}"
layout: horizontal
multiline_secondary: false
fill_container: false
tap_action:
  action: none
hold_action:
  action: none
double_tap_action:
  action: none
visibility:
  - condition: state
    entity: sensor.normalised_washer
    state: "True"
icon: "{{ state_attr(entity, 'icon') }}"
entity: sensor.dash_washer
badge_icon: "{{ state_attr(entity, 'badge_icon') }}"
badge_color: "{{ state_attr(entity, 'badge_colour') }}"
picture: "{{ state_attr(entity, 'picture') }}"

This has the advantage that all the logic is back in one place.

And for things where I want to use this type of button, I can literally copy/paste the button and change the entity name. And probably never have to edit it again, save for visibility and layout, which genuinely might vary from dashboard to dashboard.

Here’s one thing I do… there are probably better ways…

You can store a list of color values in the same way you store custom template macros.

# config/custom_templates/constants.jinja

{% set colors_blue_to_red = [
'#2365b9','#2770ce','#367dd9','#4b8bdd', 
'#4ae854','#edcb44' ,'#f39c12','#d35400',
'#d65548','#c0392b','#81261d','#6c2018',
'#6c2018'] %}

That gives you a gradient of colors you can pull by index from any template.

  - type: template
    double_tap_action:
      action: none
    entity: sensor.average_non_basement_temp
    hold_action:
      action: none
    icon: mdi:home-thermometer
    content: "{{ states('sensor.living_room_temperature')|round(1) }}°F"
    icon_color: >-
      {% set temp = [45, (states(entity)|int(70) // 5) * 5, 110][1] %}
      {% set d = [45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 110] %}
      {% from 'constants.jinja' import colors_blue_to_red %}
      {{ colors_blue_to_red[d.index(temp)] }}
1 Like

Thank you - My question was actually wider that that - it was about maintaining the whole button/tile code across multiple dashboards.

I sort of do something along your lines for certain complex sensors like my Bosch Washer and Dishwasher where there are several sensors feeding in and “state” that I care about is a complex function of those.

For that I make a sensor template with a number of attributes, one of which the icon colour for a template button. That reduces the amount of cruft in the button itself and means certain changes like the function logic and icon colour are set from the sensor template.

Maybe I should take that idea to the logical conclusion and have an attribute for every section in a Mushroom Template - that would mean essentially consistency from a central code block, and very little liklihood of ever needing to manually change the button itself, other than “layout” and “visibility”[1]

[1] I actually reserve the “state” of my sensor template for "if this button can be hidden, make state=True for those times I really would want to see it - eg action, or problem condition. Only because Visibility cannot work on an attribute.

BUT - your post gave me an idea to abstract the colour scheme out of each sensor template to a single place, which would be great for maintaining a consistent theme for colours.

I also prefix all my sensor templates with sensortemplate_ so I can glob exclude these from recorder and any other database logging.

If you click “Add card” you should get a “Paste from Clipboard” option.

1 Like

Not seeing it - I tried and carefully looked - I get a full list of cards, and “Manual (YAML)” at the end.

Weird… That’s where I would have expected to find it…

You have to be in the same session - it doesn’t work across tabs. Also - what version of HA are you running?

1 Like

Oh - same session… Might be that. Was hoping to cut and paste across 2 windows, using one as a “toolbox of master template buttons”.

Never mind, can still do it with slightly more clicks copy/pasting the YAML over.

Version: certainly - it is the latest:

 Core 2025.5.1
Supervisor 2025.05.0
Operating System 15.2
Frontend 20250509.0
1 Like

Yes - you are indeed correct - within the same tab, it does offer “paste from clipboard”. Cheers :slight_smile:

1 Like