Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type: custom:button-card
- entity: sensor.ucg_ultra_state
- triggers_update: all
- aspect_ratio: 1/1
- name: |
- [[[
- return [entity.attributes.friendly_name.replace("8 PoE","").replace("Mini","").replace("CPU","").replace(" State","")]
- ]]]
- styles:
- grid:
- - grid-template-areas: >-
- "icon update corner" "n n n" "line1 line1 line1" "line2 line2 line2"
- "line3 line3 line3"
- - grid-template-columns: 1fr 1fr 1fr
- - grid-template-rows: 1fr 2fr 1fr 1fr 1fr
- card:
- - box-shadow: |
- [[[
- if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state))
- return 'inset 0 0 0 1px red'
- else if (entity.entity_id.includes("eaton")){
- if (entity.state!="Online")
- return 'inset 0 0 0 1px red'
- else return 'inset 0 0 0 1px black'}
- else if (entity.state=='on'){
- if (entity.entity_id.includes("presence")||
- entity.entity_id.includes("motion")||
- entity.entity_id.includes("siren")||
- entity.entity_id.includes("binary_sensor.door_livingroom")||
- entity.entity_id.includes("binary_sensor.gas")||
- entity.entity_id.includes("binary_sensor.smoke")||
- entity.entity_id.includes("binary_sensor.leak"))
- return 'inset 0 0 0 1px red'
- else return 'inset 0 0 0 1px black'}
- else return 'inset 0 0 0 1px black'
- ]]]
- - background: linear-gradient(#000055,#000044,#000033)
- - font-weight: bold
- - filter: drop-shadow(0 0 1px black)
- - text-shadow: 0 0 2px black
- - opacity: |
- [[[
- if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state))
- return '50%'
- else return '100%'
- ]]]
- - text-transform: capitalize
- - font-size: 11px
- - padding: 5%
- name:
- - z-index: 1
- - pointer-events: none
- - filter: drop-shadow(0 0 1px black)
- - place-self: center start
- - font-size: 14px
- - overflow: visible
- - margin-bottom: "-3px"
- img_cell:
- - justify-content: start
- - scale: 1.5
- - padding: 10%
- icon:
- - filter: drop-shadow(0 0 1px black)
- - padding-left: 10%
- - padding-top: 10%
- custom_fields:
- icon:
- - z-index: 1
- - pointer-events: none
- - padding-top: 1em
- - width: 2em
- - filter: |
- [[[
- if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state))
- return 'drop-shadow(0 0 1px black) grayscale(100%)'
- else return 'drop-shadow(0 0 1px black) grayscale(0%)'
- ]]]
- corner:
- - z-index: 2
- - pointer-events: none
- - position: absolute
- - overflow: visible
- - filter: drop-shadow(0 0 1px black)
- - background: rgb(0,0,0,25%)
- - padding-top: 2%
- - padding-bottom: 2%
- - padding-left: 4%
- - padding-right: 4%
- - border-radius: 5px
- - border-style: solid
- - border-color: black
- - border-width: 1px
- - font-size: 12px
- - right: 3%
- - top: 3%
- corner1:
- - z-index: 2
- - pointer-events: none
- - position: absolute
- - overflow: visible
- - filter: drop-shadow(0 0 1px black)
- - background: rgb(0,0,0,25%)
- - padding-top: 2%
- - padding-bottom: 2%
- - padding-left: 4%
- - padding-right: 4%
- - border-radius: 5px
- - border-style: solid
- - border-color: black
- - border-width: 1px
- - font-size: 12px
- - right: 3%
- - top: 22%
- line1:
- - pointer-events: none
- - filter: drop-shadow(0 0 1px black)
- - justify-self: start
- line2:
- - pointer-events: none
- - filter: drop-shadow(0 0 1px black)
- - justify-self: start
- line3:
- - pointer-events: none
- - filter: drop-shadow(0 0 1px black)
- - justify-self: start
- addon_update:
- - z-index: 1
- - pointer-events: none
- - filter: drop-shadow(0 0 1px black)
- - width: 2em
- - position: absolute
- - top: 12.5%
- - left: 2em
- - scale: 75%
- addon_line2bar:
- - pointer-events: none
- - filter: drop-shadow(0 0 1px black)
- - position: absolute
- - left: "-8%"
- - top: 53%
- - "--ha-card-background": rgba(0, 0, 0, 0.0)
- - "--ha-card-border-width": 0px
- addon_line1bar:
- - pointer-events: none
- - filter: drop-shadow(0 0 1px black)
- - position: absolute
- - left: "-8%"
- - top: 37%
- - "--ha-card-background": rgba(0, 0, 0, 0.0)
- - "--ha-card-border-width": 0px
- custom_fields:
- addon_update: |
- [[[
- const { update, updating } = variables
- if (updating === 'on' || update === 'on') {
- return `
- <svg viewBox="0 0 48 48">
- ${updating === 'on' ? `<style>
- @keyframes rotate {
- 0% { visibility: visible; transform: rotate(0deg) translateZ(0); }
- 100% { transform: rotate(360deg) translateZ(0); }
- }
- .on {
- animation: rotate 3s linear infinite;
- transform-origin: center;
- visibility: visible;
- }
- </style>` : ''}
- <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"/>
- <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;"/>
- <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;"/>
- </svg>`
- } else {
- return ''
- }
- ]]]
- corner: |
- [[[
- if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state)) return;
- else if (entity.entity_id.includes("ucg"))
- return Math.round(states['sensor.ucg_ultra_cpu_temperature'].state)+" °C"
- else if (entity.entity_id.includes("usw"))
- return states[entity.entity_id.replace("_state","_clients")].state + ' <ha-icon icon="mdi:ethernet-cable" style="width: 12px; height: 12px; color: yellow;"></ha-icon>'
- else if (entity.entity_id.includes("uap"))
- return states[entity.entity_id.replace("_state","_clients")].state + ' <ha-icon icon="mdi:wifi" style="width: 12px; height: 12px; color: yellow;"></ha-icon>'
- ]]]
- icon: |
- [[[
- return `
- <svg viewBox="0 0 48 48">
- <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"/>
- </svg>`
- ]]]
- corner1: |
- [[[
- if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state)) return;
- else if (entity.entity_id.includes("ucg"))
- return states[entity.entity_id.replace("_state","_clients")].state + ' <ha-icon icon="mdi:ethernet-cable" style="width: 12px; height: 12px; color: yellow;"></ha-icon>'
- ]]]
- line1: |
- [[[
- if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state)) return;
- else return "CPU:"
- ]]]
- line2: |
- [[[
- if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state)) return;
- else return "RAM:"
- ]]]
- line3: |
- [[[
- if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state)) return;
- const uptimeEntityId = entity.entity_id.replace("_state", "_uptime");
- const uptimeState = states[uptimeEntityId]?.state;
- const uptimeDate = new Date(uptimeState);
- if (!uptimeState || isNaN(uptimeDate)) {
- return "Uptime: unavailable";
- }
- const now = new Date();
- const timeDiff = (now.getTime() - uptimeDate.getTime()) / 1000;
- const days = Math.floor(timeDiff / 86400);
- const hours = Math.floor((timeDiff % 86400) / 3600);
- const minutes = Math.floor((timeDiff % 3600) / 60);
- return days > 0 ? `Uptime: ${days} days` :
- hours > 0 ? `Uptime: ${hours} hours` :
- `Uptime: ${minutes} minutes`;
- ]]]
- addon_line1bar:
- card:
- decimal: 0
- height: 10px
- width: 60px
- positions:
- icon: "off"
- indicator: "off"
- name: "off"
- severity:
- - color: green
- from: 0
- to: 70
- - color: sienna
- from: 70
- to: 85
- - color: darkred
- from: 85
- to: 100
- type: custom:bar-card
- entities:
- - entity: |
- [[[
- if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state)) return;
- else return entity.entity_id.replace("_state", "_cpu_utilization")
- ]]]
- addon_line2bar:
- card:
- type: custom:bar-card
- entities:
- - entity: |
- [[[
- if (!entity?.state || ['unavailable', 'unknown', ''].includes(entity.state)) return;
- else return entity.entity_id.replace("_state", "_memory_utilization")
- ]]]
- decimal: 0
- height: 10px
- width: 60px
- positions:
- icon: "off"
- indicator: "off"
- name: "off"
- severity:
- - color: green
- from: 0
- to: 70
- - color: sienna
- from: 70
- to: 85
- - color: darkred
- from: 85
- to: 100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement