Advertisement
Guest User

Untitled

a guest
Feb 19th, 2025
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.04 KB | None | 0 0
  1. type: custom:button-card
  2. entity: sensor.dishwasher_operation_state
  3. name: Dishwasher
  4. show_label: true
  5. tap_action:
  6. action: none
  7. hold_action:
  8. action: none
  9. double_tap_action:
  10. action: none
  11. icon: mdi:dishwasher
  12. state:
  13. - value: Ready
  14. label: Idle
  15. styles:
  16. custom_fields:
  17. bar:
  18. - display: none
  19. stat1:
  20. - display: none
  21. stat2:
  22. - visibility: hidden
  23. stat3:
  24. - visibility: hidden
  25. - value: "Off"
  26. label: "Off"
  27. styles:
  28. custom_fields:
  29. bar:
  30. - display: none
  31. stat1:
  32. - display: none
  33. stat2:
  34. - visibility: hidden
  35. stat3:
  36. - visibility: hidden
  37. styles:
  38. card:
  39. - padding: 20px
  40. - height: 180px
  41. - font-family:'Montserrat', sans-serif
  42. - font-size: 16px
  43. grid:
  44. - grid-template-areas: "\"i program\" \"n stat2\" \"bar bar\" \"stat1 stat3\""
  45. - grid-template-columns: 1fr 1fr
  46. - grid-template-rows: 70px min-content 40px min-content
  47. name:
  48. - justify-self: start
  49. - font-size: 16px
  50. - font-weight: 500
  51. label:
  52. - justify-self: start
  53. - font-size: 16px
  54. - font-weight: 500
  55. icon:
  56. - width: 36px
  57. img_cell:
  58. - justify-self: start
  59. - align-self: start
  60. - width: 36px
  61. - height: 36px
  62. custom_fields:
  63. program:
  64. - justify-self: end
  65. - align-self: end
  66. - padding-bottom: 6px
  67. - font-size: 16px
  68. - font-weight: 500
  69. - visibility: >
  70. [[[ return states['switch.dishwasher_power'].state !== 'off' ?
  71. 'visible' : 'hidden'; ]]]
  72. stat1:
  73. - justify-self: start
  74. - font-size: 12px
  75. - opacity: 0.7
  76. stat2:
  77. - justify-self: end
  78. - font-size: 16px
  79. - font-weight: 500
  80. - visibility: >
  81. [[[ return states['switch.dishwasher_power'].state !== 'off' ?
  82. 'visible' : 'hidden'; ]]]
  83. stat3:
  84. - justify-self: end
  85. - font-size: 12px
  86. - opacity: 0.7
  87. - visibility: |
  88. [[[
  89. var powerState = states['switch.dishwasher_power'].state;
  90. if (powerState === 'off') {
  91. return 'visible'; // Keep stat3 visible when power is off
  92. }
  93. var progress = states['sensor.dishwasher_program_progress'].state;
  94. if (progress === 'unavailable' || progress === 'unknown' || progress === '') {
  95. return 'visible'; // Show stat3 as "Ready" when power is on and progress is empty
  96. }
  97. return 'visible'; // Show progress percentage otherwise
  98. ]]]
  99. bar:
  100. - justify-self: start
  101. - width: 100%
  102. - border-radius: 6px
  103. - background: var(--slider-color)
  104. - height: 16px
  105. custom_fields:
  106. bar: |
  107. [[[
  108. var state = parseFloat(states['sensor.dishwasher_program_progress'].state);
  109. if (isNaN(state)) { state = 0; } // Ensure it defaults to 0 if the state isn't a valid number
  110. return `<div style="background: var(--slider-color); border-radius: 6px; width: 100%; height: 16px;">
  111. <div style="background: var(--color-blue); border-radius: 6px; height: 16px; width: ${state}%;"></div>
  112. </div>`;
  113. ]]]
  114. program: |
  115. [[[
  116. var powerState = states['switch.dishwasher_power'].state;
  117. var program = states['select.dishwasher_active_program'].state;
  118. var programLabels = {
  119. "dishcare_dishwasher_program_eco_50": "Eco",
  120. "dishcare_dishwasher_program_auto_2": "Auto",
  121. "dishcare_dishwasher_program_intensiv_70": "Heavy",
  122. "dishcare_dishwasher_program_quick_65": "Express 65°",
  123. "dishcare_dishwasher_program_night_wash": "Silent",
  124. "dishcare_dishwasher_program_machine_care": "Machine Care",
  125. "dishcare_dishwasher_program_pre_rinse": "Pre-rinse"
  126. };
  127.  
  128. // If the dishwasher is on but no program is running, show "Idle"
  129. if (powerState !== 'off' && (!program || program === 'unavailable' || program === 'unknown')) {
  130. return "Idle";
  131. }
  132.  
  133. return programLabels[program] || program;
  134. ]]]
  135. stat1: |
  136. [[[
  137. // Icons for rinse aid and salt status
  138. var rinseAidState = states['sensor.dishwasher_rinse_aid_nearly_empty'].state;
  139. var saltState = states['sensor.dishwasher_salt_nearly_empty'].state;
  140.  
  141. // Set the icon color based on state
  142. var rinseAidColor = rinseAidState === 'present' ? 'red' : 'gray';
  143. var saltColor = saltState === 'present' ? 'red' : 'gray';
  144.  
  145. return `
  146. <span style="color: ${rinseAidColor}; margin-right: 4px;">
  147. <ha-icon icon="fapro:sparkles" style="width: 16px; height: 16px;"></ha-icon>
  148. </span>
  149. <span style="color: ${saltColor};">
  150. <ha-icon icon="fapro:salt-shaker" style="width: 16px; height: 16px;"></ha-icon>
  151. </span>
  152. `;
  153. ]]]
  154. stat2: |
  155. [[[
  156. var finishTime = states['sensor.dishwasher_remaining_program_time'].state;
  157.  
  158. // If no program is running or finish time is unavailable, return an empty string
  159. if (!finishTime || finishTime === 'unavailable' || finishTime === 'unknown') {
  160. return "";
  161. }
  162.  
  163. var time = new Date(finishTime);
  164. var hours = time.getHours();
  165. var minutes = time.getMinutes();
  166. return 'Finished at ' + (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
  167. ]]]
  168. stat3: |
  169. [[[
  170. var powerState = states['switch.dishwasher_power'].state;
  171. if (powerState === 'off') {
  172. return "Off"; // Display "Off" when the power is off
  173. }
  174.  
  175. var progress = states['sensor.dishwasher_program_progress'] ? states['sensor.dishwasher_program_progress'].state : 'unknown';
  176.  
  177. // If the progress is unavailable or empty, show "Ready"
  178. if (progress === 'unavailable' || progress === 'unknown' || progress === '') {
  179. return "Ready"; // Default to "Ready" when the dishwasher is in idle state
  180. }
  181.  
  182. // Otherwise, return the progress percentage
  183. return progress + '%';
  184. ]]]
  185.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement