『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 435|回复: 0

[求助] 有啥方法能动态生成card

[复制链接]

20

主题

136

帖子

827

积分

高级会员

Rank: 4

积分
827
金钱
691
HASS币
0
发表于 2024-7-15 18:38:34 | 显示全部楼层 |阅读模式
原来的代码如下:
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;
            }`
      ]]]
这样又不对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-12-23 15:59 , Processed in 0.047245 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表