Advertisement
fablav

light_button_rgb

Sep 2nd, 2024 (edited)
229
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 5.35 KB | Software | 0 0
  1. button_card_templates:
  2.   light_button_rgb:
  3.     variables:
  4.       background_off: rgba(220, 221, 247,0.8)
  5.     name: |
  6.      [[[
  7.         var bri = states[entity.entity_id].attributes.brightness
  8.         if (states[entity.entity_id].state === 'on')
  9.         return Math.round((bri ? bri : '0')/255*100) + '%'
  10.         else return 'Luce'
  11.       ]]]
  12.     color_type: card
  13.     show:name: true
  14.     show_icon: true
  15.     show_label: true
  16.     show_state: false
  17.     tap_action:
  18.       action: toggle
  19.     hold_action:
  20.       action: more-info
  21.     custom_fields:
  22.       br:
  23.         card:
  24.           type: custom:my-slider-v2
  25.           entity: '[[[ return entity.entity_id ]]]'
  26.           mode: brightness
  27.           styles:
  28.             container:
  29.               - overflow: visible
  30.             card:
  31.               - border-radius: 100px
  32.               - height: 20px
  33.               - padding: 0px 17px
  34.               - border: |
  35.                  [[[
  36.                     if (states[entity.entity_id].state === 'unavailable')
  37.                     return 'transparent'
  38.                   ]]]
  39.               - background: |
  40.                  [[[
  41.                     if (states[entity.entity_id].state === 'on')
  42.                     return 'linear-gradient(90deg, rgba(211,161,31,1) 0%, rgba(255,211,94,1) 100%)'
  43.                     else if (states[entity.entity_id].state === 'off')
  44.                     return 'linear-gradient(90deg, rgba(211,161,31,0.5) 0%, rgba(255,211,94,0.5) 100%)'
  45.                     else return 'transparent'
  46.                   ]]]
  47.             track:
  48.               - overflow: visible
  49.               - background: none
  50.               - padding: 0 4px 0 5px
  51.             progress:
  52.               - background: none
  53.             thumb:
  54.               - background: |
  55.                  [[[
  56.                     if (states[entity.entity_id].state === 'on')
  57.                     return 'white'
  58.                     else if (states[entity.entity_id].state === 'off')
  59.                     return 'rgba(255,255,255,0.3)'
  60.                     else return 'transparent'
  61.                   ]]]
  62.               - top: 0px
  63.               - right: 0px
  64.               - height: 18px
  65.               - width: 18px
  66.               - border-radius: 100px
  67.       k:
  68.         card:
  69.           type: custom:my-slider-v2
  70.           entity: '[[[ return entity.entity_id ]]]'
  71.           mode: temperature
  72.           styles:
  73.             container:
  74.               - overflow: visible
  75.             card:
  76.               - border-radius: 100px
  77.               - height: 20px
  78.               - top: 5px
  79.               - padding: 0 17px
  80.               - border: |
  81.                  [[[
  82.                     if (states[entity.entity_id].state === 'unavailable')
  83.                     return 'transparent'
  84.                   ]]]
  85.               - background: |
  86.                  [[[
  87.                     if (states[entity.entity_id].state === 'on')
  88.                     return 'linear-gradient(90deg, rgba(177,197,255,1) 0%, rgba(255,175,131,1)100%)'
  89.                     else if (states[entity.entity_id].state === 'off')
  90.                     return 'linear-gradient(90deg, rgba(177,197,255,0.5) 0%, rgba(255,175,131,0.5)100%)'
  91.                     else return 'transparent'
  92.                   ]]]
  93.             track:
  94.               - overflow: visible
  95.               - background: none
  96.               - padding: 0 4px 0 5px
  97.             progress:
  98.               - background: none
  99.             thumb:
  100.               - background: |
  101.                  [[[
  102.                     if (states[entity.entity_id].state === 'on')
  103.                     return 'white'
  104.                     else if (states[entity.entity_id].state === 'off')
  105.                     return 'rgba(255,255,255,0.3)'
  106.                     else return 'transparent'
  107.                   ]]]
  108.               - top: 0px
  109.               - right: 0px
  110.               - height: 18px
  111.               - width: 18px
  112.               - border-radius: 100px
  113.     state:
  114.       - value: 'off'
  115.         styles:
  116.           icon:
  117.             - color: black
  118.           name:
  119.             - color: black
  120.           label:
  121.             - color: black
  122.           card:
  123.             - background: '[[[ return variables.background_off ]]]'
  124.       - value: 'on'
  125.         color: auto
  126.         styles:
  127.           icon:
  128.             - color: black
  129.           name:
  130.             - color: black
  131.           label:
  132.             - color: black
  133.       - value: unavaliable
  134.         color: auto
  135.     styles:
  136.       grid:
  137.         - grid-template-areas: '"n i" "l l" "br br" "k k"'
  138.         - grid-template-columns: 1fr 1fr
  139.         - grid-template-rows: min-content min-content 1fr
  140.       icon:
  141.         - width: 30px
  142.       img_cell:
  143.         - justify-self: end
  144.         - width: 40px
  145.         - height: 40px
  146.         - bottom: 10px
  147.         - right: 5px
  148.       name:
  149.         - justify-self: start
  150.         - padding-bottom: 5px
  151.         - padding-left: 10px
  152.         - font-size: 20px
  153.         - line-height: 30px
  154.         - font-weight: 600
  155.       label:
  156.         - justify-self: start
  157.         - padding-left: 10px
  158.         - font-size: 14px
  159.         - font-weight: 500
  160.         - margin-bottom: 10px
  161.         - margin-top: '-10px'
  162.       br:
  163.         - bottom: 14px
  164.       card:
  165.         - height: 140px
  166.         - padding: 20px
  167.         - border-radius: 25px
  168.         - '--mdc-ripple-color': yellow
  169.         - '--mdc-ripple-press-opacity': 0.5
Tags: ha
Advertisement
Comments
  • fablav
    176 days (edited)
    Comment was deleted
  • fablav
    163 days
    # YAML 0.38 KB | 0 0
    1. N.B.
    2. Questa non é una card, ma un template riutilizzabile per più entità luci RGB.
    3. Pertanto va inserito nell'editor di configurazione testuale.
    4. Aggiungere solo dopo in plancia la card specificando entità, label e template.
    5.  
    6. Per esempio la luce dimmerabile del soggiorno sarà:
    7. type: custom:button-card
    8. entity: light.luce_soggiorno
    9. label: Soggiorno
    10. template: light_button_rgb
Add Comment
Please, Sign In to add comment
Advertisement