Advertisement
Guest User

Untitled

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