原来的代码如下:
type: custom:stack-in-card
title: null
mode: vertical
cards:
- type: custom:layout-card
layout_type: grid
layout:
grid-template-columns: 25% 25% 50%
grid-gap: 0px;
cards:
- type: custom:mushroom-template-card
entity: '{{ state_attr(''sensor.important3days'', ''date'') }}'
primary: |-
{% if (state_attr('sensor.important3days','important1')) != None %}
{{ state_attr('sensor.important3days','important1').split(",")[0] }}
{% endif %}
secondary: ''
card_mod:
style: |
ha-card {
box-shadow: none;
margin: -4px -7px;
text-align: center;
background: none;
}
我是从数据库获取到的数据,有啥办法能动态生成卡片呢?
type: custom:stack-in-card
title: null
mode: vertical
cards:
- type: custom:layout-card
layout_type: grid
layout:
grid-template-columns: 25% 25% 50%
grid-gap: 0px;
cards: |
[[[
return `- type: custom:mushroom-template-card
entity: '{{ state_attr(''sensor.important3days'', ''date'') }}'
primary: |-
{% if (state_attr('sensor.important3days','important1')) != None %}
{{ state_attr('sensor.important3days','important1').split(",")[0] }}
{% endif %}
secondary: ''
card_mod:
style: |
ha-card {
box-shadow: none;
margin: -4px -7px;
text-align: center;
background: none;
}`
]]]
这样又不对
|