Advertisement
dykandDK

HA - YAML - Custom:button-cards for garbage collection

May 15th, 2025
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.82 KB | None | 0 0
  1. ===========================
  2. Example 1: Auto-entities
  3. with background pictures
  4. ===========================
  5. type: custom:auto-entities
  6. card:
  7.   square: false
  8.   type: grid
  9.   columns: 4
  10. card_param: cards
  11. filter:
  12.   include:
  13.     - entity_id: sensor.affalddk_*
  14.       state: < 34
  15.       options:
  16.         type: custom:button-card
  17.         layout: horizontal
  18.         state_display: |
  19.          [[[ var d=entity.state;
  20.             if (d==0) {return "I dag"}
  21.             if (d==1) {return "I morgen"}
  22.             if (d>1) {return d+" dage"}
  23.           ]]]
  24.         name: |
  25.          [[[ return entity.attributes.name; ]]]
  26.         styles:
  27.           grid:
  28.             - grid-template-areas: "\"s\" \"l\" \"n\""
  29.             - grid-template-columns: 1fr
  30.             - grid-template-rows: 1fr 10fr 1fr
  31.           state:
  32.             - background-color: rgba(0, 0,0, 0.3)
  33.             - width: 100%
  34.             - line-height: 50px
  35.             - text-align: center
  36.             - font-size: 22pt
  37.             - color: white
  38.             - display: inline-block
  39.             - vertical-align: center
  40.           name:
  41.             - background-color: rgba(0, 0,0, 0.3)
  42.             - padding-left: 0px
  43.             - width: 100%
  44.             - line-height: 50px
  45.             - text-align: center
  46.             - font-size: 14pt
  47.             - color: white
  48.             - display: inline-block
  49.             - vertical-align: top
  50.           card:
  51.             - background-size: cover
  52.             - background-position: center
  53.             - background-image: |
  54.                [[[
  55.                     var txt=entity.attributes.entity_picture;
  56.                     return "url(" + txt + ")";
  57.                 ]]]
  58.         tap_action:
  59.           action: more-info
  60.         show_entity_picture: false
  61.         show_state: true
  62.         show_name: true
  63.         show_image: false
  64.         show_label: false
  65.         show_icon: false
  66.         aspect_ratio: 1/1
  67.   exclude:
  68.     - entity_id: sensor.affalddk_*_naeste_afhentning
  69.     - entity_id: sensor.*tekstil*
  70. sort:
  71.   method: state
  72.   numeric: true
  73.  
  74. ===========================
  75. Example 2: Single card with
  76. entity pictures
  77. ===========================
  78. type: custom:button-card
  79. entity: sensor.affalddk_street_pap
  80. layout: icon_name_state2nd
  81. name: |
  82.  [[[ return entity.attributes.name; ]]]
  83. label: |
  84.  [[[ var d=entity.state;
  85.       if (d==0) {return "I dag"}
  86.       if (d==1) {return "I morgen"}
  87.       if (d>1) {return ""+d+" dage"}
  88.   ]]]
  89. styles:
  90.   name:
  91.     - justify-self: start
  92.     - font-size: 14pt
  93.     - padding-top: 10px
  94.   label:
  95.     - justify-self: start
  96.     - font-size: 20pt
  97.     - font-weight: 470
  98.   card:
  99.     - background-color: rgba(3, 169, 244, 0.2)
  100. tap_action:
  101.   action: more-info
  102. show_state: false
  103. show_name: true
  104. show_image: false
  105. show_label: true
  106. show_icon: true
  107. show_entity_picture: true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement