@4integration,
You can do it without templates. The templates just make it easier to re-use common parts of the buttons. When getting started with the custom button card, I recommend trying your ideas without templates first to see if they work as expected, then try making templates to get the same result.
As a non-template example, you can make 6 buttons based on this, with each one using a different - value:
setting based on the values available in your input_select:
type: 'custom:button-card'
entity: input_select.albin_rgbw
styles:
card:
- background-color: 'gray'
state:
- value: 'None' # different value here for each copy of the button
styles:
card:
- background-color: 'green'
In that example, the gray style is default to use when the value doesn’t match, and the green style is what to use when the value matches.
To turn the above into a template, you would do something like this in your raw dashboard yaml:
button-card-templates:
radio_albin_rgbw:
entity: input_select.albin_rgbw
styles:
card:
- background-color: gray
state:
- id: on_state # important id mapping for templated states
styles:
card:
- background-color: green
And then your 6 buttons in your dashboard card can use the template:
(I put them in a horizontal-stack as a container)
type: horizontal-stack
cards:
- type: 'custom:button-card'
template: radio_albin_rgbw
state:
- id: on_state # matches the id mapping in the template
value: 'None' # defines the value to match
- type: 'custom:button-card'
template: radio_albin_rgbw
state:
- id: on_state
value: 'Fireplace'
- type: 'custom:button-card'
template: radio_albin_rgbw
state:
- id: on_state
value: 'Storm'
- type: 'custom:button-card'
template: radio_albin_rgbw
state:
- id: on_state
value: 'Rainbow'
- type: 'custom:button-card'
template: radio_albin_rgbw
state:
- id: on_state
value: 'Aurora'
- type: 'custom:button-card'
template: radio_albin_rgbw
state:
- id: on_state
value: 'LAPD'
NOTE: the - id: on_state
is important for templated states so they can be matched properly between the button and the template, otherwise you end up with the state lists of both being concatenated instead of merged. It’s only needed when using templates with states.
NOTE 2: if you want the template to be useful for different entities you can either move the entity property to the buttons instead of having it on the template, or you can have a base template plus a template for each entity.
Example of multiple templates:
button-card-templates:
radio_button: # base template
styles:
card:
- background-color: gray
state:
- id: on_state
styles:
card:
- background-color: green
radio_albin_rgbw: # template for your button to use
template: radio_button # refers to the base template
entity: input_select.albin_rgbw # identifies the entity
In that example, the radio_albin_rgbw
template refers to the radio_button
template. Your buttons for the input_select.albin_rgbw
would refer to radio_albin_rgbw
.
Again, templates are optional. They just give you more organization of common parts.