.storage/lovelace.sparkx_i7

This commit is contained in:
Home Assistant Version Control
2026-10-09 22:35:00 +00:00
parent 37b85a4603
commit e73518564c
+3 -2
View File
@@ -1413,11 +1413,12 @@
"card": {
"type": "grid",
"columns": 4,
"square": false
"square": false,
"title": "Filament"
},
"card_param": "cards",
"filter": {
"template": "{% set ns = namespace(cards=[]) %} {% for s in states.sensor %}\n {% if s.entity_id.startswith('sensor.spoolman_spool_') %}\n {% set loc = (s.attributes.location | default('')) | lower %}\n {% if 'cfs lite' in loc %}\n {% set hex = s.attributes.filament_color_hex | default('44739e') %}\n {% set hex_clean = hex if hex.startswith('#') else '#' ~ hex %}\n {% set name = s.attributes.filament_name | default(s.attributes.friendly_name) %}\n {% set remain = (s.attributes.remaining_weight | default(s.state) | float(0)) | round(1) %}\n {% set total = (s.attributes.initial_weight | default(1000) | float(1000)) %}\n {% set raw_pct = ((remain / total) * 100) | round(1) %}\n {% set pct = 0 if raw_pct < 0 else (100 if raw_pct > 100 else raw_pct) %}\n {% set border = '#cccccc' if hex_clean | lower in ['#ffffff', '#fff'] else 'transparent' %}\n\n {% set card = {\n \"type\": \"custom:button-card\",\n \"entity\": s.entity_id,\n \"name\": name,\n \"show_icon\": false,\n \"show_state\": false,\n \"show_name\": true,\n \"custom_fields\": {\n \"bar\": \"\",\n \"val\": remain ~ \"g\"\n },\n \"styles\": {\n \"card\": [\n {\"background\": \"transparent\"},\n {\"box-shadow\": \"none\"},\n {\"border\": \"none\"},\n {\"padding\": \"4px 2px\"},\n {\"display\": \"flex\"},\n {\"flex-direction\": \"column\"},\n {\"align-items\": \"center\"}\n ],\n \"name\": [\n {\"font-size\": \"13px\"},\n {\"font-weight\": \"700\"},\n {\"color\": \"var(--primary-text-color)\"},\n {\"margin-top\": \"8px\"},\n {\"white-space\": \"nowrap\"},\n {\"overflow\": \"hidden\"},\n {\"text-overflow\": \"ellipsis\"},\n {\"max-width\": \"75px\"}\n ],\n \"custom_fields\": {\n \"bar\": [\n {\"position\": \"relative\"},\n {\"width\": \"54px\"},\n {\"height\": \"160px\"},\n {\"background\": \"rgba(220, 220, 224, 0.9)\"},\n {\"border-radius\": \"18px\"},\n {\"overflow\": \"hidden\"},\n {\"border\": \"1px solid \" ~ border},\n {\"background-image\": \"linear-gradient(to top, \" ~ hex_clean ~ \" 0%, \" ~ hex_clean ~ \" \" ~ pct ~ \"%, rgba(220, 220, 224, 0.9) \" ~ pct ~ \"%, rgba(220, 220, 224, 0.9) 100%)\"}\n ],\n \"val\": [\n {\"position\": \"absolute\"},\n {\"top\": \"50%\"},\n {\"left\": \"50%\"},\n {\"transform\": \"translate(-50%, -50%)\"},\n {\"font-size\": \"13px\"},\n {\"font-weight\": \"700\"},\n {\"color\": \"#111111\"},\n {\"pointer-events\": \"none\"},\n {\"z-index\": \"2\"}\n ]\n }\n },\n \"tap_action\": {\n \"action\": \"more-info\"\n }\n } %}\n {% set ns.cards = ns.cards + [card] %}\n {% endif %}\n {% endif %}\n{% endfor %} {{ ns.cards }}"
"template": "{% set ns = namespace(cards=[]) %} {% for s in states.sensor %}\n {% if s.entity_id.startswith('sensor.spoolman_spool_') %}\n {% set loc = (s.attributes.location | default('')) | lower %}\n {% if 'cfs lite' in loc %}\n {% set hex = s.attributes.filament_color_hex | default('44739e') %}\n {% set hex_clean = hex if hex.startswith('#') else '#' ~ hex %}\n {% set name = s.attributes.filament_name | default(s.attributes.friendly_name) %}\n {% set remain = (s.attributes.remaining_weight | default(s.state) | float(0)) | round(1) %}\n {% set total = (s.attributes.initial_weight | default(1000) | float(1000)) %}\n {% set raw_pct = ((remain / total) * 100) | round(1) %}\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\": s.entity_id,\n \"name\": name,\n \"show_icon\": false,\n \"show_state\": false,\n \"show_name\": true,\n \"custom_fields\": {\n \"tube\": \"<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 },\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 \"name\": [\n {\"font-size\": \"13px\"},\n {\"font-weight\": \"700\"},\n {\"color\": \"var(--primary-text-color)\"},\n {\"margin-top\": \"8px\"},\n {\"white-space\": \"nowrap\"},\n {\"overflow\": \"hidden\"},\n {\"text-overflow\": \"ellipsis\"},\n {\"max-width\": \"75px\"},\n {\"text-align\": \"center\"}\n ],\n \"custom_fields\": {\n \"tube\": [\n {\"width\": \"100%\"},\n {\"display\": \"flex\"},\n {\"justify-content\": \"center\"}\n ]\n }\n },\n \"extra_styles\": \"\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 \",\n \"tap_action\": {\n \"action\": \"more-info\"\n }\n } %}\n {% set ns.cards = ns.cards + [card] %}\n {% endif %}\n {% endif %}\n{% endfor %} {{ ns.cards }}"
}
}
]