.storage/lovelace.3d_printer_cellphone
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
},
|
||||
"card_param": "cards",
|
||||
"filter": {
|
||||
"template": "{% set ns = namespace(cards=[]) %}\n{% for n in [1, 2, 3, 4] %}\n {% set sp = namespace(ent='') %}\n {% for s in states.sensor %}\n {% if sp.ent == '' and s.entity_id.startswith('sensor.spoolman_spool_') %}\n {% set loc = (s.attributes.location | default('')) | lower %}\n {% if loc == ('cfs lite ' ~ n) %}\n {% set sp.ent = s.entity_id %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% if sp.ent != '' %}\n {% set hex = state_attr(sp.ent, 'filament_color_hex') | default('44739e') %}\n {% set hex_clean = hex if hex.startswith('#') else '#' ~ hex %}\n {% set remain = (state_attr(sp.ent, 'remaining_weight') | default(states(sp.ent)) | float(0)) | round(1) %}\n {% set total = state_attr(sp.ent, 'filament_weight') | float(0) %}\n {% set raw_pct = ((remain / total) * 100) | round(1) if total > 0 else 0 %}\n {% set pct = 0 if raw_pct < 0 else (100 if raw_pct > 100 else raw_pct) %}\n {% set border = '#d0d0d0' if hex_clean | lower in ['#ffffff', '#fff'] else 'transparent' %}\n\n {% set card = {\n \"type\": \"custom:button-card\",\n \"entity\": sp.ent,\n \"show_icon\": false,\n \"show_state\": false,\n \"show_name\": false,\n \"custom_fields\": {\n \"tube\": \"<div class='tube-wrap'><div class='tube-bg'><div class='tube-fill' style='height: \" ~ pct ~ \"%; background-color: \" ~ hex_clean ~ \";'></div><div class='tube-text'>\" ~ remain ~ \"g</div></div><div class='slot-label'>Slot \" ~ n ~ \"</div></div>\"\n },\n \"styles\": {\n \"card\": [\n {\"background\": \"transparent\"},\n {\"box-shadow\": \"none\"},\n {\"border\": \"none\"},\n {\"padding\": \"8px 2px\"},\n {\"display\": \"flex\"},\n {\"flex-direction\": \"column\"},\n {\"align-items\": \"center\"}\n ],\n \"custom_fields\": {\n \"tube\": [\n {\"width\": \"100%\"},\n {\"display\": \"flex\"},\n {\"flex-direction\": \"column\"},\n {\"align-items\": \"center\"}\n ]\n }\n },\n \"extra_styles\": \"\n .tube-wrap {\n display: flex;\n flex-direction: column;\n align-items: center;\n width: 100%;\n }\n .tube-bg {\n position: relative;\n width: 60px;\n height: 180px;\n background-color: #dedede;\n border-radius: 20px;\n overflow: hidden;\n border: 1px solid \" ~ border ~ \";\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n }\n .tube-fill {\n width: 100%;\n border-radius: 0 0 19px 19px;\n }\n .tube-text {\n position: absolute;\n top: 48%;\n left: 50%;\n transform: translate(-50%, -50%);\n font-size: 13px;\n font-weight: 800;\n color: #111111;\n pointer-events: none;\n z-index: 2;\n white-space: nowrap;\n }\n .slot-label {\n margin-top: 8px;\n font-size: 12px;\n font-weight: 700;\n letter-spacing: 0.3px;\n color: var(--secondary-text-color);\n }\n \",\n \"tap_action\": {\n \"action\": \"more-info\"\n }\n } %}\n\n {% set ns.cards = ns.cards + [card] %}\n {% endif %}\n{% endfor %}\n{{ ns.cards }}"
|
||||
"template": "{% set ns = namespace(cards=[]) %}\n{% for n in [1, 2, 3, 4] %}\n {% set sp = namespace(ent='') %}\n {% for s in states.sensor %}\n {% if sp.ent == '' and s.entity_id.startswith('sensor.spoolman_spool_') %}\n {% set loc = (s.attributes.location | default('')) | lower %}\n {% if loc == ('cfs lite ' ~ n) %}\n {% set sp.ent = s.entity_id %}\n {% endif %}\n {% endif %}\n {% endfor %}\n {% set v = namespace(html='', label='Slot ' ~ n, border='transparent') %}\n {% if sp.ent != '' %}\n {% set hex = state_attr(sp.ent, 'filament_color_hex') | default('44739e') %}\n {% set hex_clean = hex if hex.startswith('#') else '#' ~ hex %}\n {% set remain = (state_attr(sp.ent, 'remaining_weight') | default(states(sp.ent)) | float(0)) | round(1) %}\n {% set total = state_attr(sp.ent, 'filament_weight') | float(1000) %}\n {% set raw_pct = ((remain / total) * 100) | round(1) if total > 0 else 0 %}\n {% set pct = 0 if raw_pct < 0 else (100 if raw_pct > 100 else raw_pct) %}\n {% set v.border = '#d0d0d0' if hex_clean | lower in ['#ffffff', '#fff'] else 'transparent' %}\n {% set v.html = \"<div class='tube-bg'><div class='tube-fill' style='height: \" ~ pct ~ \"%; background-color: \" ~ hex_clean ~ \";'></div><div class='tube-text'>\" ~ remain ~ \"g</div></div>\" %}\n {% set v.label = 'Slot ' ~ n %}\n {% else %}\n {% set v.html = \"<div class='tube-bg tube-empty'></div>\" %}\n {% set v.label = \"<span class='slot-warn'>Slot \" ~ n ~ \" — empty</span>\" %}\n {% endif %}\n {% set card = {\n \"type\": \"custom:button-card\",\n \"entity\": sp.ent if sp.ent != '' else 'sensor.sparkx_i7_active_filament_slot',\n \"show_icon\": false,\n \"show_state\": false,\n \"show_name\": false,\n \"custom_fields\": {\n \"tube\": \"<div class='tube-wrap'>\" ~ v.html ~ \"<div class='slot-label'>\" ~ v.label ~ \"</div></div>\"\n },\n \"styles\": {\n \"card\": [\n {\"background\": \"transparent\"},\n {\"box-shadow\": \"none\"},\n {\"border\": \"none\"},\n {\"padding\": \"8px 2px\"},\n {\"display\": \"flex\"},\n {\"flex-direction\": \"column\"},\n {\"align-items\": \"center\"}\n ],\n \"custom_fields\": {\n \"tube\": [\n {\"width\": \"100%\"},\n {\"display\": \"flex\"},\n {\"flex-direction\": \"column\"},\n {\"align-items\": \"center\"}\n ]\n }\n },\n \"extra_styles\": \"\n .tube-wrap {\n display: flex;\n flex-direction: column;\n align-items: center;\n width: 100%;\n }\n .tube-bg {\n position: relative;\n width: 60px;\n height: 180px;\n background-color: #dedede;\n border-radius: 20px;\n overflow: hidden;\n border: 1px solid \" ~ v.border ~ \";\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n }\n .tube-empty {\n background: transparent;\n border: 2px dashed var(--error-color);\n }\n .tube-fill {\n width: 100%;\n border-radius: 0 0 19px 19px;\n }\n .tube-text {\n position: absolute;\n top: 48%;\n left: 50%;\n transform: translate(-50%, -50%);\n font-size: 13px;\n font-weight: 800;\n color: #111111;\n pointer-events: none;\n z-index: 2;\n white-space: nowrap;\n }\n .slot-label {\n margin-top: 8px;\n font-size: 12px;\n font-weight: 700;\n letter-spacing: 0.3px;\n color: var(--secondary-text-color);\n }\n .slot-warn {\n color: var(--error-color);\n }\n \",\n \"tap_action\": {\n \"action\": \"more-info\" if sp.ent != '' else \"none\"\n }\n } %}\n\n {% set ns.cards = ns.cards + [card] %}\n{% endfor %}\n{{ ns.cards }}\n"
|
||||
},
|
||||
"type": "custom:auto-entities"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user