.storage/lovelace.sparkx_i7
This commit is contained in:
@@ -1412,12 +1412,12 @@
|
||||
"type": "custom:auto-entities",
|
||||
"card": {
|
||||
"type": "grid",
|
||||
"columns": 2,
|
||||
"columns": 4,
|
||||
"square": false
|
||||
},
|
||||
"card_param": "cards",
|
||||
"filter": {
|
||||
"template": "{% set ns = namespace(cards=[]) %} {% for s in states.sensor | selectattr('entity_id', 'match', '^sensor\\.spoolman_spool_') %}\n {% if s.attributes.location is defined and s.attributes.location | lower == 'cfs lite' %}\n {% set hex = s.attributes.filament_color_hex | default('44739e') %}\n {% set hex_clean = hex if hex.startswith('#') else '#' ~ hex %}\n {% set vendor = s.attributes.filament_vendor_name | default('') %}\n {% set name = s.attributes.filament_name | default(s.attributes.friendly_name) %}\n {% set material = s.attributes.filament_material | default('') %}\n {% set remaining = (s.attributes.remaining_weight | default(0) | float) | round(0) %}\n {% set total = (s.attributes.initial_weight | default(1000) | float) | round(0) %}\n {% set used_pct = (s.attributes.used_percentage | default(0) | float) | round(1) %}\n {% set remain_pct = (100 - used_pct) | round(0) %}\n\n {% set card = {\n \"type\": \"custom:button-card\",\n \"entity\": s.entity_id,\n \"layout\": \"icon_name_state2nd\",\n \"show_name\": true,\n \"show_state\": false,\n \"show_icon\": true,\n \"show_label\": true,\n \"icon\": \"mdi:printer-3d-nozzle\",\n \"name\": vendor ~ \" \" ~ name,\n \"label\": material ~ \" • \" ~ remaining ~ \"g / \" ~ total ~ \"g (\" ~ remain_pct ~ \"%)\",\n \"styles\": {\n \"card\": [\n {\"padding\": \"12px\"},\n {\"background-color\": \"var(--card-background-color)\"},\n {\"border-radius\": \"12px\"}\n ],\n \"icon\": [\n {\"color\": hex_clean},\n {\"width\": \"32px\"},\n {\"height\": \"32px\"}\n ],\n \"name\": [\n {\"font-weight\": \"600\"},\n {\"font-size\": \"14px\"},\n {\"justify-self\": \"start\"},\n {\"text-align\": \"left\"}\n ],\n \"label\": [\n {\"font-size\": \"12px\"},\n {\"color\": \"var(--secondary-text-color)\"},\n {\"justify-self\": \"start\"},\n {\"text-align\": \"left\"},\n {\"margin-top\": \"4px\"}\n ]\n },\n \"tap_action\": {\n \"action\": \"more-info\"\n }\n } %}\n {% set ns.cards = ns.cards + [card] %}\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 = '#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 }}"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user