Advertisement
Guest User

Waste Collection Template

a guest
Feb 16th, 2025
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.36 KB | None | 0 0
  1. hc_waste_collection:
  2. variables:
  3. entitybulky: sensor.bulky_waste_collection
  4. entitybulkyicon: fapro:boxes-stacked-solid
  5. entitymixed: sensor.mixed_waste_collection
  6. entitymixedicon: fapro:dumpster-solid
  7. entityelectronics: sensor.electronics_waste_collection
  8. entityelectronicsicon: fapro:radio-solid
  9. trash_entities:
  10. - entity: '[[[ return variables.entitybulky ]]]'
  11. name: Bulky Waste
  12. icon: '[[[ return variables.entitybulkyicon ]]]'
  13. style: "color: #66ac85;"
  14. - entity: '[[[ return variables.entitymixed ]]]'
  15. name: Mixed Waste
  16. icon: '[[[ return variables.entitymixedicon ]]]'
  17. style: "color: #ddae7b;"
  18. - entity: '[[[ return variables.entityelectronics ]]]'
  19. name: Electronics
  20. icon: '[[[ return variables.entityelectronicsicon ]]]'
  21. style: "color: #84a2d9;"
  22. "y": |
  23. [[[
  24. const trashData = variables.trash_entities.map(entity => {
  25. const state = states[entity.entity] ? states[entity.entity].state : null;
  26. const days_left = state && !isNaN(parseInt(state, 10)) ? parseInt(state, 10) : 9999; // Assign a large number if invalid
  27.  
  28. return {
  29. entity: entity.entity,
  30. name: entity.name,
  31. icon: entity.icon,
  32. style: entity.style,
  33. days_left: days_left
  34. };
  35. });
  36.  
  37. // Sort by days_left but push non-numeric ones to the end
  38. trashData.sort((a, b) => a.days_left - b.days_left);
  39.  
  40. return JSON.stringify(trashData);
  41. ]]]
  42. styles:
  43. grid:
  44. - grid-template-areas: '''first second third'''
  45. - grid-template-columns: 1fr 1fr 1fr
  46. card:
  47. - padding: 15px
  48. custom_fields:
  49. first:
  50. - justify-self: start
  51. second:
  52. - justify-self: center
  53. third:
  54. - justify-self: end
  55. custom_fields:
  56. first:
  57. card:
  58. type: custom:button-card
  59. card_mod:
  60. style: |
  61. ha-card {
  62. padding: 5px !important;
  63. }
  64. icon: |
  65. [[[ const trashData = JSON.parse(variables.y); return trashData[0] ? trashData[0].icon : null; ]]]
  66. name: |
  67. [[[ const trashData = JSON.parse(variables.y); return trashData[0] ? trashData[0].name : ''; ]]]
  68. label: |
  69. [[[
  70. const trashData = JSON.parse(variables.y);
  71. if (!trashData[0]) return '';
  72. return trashData[0].days_left === 0 ? "Today" : trashData[0].days_left === 1 ? "Tomorrow" : `${trashData[0].days_left} days`;
  73. ]]]
  74. show_label: true
  75. styles:
  76. card:
  77. - border-radius: 0px
  78. - box-shadow: none
  79. - padding-right: 5px
  80. grid:
  81. - grid-template-areas: '''i n'' ''i l'''
  82. - grid-template-columns: min-content
  83. - column-gap: 10px
  84. icon:
  85. - width: 20px
  86. - color: |
  87. [[[ return JSON.parse(variables.y)[0] ? JSON.parse(variables.y)[0].style.match(/color:\s*(#[0-9A-Fa-f]{6}|#[0-9A-Fa-f]{3}|[a-zA-Z]+)/)[1] : 'gray'; ]]]
  88. img_cell:
  89. - width: 20px
  90. name:
  91. - justify-self: start
  92. - font-size: 11px
  93. - font-family: montserrat
  94. - font-weight: 500
  95. - color: var(--color-dark-gray)
  96. label:
  97. - font-size: 11px
  98. - font-weight: 700
  99. second:
  100. card:
  101. type: custom:button-card
  102. icon: |
  103. [[[ const trashData = JSON.parse(variables.y); return trashData[1] ? trashData[1].icon : null; ]]]
  104. name: |
  105. [[[ const trashData = JSON.parse(variables.y); return trashData[1] ? trashData[1].name : ''; ]]]
  106. label: |
  107. [[[
  108. const trashData = JSON.parse(variables.y);
  109. if (!trashData[1]) return '';
  110. return trashData[1].days_left === 0 ? "Today" : trashData[1].days_left === 1 ? "Tomorrow" : `${trashData[1].days_left} days`;
  111. ]]]
  112. show_label: true
  113. styles:
  114. card:
  115. - border-radius: 0px
  116. - box-shadow: none
  117. - padding-right: 5px
  118. grid:
  119. - grid-template-areas: '''i n'' ''i l'''
  120. - grid-template-columns: min-content
  121. - column-gap: 10px
  122. icon:
  123. - width: 20px
  124. - color: |
  125. [[[ return JSON.parse(variables.y)[1] ? JSON.parse(variables.y)[1].style.match(/color:\s*(#[0-9A-Fa-f]{6}|#[0-9A-Fa-f]{3}|[a-zA-Z]+)/)[1] : 'gray'; ]]]
  126. img_cell:
  127. - width: 20px
  128. name:
  129. - font-size: 11px
  130. - font-family: montserrat
  131. - font-weight: 500
  132. - color: var(--color-dark-gray)
  133. label:
  134. - font-size: 11px
  135. - font-weight: 700
  136. third:
  137. card:
  138. type: custom:button-card
  139. icon: |
  140. [[[ const trashData = JSON.parse(variables.y); return trashData[2] ? trashData[2].icon : null; ]]]
  141. name: |
  142. [[[ const trashData = JSON.parse(variables.y); return trashData[2] ? trashData[2].name : ''; ]]]
  143. label: |
  144. [[[
  145. const trashData = JSON.parse(variables.y);
  146. if (!trashData[2]) return '';
  147. return trashData[2].days_left === 0 ? "Today" : trashData[2].days_left === 1 ? "Tomorrow" : `${trashData[2].days_left} days`;
  148. ]]]
  149. show_label: true
  150. styles:
  151. card:
  152. - border-radius: 0px
  153. - box-shadow: none
  154. - padding-right: 5px
  155. grid:
  156. - grid-template-areas: '''i n'' ''i l'''
  157. - grid-template-columns: min-content
  158. - column-gap: 10px
  159. icon:
  160. - width: 20px
  161. - color: |
  162. [[[ return JSON.parse(variables.y)[2] ? JSON.parse(variables.y)[2].style.match(/color:\s*(#[0-9A-Fa-f]{6}|#[0-9A-Fa-f]{3}|[a-zA-Z]+)/)[1] : 'gray'; ]]]
  163. img_cell:
  164. - width: 20px
  165. name:
  166. - font-size: 11px
  167. - font-family: montserrat
  168. - font-weight: 500
  169. - color: var(--color-dark-gray)
  170. label:
  171. - font-size: 11px
  172. - font-weight: 700
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement