Skip to content

Commit

Permalink
Add missing template
Browse files Browse the repository at this point in the history
  • Loading branch information
IDmedia committed Feb 15, 2024
1 parent 4a4883c commit 769d55c
Showing 1 changed file with 88 additions and 0 deletions.
88 changes: 88 additions & 0 deletions lovelace/templates/network_share.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
button_network_share:
variables:
warning_from_state: 80
critical_from_state: 90
bar_color_normal: '#69B34C'
bar_color_warning: '#FAB733'
bar_color_critical: '#FF4E11'
bar_color_background: '#E5E6E8'
show_icon: false
show_entity_picture: true
entity_picture: /local/share.png
name: >
[[[
if (isNaN(entity.state)) {
return 'Unavailable';
}
return `${entity.attributes.nameorig}`;
]]]
styles:
grid:
- grid-template-areas: '"i n"
"i bar"
"i state"'
- grid-template-columns: 40px auto
- column-gap: 5px
- grid-template-rows: 1fr
card:
- color: '#000'
- font-size: 1em
- border-style: none
- --mdc-ripple-color: none
icon:
- width: 100%
img_cell:
- justify-content: start
name:
- justify-self: start
custom_fields:
bar:
- grid-area: bar
- font-size: 0.8em
- padding: 2px 0
- width: 100%
state:
- grid-area: state
- justify-self: start
- color: '#888'
- font-size: 0.8em
custom_fields:
state: >
[[[
if (isNaN(entity.state)) {
return 'Unknown';
}
function formatBytes(a,b=2){if(!+a)return"0 Bytes";const c=0>b?0:b,d=Math.floor(Math.log(a)/Math.log(1000));return`${parseFloat((a/Math.pow(1000,d)).toFixed(c))} ${["Bytes", "KB","MB","GB","TB","PB","EB","ZB","YB"][d]}`}
var free = parseInt(entity.attributes.free);
var used = parseInt(entity.attributes.used);
var spaceFree = Math.max(0, free * 1000);
var spaceTotal = (free+used) * 1000;
return `${formatBytes(spaceFree, 0)} free of ${formatBytes(spaceTotal, 0)}`;
]]]
bar: >
[[[
var pctUsed = 100;
if (!isNaN(entity.state)) {
var free = parseInt(entity.attributes.free);
var used = parseInt(entity.attributes.used);
var spaceFree = Math.max(0, free * 1000);
var spaceTotal = (free+used) * 1000;
pctUsed = Math.ceil(100-((spaceFree / spaceTotal) * 100));
}
let barColor = variables.bar_color_normal;
barColor = (pctUsed > variables.warning_from_state ) ? variables.bar_color_warning : barColor;
barColor = (pctUsed > variables.critical_from_state ) ? variables.bar_color_critical : barColor;
return `<div style="background-color:${variables.bar_color_background}">
<div style="background-color:${barColor};height:10px;width:${pctUsed}%"></div>
</div>`;
]]]

0 comments on commit 769d55c

Please sign in to comment.