Advertisement
shlomki

climate-button template

Dec 7th, 2021
747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.06 KB | None | 0 0
  1. button_card_templates:
  2.   climate-button:
  3.     variables:
  4.       var_name: window_entity_ids
  5.       var_name2: temperature_monitor_entity_id
  6.     tap_action:
  7.       action: toggle
  8.     styles:
  9.       card:
  10.         - height: 105px
  11.       name:
  12.         - padding-bottom: 10px
  13.       grid:
  14.         - position: relative
  15.       label:
  16.         - font-size: 10px
  17.       custom_fields:
  18.         window_open:
  19.           - position: absolute
  20.           - left: 65%
  21.           - top: 5%
  22.           - height: 20px
  23.           - width: 20px
  24.           - visibility: |
  25.              [[[
  26.                 if (variables.window_entity_ids != null) {
  27.                   if (Array.isArray(variables.window_entity_ids)) {
  28.                     for (const entity of variables.window_entity_ids) {
  29.                       if (states[entity].state == "on") return "visible";
  30.                     }
  31.                   } else {
  32.                     if (states[variables.window_entity_ids].state == "on") return "visible";
  33.                   }
  34.                 }
  35.  
  36.                 return "hidden";
  37.               ]]]
  38.     size: 33%
  39.     hold_action:
  40.       action: navigate
  41.       navigation_path: /lovelace/ac
  42.     state:
  43.       - value: 'off'
  44.         color: rgb(68, 115, 158)
  45.       - value: fan_only
  46.         color: rgb(253, 216, 53)
  47.     custom_fields:
  48.       window_open: >
  49.         [[[ return '<ha-icon icon="mdi:window-open" style="width: 16px;
  50.         height:16px; color: red;"></ha-icon>'; ]]]
  51.    show_label: true
  52.    label: |-
  53.      [[[ let monitor = '';
  54.          if ('temperature_monitor_entity_id' in variables) {
  55.            monitor = states[variables.temperature_monitor_entity_id].state;
  56.            monitor = monitor.replace('Ok', '').replace('Cold', 'turquoise').replace('Hot', 'red');
  57.          }
  58.          return '<div>' + entity.attributes.fan_mode + ' ' + entity.attributes.temperature + '°</div><div style="color: ' + monitor + '">' +
  59.          entity.attributes.current_temperature + '°' + ( user.name === 'Shlomi' ? ' | ' + entity.attributes.current_humidity + '%' : '' )  + '</div>'; ]]]
  60.  
  61.  
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement