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

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

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

[复制链接]

20

主题

135

帖子

797

积分

高级会员

Rank: 4

积分
797
金钱
662
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-11-23 08:13 , Processed in 0.164037 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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