hungheo 发表于 2025-6-12 21:01
能达到效果就行吧
mushroom card和ha自带的卡片都是一样的,支持jinja2模板,但仅能对预设的变量进行值的 ...
受教了。还有一个问题,原生徽章还能显示一些状态值,比如我看实体有个percentage属性,原生徽章可以在UI设置界面添加,现在我也想在button card加进来,该如何添加实现跟原生一样的效果呢?问了下AI,但效果不太理想,代码小白,能否再帮我补完一下代码?
type: custom:button-card
entity: fan.zhimi_cn_70713307_v3_s_2_fan
show_state: true
show_label: false
name: 风扇
label: 风扇
icon: mdi:fan
tap_action:
action: toggle
extra_styles: |
@keyframes spin {
0% {transform: rotate(0deg);}
100% {transform: rotate(360deg);}
}
styles:
grid:
- grid-template-areas: |
"i n"
"i s"
- grid-template-columns: 16px 1fr
- grid-template-rows: 17px 17px
- column-gap: 7px
- row-gap: 0px
card:
- height: 36px
- border-radius: 18px
- padding: 0px 15px 0px 10px
name:
- font-size: 10px
- justify-self: flex-start
- align-self: center
- margin-top: 1.5px
- color: "#707070"
- font-weight: 450
state:
- font-size: 12px
- font-weight: 500
- justify-self: flex-start
- align-self: center
- margin-bottom: 8px
icon:
- width: 18px
- color: |
[[[return entity && entity.state == "on" ? "green" : "grey" ]]]
- animation: >
[[[return entity && entity.state == "on" ? "spin 1s linear infinite"
: "" ]]]
|