#Problems loading custom button card template

1 messages · Page 1 of 1 (latest)

distant robin
#

I am trying to create a custom button template and call it within a view.

My intention is to use a horizontal custom layout card for a top bar icon display that will populate those icons from a list stored in a sensor attribute. That list will contain the names of the defined template values. I can write all of this.

The problem comes in with being able to access the defined values in the template. I've made a small dashboard and view to show where I am struggling:

https://dpaste.org/0FK8P

You can see from the image that it is not finding the template for the third button. Where am I going wrong?

empty crow
#

Ok, let me take a look at what you are doing. I might have some follow up questions.

nimble sinew
#

Follow this format

#

only one

distant robin
# nimble sinew only one

I don't understand. I am defining in the button template and then calling. icon_template is the name of the template and mediaplayer is the name of the button definition. I have created multiple templates this way before.

empty crow
#

So just to be clear, your plan is to store icon list in the sensor attribute like we do for the intent? For example like this:

#

That would be set by an automation or the device control BP?

distant robin
nimble sinew
distant robin
#
button_card_templates:
    mediaplayer:
      styles:
        card:
          - background-color: transparent
          - border-width: 0px
        icon:
          - color: white
          - height: 90%
      tap_action:
        action: call-service
        service: media_player.volume_mute
        service_data:
          entity_id: media_player.viewassist_office
          is_volume_muted: false
#

Are you saying like this? I know the tab is incorrect but can't change it easily in discord.

#

Yeah this seems to 'fix' it though the icon is not visible but does not give an error. I'll keep at it but I think this is what I was needing.

#
button_card_templates:
  mediaplayer:
    styles:
      card:
        - background-color: transparent
        - border-width: 0px
      icon:
        - color: white
        - height: 90%
    tap_action:
      action: call-service
      service: media_player.volume_mute
      service_data:
        entity_id: media_player.viewassist_livingroom
        is_volume_muted: false

This is what the tempate looks like

#

and I am calling it like this:

                - type: custom:button-card
                  template: mediaplayer

Shouldn't that be enough to get it to display?

#

For fun I changed the background from transparent to blue. Looks like the size is way too small

#

nm.. I'm a dummy and didn't define it. Got it working. This is great! Thank you for pointing out my error