d_sellers1

cb mushroom-light-card

Aug 27th, 2024
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 4.91 KB | Source Code | 0 0
  1. type: vertical-stack
  2. cards:
  3.   - type: markdown
  4.     content: >-
  5.       Making a custom:button-card look like a Mushroom Light Card
  6.       (@fredrik_persson_)
  7.     card_mod:
  8.       style: |
  9.        ha-markdown {
  10.           padding: 0 0 0 0 !important;
  11.         }
  12.         ha-card {
  13.          background-color: transparent;
  14.          border: none;
  15.         }
  16.   - type: custom:mushroom-light-card
  17.     entity: light.bedroom_lights
  18.     show_brightness_control: true
  19.   - type: custom:button-card
  20.     entity: light.bedroom_lights
  21.     show_state: true
  22.     state_display: |
  23.      [[[
  24.           if (entity.state === 'on')
  25.             return Math.round(entity.attributes.brightness / 255 * 100) + "%"
  26.           else
  27.             return "Off"
  28.       ]]]
  29.     styles:
  30.       grid:
  31.         - grid-template-areas: '"i n" "i s" "slider slider"'
  32.         - grid-template-rows: 1fr 1fr
  33.         - grid-template-columns: min-content 1fr
  34.         - column-gap: 10px
  35.         - row-gap: 4px
  36.       card:
  37.         - height: 100%
  38.         - padding: 1rem
  39.       name:
  40.         - align-self: end
  41.         - justify-self: start
  42.         - font-weight: 500
  43.         - font-size: 14px
  44.       state:
  45.         - align-self: start
  46.         - justify-self: start
  47.         - font-weight: 400
  48.         - font-size: 12px
  49.         - color: '#9b9b9b'
  50.       img_cell:
  51.         - background: '#2c2c2c'
  52.         - height: 42px
  53.         - width: 42px
  54.         - border-radius: 25px
  55.       icon:
  56.         - color: '#6f6f6f'
  57.         - height: 21px
  58.         - width: 21px
  59.       custom_fields:
  60.         slider:
  61.           - padding: 8px 0
  62.     state:
  63.       - value: 'on'
  64.         styles:
  65.           img_cell:
  66.             - background: '#493416'
  67.           icon:
  68.             - color: '#ff9800'
  69.     hold_action:
  70.       action: more-info
  71.     custom_fields:
  72.       slider:
  73.         card:
  74.           type: custom:my-slider-v2
  75.           entity: light.bedroom_lights
  76.           showMin: true
  77.           styles:
  78.             card:
  79.               - background: none
  80.             container:
  81.               - border-radius: 10px
  82.               - color: yellow
  83.               - overflow: hidden
  84.               - height: 42px
  85.             track:
  86.               - background: |
  87.                  [[[
  88.                     if (entity.state == "on"){
  89.                       return '#493416';
  90.                     } else {
  91.                       return '#2c2c2c';
  92.                     }
  93.                   ]]]
  94.               - border-radius: 10px
  95.             progress:
  96.               - background: |
  97.                  [[[
  98.                     if (entity.state == "on"){
  99.                       return '#ff9800';
  100.                     } else {
  101.                       return '#343537';
  102.                     }
  103.                   ]]]
  104.               - border-radius: 0px
  105.             thumb:
  106.               - background: '#6f6f6f'
  107.               - display: none
  108.   - type: custom:button-card
  109.     entity: null
  110.     show_state: true
  111.     name: This one is using some numbers but not all work right
  112.     icon: |
  113.      [[[
  114.         var vol = parseFloat(states["number.volume"].state);
  115.         if (vol == 0) return 'mdi:volume-mute';
  116.         else if (vol < 33) return 'mdi:volume-low';
  117.         else if (vol < 66) return 'mdi:volume-medium';
  118.         else return 'mdi:volume-high';
  119.       ]]]
  120.     state_display: |
  121.      [[[
  122.           return Math.round(states["number.volume"].state) + "%"
  123.          
  124.       ]]]
  125.     styles:
  126.       grid:
  127.         - grid-template-areas: '"i n" "i s" "slider slider"'
  128.         - grid-template-rows: 1fr 1fr
  129.         - grid-template-columns: min-content 1fr
  130.         - column-gap: 12px
  131.         - row-gap: 4px
  132.       card:
  133.         - height: 100%
  134.         - padding: 1rem
  135.       name:
  136.         - align-self: end
  137.         - justify-self: start
  138.         - font-weight: bold
  139.         - font-size: 14px
  140.       state:
  141.         - align-self: start
  142.         - justify-self: start
  143.         - font-weight: bolder
  144.         - font-size: 12px
  145.         - color: '#9b9b9b'
  146.       img_cell:
  147.         - background: '#493416'
  148.         - height: 42px
  149.         - width: 42px
  150.         - border-radius: 25px
  151.       icon:
  152.         - color: '#ff9800'
  153.         - height: 21px
  154.         - width: 21px
  155.       custom_fields:
  156.         slider:
  157.           - padding: 8px 0
  158.     hold_action:
  159.       action: none
  160.     custom_fields:
  161.       slider:
  162.         card:
  163.           type: custom:my-slider-v2
  164.           entity: number.volume
  165.           showMin: true
  166.           styles:
  167.             card:
  168.               - background: none
  169.             container:
  170.               - border-radius: 10px
  171.               - color: yellow
  172.               - overflow: hidden
  173.               - height: 42px
  174.             track:
  175.               - background: '#493416'
  176.               - border-radius: 10px
  177.             progress:
  178.               - background: '#ff9800'
  179.               - border-radius: 0px
  180.             thumb:
  181.               - background: '#6f6f6f'
  182.               - display: none
  183.  
Advertisement
Add Comment
Please, Sign In to add comment