Is it possible to reuse card?

Is it possible to reuse same card on several places on dashboard? I do not mean duplicate, but create card once and then place it in several places, so if user changes something on the card change is visible in all places?

Hi,
Pretty sure you can achieve this by Editing your dashboard, click on the options : on the bottom right and ‘Duplicate’. Once you do that, same method to move to other dashboards

I don’t think that’s possible if you configure your dashboards via the UI.

But if you use yaml mode then you should be able to do it with using !include statements

1 Like

On my HA duplicating card just creates new card with the same settings but in no way linked or related to original.

Correct. I say no. The person posting about copying just does not understand.

I have a view in one dashboard the master. Lets say im working on building my Roborock interface. I have another dashboard called quick view for my wife that has the same card.

I want to change the master and quickview is changed. I do not want to:

Delete quickview card
Copy master card
Move copy to quickview
Reposition

That is ridiculous at least. Especially when developing things you may do that 20 times.

The answer is simple. Includes in YAML.

As I come from expertise in XML, XSL … YAML people don’t get it.

true, sorry :roll_eyes:

Another option is using a custom:decluttering-card.
When used in a storage mode (I.e. not yaml) - one card’s template may be shared by different views of a same dashboard. In yaml mode - may be used by all dashboards.

True. This is OK but what would be better is like custom:button-card so you can template inside template or have multiple templates. Said differently, I would die for someone to take what works in custom:button-card and make in general and available anywhere. Take for example my button-templates to build out multiple remote controls …

  dtvip:
    variables:
      dtvip: 192.168.2.235
  patio_vizio:
    triggers_update: all
    variables:
      tv: patio_vizio
      ip: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'patio_vizio').ip ]]]
      port: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'patio_vizio').port ]]]
      auth: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'patio_vizio').auth ]]]
      clientaddr: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'patio_vizio').clientAddr ]]]
  office_vizio:
    triggers_update: all
    variables:
      tv: office_vizio
      ip: >-
        [[[ return  states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'office_vizio').ip ]]]
      port: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'office_vizio').port ]]]
      auth: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'office_vizio').auth ]]]
      clientaddr: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'office_vizio').clientAddr ]]]
  kitchen_vizio:
    triggers_update: all
    variables:
      tv: kitchen_vizio
      ip: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'kitchen_vizio').ip ]]]
      port: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'kitchen_vizio').port ]]]
      auth: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'kitchen_vizio').auth ]]]
      clientaddr: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'kitchen_vizio').clientAddr ]]]
  bedroom_vizio:
    triggers_update: all
    variables:
      tv: bedroom_vizio
      ip: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'bedroom_vizio').ip ]]]
      port: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'bedroom_vizio').port ]]]
      auth: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'bedroom_vizio').auth ]]]
      clientaddr: >-
        [[[ return states['sensor.vizio_tvs'].attributes.tvs.find(x=>x.name ==
        'bedroom_vizio').clientAddr ]]]
  dtv_action:
    template:
      - dtvip
    variables:
      clientaddr: bar
      button: foo
    tap_action:
      action: call-service
      service: rest_command.directv_processkey
      service_data:
        ipAddress: '[[[ return variables.dtvip ]]]'
        clientAddr: '[[[ return variables.clientaddr ]]]'
        key: '[[[ return variables.button ]]]'
  dtv_fav:
    template:
      - dtvip
    variables:
      clientaddr: bar
      button: foo
    tap_action:
      action: call-service
      service: rest_command.directv_tune
      service_data:
        ipAddress: '[[[ return variables.dtvip ]]]'
        clientAddr: '[[[ return variables.clientaddr ]]]'
        channel: '[[[ return variables.button ]]]'
  vizio_power:
    tap_action:
      action: call-service
      service: media_player.toggle
      service_data:
        entity_id: '[[[ return ''media_player.'' + variables.tv ]]]'
  vizio_select:
    variables:
      button: foo
    tap_action:
      action: call-service
      service: media_player.select_source
      service_data:
        source: '[[[ return variables.button ]]]'
        entity_id: '[[[ return ''media_player.'' + variables.tv ]]]'
  vizio_action:
    variables:
      codeset: 4
      code: 3
    tap_action:
      action: call-service
      service: rest_command.vizio_processkey
      service_data:
        ip: '[[[ return variables.ip ]]]'
        port: '[[[ return variables.port ]]]'
        auth: '[[[ return variables.auth ]]]'
        codeset: '[[[ return variables.codeset ]]]'
        code: '[[[ return variables.code ]]]'
  vizio_hold_action:
    variables:
      codeset: 4
      code: 3
      repeat: 500
    hold_action:
      repeat: '[[[ return variables.repeat ]]]'
      action: call-service
      service: rest_command.vizio_processkey
      service_data:
        ip: '[[[ return variables.ip ]]]'
        port: '[[[ return variables.port ]]]'
        auth: '[[[ return variables.auth ]]]'
        codeset: '[[[ return variables.codeset ]]]'
        code: '[[[ return variables.code ]]]'
  broadlink_action:
    show_name: false
    variables:
      command: Vol+
    tap_action:
      action: call-service
      service: remote.send_command
      service_data:
        entity_id: entity
        device: '[[[ return variables.device ]]]'
        command: '[[[ return variables.command ]]]'
  firetv_action:
    variables:
      button: foo
    tap_action:
      action: call-service
      service: androidtv.adb_command
      service_data:
        command: '[[[ return variables.button ]]]'
        entity_id: media_player.deck_firestick
  firetv_select:
    variables:
      button: foo
    tap_action:
      action: call-service
      service: media_player.select_source
      service_data:
        source: '[[[ return variables.button ]]]'
        entity_id: media_player.deck_firestick
  zone_button:
    styles:
      card:
        - background: white
        - color: black
        - height: 40px
        - cursor: none
        - border-radius: 15px
  label_button_height:
    styles:
      card:
        - height: 43px
  label_button_style:
    template:
      - label_button_height
    styles:
      card:
        - border: none
        - background: none
        - box-shadow: none
        - cursor: none
  icon_button:
    size: 32px
  white_button:
    color_type: card
    color: white
    template:
      - label_button_height
  theme_button:
    template:
      - label_button_height
  upleft_radius:
    styles:
      card:
        - border-radius: 30px 5px 5px 5px
  upright_radius:
    styles:
      card:
        - border-radius: 5px 30px 5px 5px
  botleft_radius:
    styles:
      card:
        - border-radius: 5px 5px 5px 30px
  botright_radius:
    styles:
      card:
        - border-radius: 5px 5px 30px 5px
  all_radius:
    styles:
      card:
        - border-radius: 15px

Which reduces buttons on my remotes to something like this:

                          - type: custom:button-card
                            icon: mdi:replay
                            template:
                              - icon_button
                              - kitchen_vizio
                              - vizio_action
                            variables:
                              codeset: 4
                              code: 0
                          - type: custom:button-card
                            icon: mdi:arrow-up-circle
                            template:
                              - icon_button
                              - kitchen_vizio
                              - vizio_action
                            variables:
                              codeset: 3
                              code: 8
                          - type: custom:button-card
                            icon: mdi:menu
                            template:
                              - icon_button
                              - kitchen_vizio
                              - vizio_action
                            variables:
                              codeset: 4
                              code: 8

And with minimal code, I can build these, expand them for every remote in the house. (5 TVs, 5 DirecTV boxes, some with alternate sound systems attached, etc.)

Since I have converted many things to mushrrom in my interface, I would love to have these done with mushroom. But the code would explode 100 fold.

This is a great tip that I will try as I am a big fan of custom:button-card. But are these templates defined in configuration.yaml? That requires a HA restart every time you make a change (to the template)?

No, button card templates are defined in YAML of the dashboard itself. For instance, my TV Remote dashboard looks like this and shows the use of wallpanel, decluttering-templates and button_card_templates as well as the view for the page:

NOTE: I have considerably collapsed the tree view of the YAML for understanding where they go. I am currently in the process and have 90% finished all the code behind for decluttering of the whole remote (only DirecTV favorites remain to be done). Now the entire remote control is just this will all the code in decluttering:

      - type: custom:decluttering-card
        template: remote_control
        variables:
          - vizio: patio_vizio

Now that is valuable as one change inside the entire remote applies to all my TV remotes.