-
-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Is your feature request related to a problem? Please describe.
I would like to define a map of properties to customize how a card is shown. In my example I use the layout card to customize layouting, but I want to be able to dynamically set which cards are rendered.
Apparently the <<:
operator right now is processed before the variables are processed. So in my example below, yaml processes this:
- <<: "[[entity]]"
instead of this:
- <<:
type: tile
entity: cover.e05_blinds
Describe the solution you'd like
Add support for the <<:
operator for variables. This way you can specify defaults for a card, and extend the defaults with an arbitrary object.
Describe alternatives you've considered
I would have to specify each and every attribute as a variable. As I want to be able to use any card type, I would have to go over all properties I want and specify them as variables.
Additional context
Template
default:
- entity:
type: card
card:
type: custom:vertical-stack-in-card
foo: &foo "[[entity]]"
cards:
- type: custom:layout-card
layout_type: custom:grid-layout
layout:
margin: -4px -4px -8px
padding: 0
card_margin: 0
grid-template-columns: "1fr 50px 50px 50px 12px"
grid-template-rows: auto
grid-template-areas: |
"main e1 e2 e3 ."
cards:
- type: tile
entity: light.e05_light
view_layout:
grid-area: main
- "[[entity]]" # works
- <<: "[[entity]]" # doesn't work
- *foo # works
- <<: *foo # doesn't work
view_layout:
grid-area: e3
Usage
type: custom:decluttering-card
template: entity-controls
variables:
- entity:
type: tile
entity: light.e05_light
Edit: If the yaml processing cannot be deferred, maybe a special syntax for variables can be added, <<: [[entity]]
. The deepReplace
function can then spread the object onto the config.