Advertisement
Guest User

Untitled

a guest
Jun 9th, 2025
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.80 KB | None | 0 0
  1. type: custom:button-card
  2. entity: sensor.ucg_ultra_state
  3. triggers_update: all
  4. aspect_ratio: 1/1
  5. name: |
  6. [[[
  7. return [entity.attributes.friendly_name.replace("8 PoE","").replace("Mini","").replace("CPU","").replace(" State","")]
  8. ]]]
  9. styles:
  10. grid:
  11. - grid-template-areas: >-
  12. "icon update corner" "n n n" "line1 line1 line1" "line2 line2 line2"
  13. "line3 line3 line3"
  14. - grid-template-columns: 1fr 1fr 1fr
  15. - grid-template-rows: 1fr 2fr 1fr 1fr 1fr
  16. card:
  17. - box-shadow: |
  18. [[[
  19. if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state))
  20. return 'inset 0 0 0 1px red'
  21. else if (entity.entity_id.includes("eaton")){
  22. if (entity.state!="Online")
  23. return 'inset 0 0 0 1px red'
  24. else return 'inset 0 0 0 1px black'}
  25. else if (entity.state=='on'){
  26. if (entity.entity_id.includes("presence")||
  27. entity.entity_id.includes("motion")||
  28. entity.entity_id.includes("siren")||
  29. entity.entity_id.includes("binary_sensor.door_livingroom")||
  30. entity.entity_id.includes("binary_sensor.gas")||
  31. entity.entity_id.includes("binary_sensor.smoke")||
  32. entity.entity_id.includes("binary_sensor.leak"))
  33. return 'inset 0 0 0 1px red'
  34. else return 'inset 0 0 0 1px black'}
  35. else return 'inset 0 0 0 1px black'
  36. ]]]
  37. - background: linear-gradient(#000055,#000044,#000033)
  38. - font-weight: bold
  39. - filter: drop-shadow(0 0 1px black)
  40. - text-shadow: 0 0 2px black
  41. - opacity: |
  42. [[[
  43. if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state))
  44. return '50%'
  45. else return '100%'
  46. ]]]
  47. - text-transform: capitalize
  48. - font-size: 11px
  49. - padding: 5%
  50. name:
  51. - z-index: 1
  52. - pointer-events: none
  53. - filter: drop-shadow(0 0 1px black)
  54. - place-self: center start
  55. - font-size: 14px
  56. - overflow: visible
  57. - margin-bottom: "-3px"
  58. img_cell:
  59. - justify-content: start
  60. - scale: 1.5
  61. - padding: 10%
  62. icon:
  63. - filter: drop-shadow(0 0 1px black)
  64. - padding-left: 10%
  65. - padding-top: 10%
  66. custom_fields:
  67. icon:
  68. - z-index: 1
  69. - pointer-events: none
  70. - padding-top: 1em
  71. - width: 2em
  72. - filter: |
  73. [[[
  74. if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state))
  75. return 'drop-shadow(0 0 1px black) grayscale(100%)'
  76. else return 'drop-shadow(0 0 1px black) grayscale(0%)'
  77. ]]]
  78. corner:
  79. - z-index: 2
  80. - pointer-events: none
  81. - position: absolute
  82. - overflow: visible
  83. - filter: drop-shadow(0 0 1px black)
  84. - background: rgb(0,0,0,25%)
  85. - padding-top: 2%
  86. - padding-bottom: 2%
  87. - padding-left: 4%
  88. - padding-right: 4%
  89. - border-radius: 5px
  90. - border-style: solid
  91. - border-color: black
  92. - border-width: 1px
  93. - font-size: 12px
  94. - right: 3%
  95. - top: 3%
  96. corner1:
  97. - z-index: 2
  98. - pointer-events: none
  99. - position: absolute
  100. - overflow: visible
  101. - filter: drop-shadow(0 0 1px black)
  102. - background: rgb(0,0,0,25%)
  103. - padding-top: 2%
  104. - padding-bottom: 2%
  105. - padding-left: 4%
  106. - padding-right: 4%
  107. - border-radius: 5px
  108. - border-style: solid
  109. - border-color: black
  110. - border-width: 1px
  111. - font-size: 12px
  112. - right: 3%
  113. - top: 22%
  114. line1:
  115. - pointer-events: none
  116. - filter: drop-shadow(0 0 1px black)
  117. - justify-self: start
  118. line2:
  119. - pointer-events: none
  120. - filter: drop-shadow(0 0 1px black)
  121. - justify-self: start
  122. line3:
  123. - pointer-events: none
  124. - filter: drop-shadow(0 0 1px black)
  125. - justify-self: start
  126. addon_update:
  127. - z-index: 1
  128. - pointer-events: none
  129. - filter: drop-shadow(0 0 1px black)
  130. - width: 2em
  131. - position: absolute
  132. - top: 12.5%
  133. - left: 2em
  134. - scale: 75%
  135. addon_line2bar:
  136. - pointer-events: none
  137. - filter: drop-shadow(0 0 1px black)
  138. - position: absolute
  139. - left: "-8%"
  140. - top: 53%
  141. - "--ha-card-background": rgba(0, 0, 0, 0.0)
  142. - "--ha-card-border-width": 0px
  143. addon_line1bar:
  144. - pointer-events: none
  145. - filter: drop-shadow(0 0 1px black)
  146. - position: absolute
  147. - left: "-8%"
  148. - top: 37%
  149. - "--ha-card-background": rgba(0, 0, 0, 0.0)
  150. - "--ha-card-border-width": 0px
  151. custom_fields:
  152. addon_update: |
  153. [[[
  154. const { update, updating } = variables
  155. if (updating === 'on' || update === 'on') {
  156. return `
  157. <svg viewBox="0 0 48 48">
  158. ${updating === 'on' ? `<style>
  159. @keyframes rotate {
  160. 0% { visibility: visible; transform: rotate(0deg) translateZ(0); }
  161. 100% { transform: rotate(360deg) translateZ(0); }
  162. }
  163. .on {
  164. animation: rotate 3s linear infinite;
  165. transform-origin: center;
  166. visibility: visible;
  167. }
  168. </style>` : ''}
  169. <path fill="${updating === 'on' ? '#ff0000' : '#00ff00'}" stroke="currentColor" d="M 24 47 C 36.703 47 47 36.703 47 24 C 47 11.297 36.703 1 24 1 C 11.297 1 1 11.297 1 24 C 1 36.703 11.297 47 24 47 Z"/>
  170. <path ${updating === 'on' ? `class="${update}"` : ''} stroke="#000" d="M 34.973 27.45 C 33.508 32.117 29.149 35.5 24 35.5 C 18.851 35.5 14.493 32.117 13.028 27.45 L 13.028 34.35" style="fill-rule: evenodd; fill: none; stroke-linecap: square; stroke-linejoin: round; stroke-width: 4px;"/>
  171. <path ${updating === 'on' ? `class="${update}"` : ''} stroke="#000" d="M 34.973 13.65 L 34.973 20.55 C 33.508 15.883 29.149 12.5 24 12.5 C 18.851 12.5 14.493 15.883 13.028 20.55" style="fill-rule: evenodd; fill: none; stroke-linecap: square; stroke-linejoin: round; stroke-width: 4px;"/>
  172. </svg>`
  173. } else {
  174. return ''
  175. }
  176. ]]]
  177. corner: |
  178. [[[
  179. if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state)) return;
  180. else if (entity.entity_id.includes("ucg"))
  181. return Math.round(states['sensor.ucg_ultra_cpu_temperature'].state)+" °C"
  182. else if (entity.entity_id.includes("usw"))
  183. return states[entity.entity_id.replace("_state","_clients")].state + ' <ha-icon icon="mdi:ethernet-cable" style="width: 12px; height: 12px; color: yellow;"></ha-icon>'
  184. else if (entity.entity_id.includes("uap"))
  185. return states[entity.entity_id.replace("_state","_clients")].state + ' <ha-icon icon="mdi:wifi" style="width: 12px; height: 12px; color: yellow;"></ha-icon>'
  186. ]]]
  187. icon: |
  188. [[[
  189. return `
  190. <svg viewBox="0 0 48 48">
  191. <path style="fill:DodgerBlue" d="M 10.662 7.974 L 8.024 7.974 L 8.024 5.334 L 10.664 5.334 L 10.662 7.974 Z M 25.872 39.976 C 22.312 39.816 19.572 38.912 17.452 37.606 C 18.888 43.842 24.262 46.906 24.522 47.052 L 26.106 47.926 C 38.232 47.116 45.328 39.29 45.328 29.054 L 45.328 26.836 C 42.446 36.236 35.738 40.422 25.872 39.976 M 8.012 19.21 L 10.676 19.21 L 10.676 25.09 L 13.348 25.09 L 13.348 15.254 L 16.02 15.254 L 16.02 34.478 C 16.018 43.6 24 48 24 48 C 10.59 48 2.672 39.87 2.672 29.054 L 2.672 7.3 L 5.34 7.3 L 5.34 21.848 L 8.012 21.848 L 8.012 19.21 Z M 5.34 2.668 L 2.672 2.668 L 2.672 0 L 5.34 0 L 5.34 2.668 Z M 10.662 16.574 L 8.022 16.574 L 8.022 13.934 L 10.662 13.934 L 10.662 16.574 Z M 13.33 12.614 L 10.69 12.614 L 10.69 9.974 L 13.33 9.974 L 13.33 12.614 Z M 16.016 9.294 L 13.348 9.294 L 13.348 6.654 L 16.018 6.654 L 16.016 9.294 Z M 13.348 5.308 L 10.676 5.308 L 10.676 2.668 L 13.348 2.668 L 13.348 5.308 Z M 44.294 26.52 L 45.328 23.144 L 45.328 0.03 C 33.238 0.03 31.98 4.664 31.98 9.092 L 31.98 34.48 C 31.98 35.794 31.852 37.188 31.586 38.554 C 37.996 37.388 42.178 33.424 44.294 26.522 L 44.294 26.52 Z"/>
  192. </svg>`
  193. ]]]
  194. corner1: |
  195. [[[
  196. if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state)) return;
  197. else if (entity.entity_id.includes("ucg"))
  198. return states[entity.entity_id.replace("_state","_clients")].state + ' <ha-icon icon="mdi:ethernet-cable" style="width: 12px; height: 12px; color: yellow;"></ha-icon>'
  199. ]]]
  200. line1: |
  201. [[[
  202. if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state)) return;
  203. else return "CPU:"
  204. ]]]
  205. line2: |
  206. [[[
  207. if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state)) return;
  208. else return "RAM:"
  209. ]]]
  210. line3: |
  211. [[[
  212. if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state)) return;
  213. const uptimeEntityId = entity.entity_id.replace("_state", "_uptime");
  214. const uptimeState = states[uptimeEntityId]?.state;
  215. const uptimeDate = new Date(uptimeState);
  216.  
  217. if (!uptimeState || isNaN(uptimeDate)) {
  218. return "Uptime: unavailable";
  219. }
  220.  
  221. const now = new Date();
  222. const timeDiff = (now.getTime() - uptimeDate.getTime()) / 1000;
  223. const days = Math.floor(timeDiff / 86400);
  224. const hours = Math.floor((timeDiff % 86400) / 3600);
  225. const minutes = Math.floor((timeDiff % 3600) / 60);
  226.  
  227. return days > 0 ? `Uptime: ${days} days` :
  228. hours > 0 ? `Uptime: ${hours} hours` :
  229. `Uptime: ${minutes} minutes`;
  230. ]]]
  231. addon_line1bar:
  232. card:
  233. decimal: 0
  234. height: 10px
  235. width: 60px
  236. positions:
  237. icon: "off"
  238. indicator: "off"
  239. name: "off"
  240. severity:
  241. - color: green
  242. from: 0
  243. to: 70
  244. - color: sienna
  245. from: 70
  246. to: 85
  247. - color: darkred
  248. from: 85
  249. to: 100
  250. type: custom:bar-card
  251. entities:
  252. - entity: |
  253. [[[
  254. if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state)) return;
  255. else return entity.entity_id.replace("_state", "_cpu_utilization")
  256. ]]]
  257. addon_line2bar:
  258. card:
  259. type: custom:bar-card
  260. entities:
  261. - entity: |
  262. [[[
  263. if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state)) return;
  264. else return entity.entity_id.replace("_state", "_memory_utilization")
  265. ]]]
  266. decimal: 0
  267. height: 10px
  268. width: 60px
  269. positions:
  270. icon: "off"
  271. indicator: "off"
  272. name: "off"
  273. severity:
  274. - color: green
  275. from: 0
  276. to: 70
  277. - color: sienna
  278. from: 70
  279. to: 85
  280. - color: darkred
  281. from: 85
  282. to: 100
  283.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement