From feef1875406967e603efecaec0ff0893d2cc7eec Mon Sep 17 00:00:00 2001 From: Home Assistant Version Control Date: Thu, 15 Oct 2026 17:24:18 +0000 Subject: [PATCH] .storage/lovelace.3d_printer_cellphone --- .storage/lovelace.3d_printer_cellphone | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.storage/lovelace.3d_printer_cellphone b/.storage/lovelace.3d_printer_cellphone index e7e58744..7550b5dc 100644 --- a/.storage/lovelace.3d_printer_cellphone +++ b/.storage/lovelace.3d_printer_cellphone @@ -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 {% 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 = \"
\" ~ remain ~ \"g
\" %}\n {% set v.label = 'Slot ' ~ n %}\n {% else %}\n {% set v.html = \"
\" %}\n {% set v.label = \"Slot \" ~ n ~ \" — empty\" %}\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\": \"
\" ~ v.html ~ \"
\" ~ v.label ~ \"
\"\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" + "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', wrap='') %}\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 rem_n = states(sp.ent) | float(-1) %}\n {% set band = 2 if (rem_n >= 0 and rem_n < 25) else (1 if (rem_n >= 0 and rem_n < 100) else 0) %}\n {% set v.wrap = ' warn-crit' if band == 2 else (' warn-low' if band == 1 else '') %}\n {% set v.border = '#d0d0d0' if hex_clean | lower in ['#ffffff', '#fff'] else 'transparent' %}\n {% set v.html = \"
\" ~ remain ~ \"g
\" %}\n {% set v.label = 'Slot ' ~ n ~ (' ⚠' if band > 0 else '') %}\n {% else %}\n {% set v.html = \"
\" %}\n {% set v.label = \"Slot \" ~ n ~ \" — empty\" %}\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\": \"
\" ~ v.html ~ \"
\" ~ v.label ~ \"
\"\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 .warn-low .tube-bg {\n background-color: #fff6df;\n outline: 2px solid var(--warning-color);\n }\n .warn-low .slot-label {\n color: var(--warning-color);\n }\n .warn-crit .tube-bg {\n background-color: #fdecea;\n outline: 2px solid var(--error-color);\n }\n .warn-crit .slot-label {\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" }, @@ -84,13 +84,13 @@ { "entity": "sensor.sparkx_moonraker_print_eta", "features_position": "bottom", - "name": "Print ETA", - "type": "tile", - "vertical": false, "grid_options": { "columns": 6, "rows": 1 - } + }, + "name": "Print ETA", + "type": "tile", + "vertical": false }, { "entity": "sensor.sparkx_i7_filament_weight_estimated", @@ -106,18 +106,18 @@ "type": "custom:mushroom-template-card" }, { - "type": "custom:mushroom-template-card", "entity": "sensor.sparkx_i7_expected_material_length", - "name": "Filament Sufficiency", - "icon": "mdi:scale-balance", - "icon_color": "{% set gcm = states('input_number.sparkx_i7_filament_g_cm') | float(0.0298) %}\n{% set lencm = states('sensor.sparkx_i7_expected_material_length') | float(0) %}\n{% set wgt = states('sensor.sparkx_i7_expected_material_weight') | float(0) %}\n{% set job_g = ((wgt if wgt > 0 else lencm * gcm) | round(1)) %}\n{% set used_g = ((states('sensor.sparkx_i7_used_material_length') | float(0)) * gcm) | round(1) %}\n{% set rem_g = ([job_g - used_g, 0] | max) | round(1) %}\n{% set gc = namespace(list=[]) %}\n{% for p in (state_attr('sensor.sparkx_i7_expected_material_length','color') | default('', true) | string).split(';') %}\n{% set q = p | replace('#','') | lower | trim %}\n{% if q not in ['','none','unknown','unavailable'] %}{% set gc.list = gc.list + [q] %}{% endif %}\n{% endfor %}\n{% set single = (gc.list | length) == 1 %}\n{% set aslot = (states('sensor.sparkx_i7_active_filament_slot') | default('', true) | string).split('_')[-1] %}\n{% set aslot = aslot if aslot in ['1','2','3','4'] else '' %}\n{% set s = namespace(short=false, ok=false, matched=0, active=false) %}\n{% for n in ['1','2','3','4'] %}\n{% set sp = namespace(id='', rem=-1) %}\n{% for e in integration_entities('spoolman') if e.endswith('_color_hex') %}\n{% if sp.id == '' and (state_attr(e[:-10],'location') | default('', true) | lower) == ('cfs lite ' ~ n) %}\n{% set sp.id = e[:-10] %}\n{% set sp.rem = states(e[:-10]) | float(-1) %}\n{% endif %}\n{% endfor %}\n{% if sp.id != '' and sp.rem >= 0 %}\n{% set s.matched = s.matched + 1 %}\n{% if single %}\n{% if n == aslot %}\n{% set s.active = true %}\n{% if sp.rem < job_g %}{% set s.short = true %}{% else %}{% set s.ok = true %}{% endif %}\n{% endif %}\n{% else %}\n{% if sp.rem < job_g %}{% set s.short = true %}{% else %}{% set s.ok = true %}{% endif %}\n{% endif %}\n{% endif %}\n{% endfor %}\n{% set v = namespace(state='unknown', label='check unavailable') %}\n{% if job_g <= 0 %}\n{% set v.state = 'none' %}\n{% set v.label = 'no slicer estimate yet' %}\n{% elif s.short %}\n{% set v.state = 'short' %}\n{% set v.label = 'NOT ENOUGH' %}\n{% elif s.ok %}\n{% set v.state = 'ok' %}\n{% set v.label = 'enough' %}\n{% elif single and aslot == '' %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'no active CFS slot' %}\n{% elif single and not s.active %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'active slot has no spool' %}\n{% elif s.matched == 0 %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'no spool loaded' %}\n{% endif %}\n{% if v.state == 'ok' %}green{% elif v.state == 'short' %}red{% elif v.state == 'none' %}grey{% else %}orange{% endif %}", - "primary": "{% set gcm = states('input_number.sparkx_i7_filament_g_cm') | float(0.0298) %}\n{% set lencm = states('sensor.sparkx_i7_expected_material_length') | float(0) %}\n{% set wgt = states('sensor.sparkx_i7_expected_material_weight') | float(0) %}\n{% set job_g = ((wgt if wgt > 0 else lencm * gcm) | round(1)) %}\n{% set used_g = ((states('sensor.sparkx_i7_used_material_length') | float(0)) * gcm) | round(1) %}\n{% set rem_g = ([job_g - used_g, 0] | max) | round(1) %}\n{% set gc = namespace(list=[]) %}\n{% for p in (state_attr('sensor.sparkx_i7_expected_material_length','color') | default('', true) | string).split(';') %}\n{% set q = p | replace('#','') | lower | trim %}\n{% if q not in ['','none','unknown','unavailable'] %}{% set gc.list = gc.list + [q] %}{% endif %}\n{% endfor %}\n{% set single = (gc.list | length) == 1 %}\n{% set aslot = (states('sensor.sparkx_i7_active_filament_slot') | default('', true) | string).split('_')[-1] %}\n{% set aslot = aslot if aslot in ['1','2','3','4'] else '' %}\n{% set s = namespace(short=false, ok=false, matched=0, active=false) %}\n{% for n in ['1','2','3','4'] %}\n{% set sp = namespace(id='', rem=-1) %}\n{% for e in integration_entities('spoolman') if e.endswith('_color_hex') %}\n{% if sp.id == '' and (state_attr(e[:-10],'location') | default('', true) | lower) == ('cfs lite ' ~ n) %}\n{% set sp.id = e[:-10] %}\n{% set sp.rem = states(e[:-10]) | float(-1) %}\n{% endif %}\n{% endfor %}\n{% if sp.id != '' and sp.rem >= 0 %}\n{% set s.matched = s.matched + 1 %}\n{% if single %}\n{% if n == aslot %}\n{% set s.active = true %}\n{% if sp.rem < job_g %}{% set s.short = true %}{% else %}{% set s.ok = true %}{% endif %}\n{% endif %}\n{% else %}\n{% if sp.rem < job_g %}{% set s.short = true %}{% else %}{% set s.ok = true %}{% endif %}\n{% endif %}\n{% endif %}\n{% endfor %}\n{% set v = namespace(state='unknown', label='check unavailable') %}\n{% if job_g <= 0 %}\n{% set v.state = 'none' %}\n{% set v.label = 'no slicer estimate yet' %}\n{% elif s.short %}\n{% set v.state = 'short' %}\n{% set v.label = 'NOT ENOUGH' %}\n{% elif s.ok %}\n{% set v.state = 'ok' %}\n{% set v.label = 'enough' %}\n{% elif single and aslot == '' %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'no active CFS slot' %}\n{% elif single and not s.active %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'active slot has no spool' %}\n{% elif s.matched == 0 %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'no spool loaded' %}\n{% endif %}\n{{ job_g }} g needed · {{ used_g }} g used", - "secondary": "{% set gcm = states('input_number.sparkx_i7_filament_g_cm') | float(0.0298) %}\n{% set lencm = states('sensor.sparkx_i7_expected_material_length') | float(0) %}\n{% set wgt = states('sensor.sparkx_i7_expected_material_weight') | float(0) %}\n{% set job_g = ((wgt if wgt > 0 else lencm * gcm) | round(1)) %}\n{% set used_g = ((states('sensor.sparkx_i7_used_material_length') | float(0)) * gcm) | round(1) %}\n{% set rem_g = ([job_g - used_g, 0] | max) | round(1) %}\n{% set gc = namespace(list=[]) %}\n{% for p in (state_attr('sensor.sparkx_i7_expected_material_length','color') | default('', true) | string).split(';') %}\n{% set q = p | replace('#','') | lower | trim %}\n{% if q not in ['','none','unknown','unavailable'] %}{% set gc.list = gc.list + [q] %}{% endif %}\n{% endfor %}\n{% set single = (gc.list | length) == 1 %}\n{% set aslot = (states('sensor.sparkx_i7_active_filament_slot') | default('', true) | string).split('_')[-1] %}\n{% set aslot = aslot if aslot in ['1','2','3','4'] else '' %}\n{% set s = namespace(short=false, ok=false, matched=0, active=false) %}\n{% for n in ['1','2','3','4'] %}\n{% set sp = namespace(id='', rem=-1) %}\n{% for e in integration_entities('spoolman') if e.endswith('_color_hex') %}\n{% if sp.id == '' and (state_attr(e[:-10],'location') | default('', true) | lower) == ('cfs lite ' ~ n) %}\n{% set sp.id = e[:-10] %}\n{% set sp.rem = states(e[:-10]) | float(-1) %}\n{% endif %}\n{% endfor %}\n{% if sp.id != '' and sp.rem >= 0 %}\n{% set s.matched = s.matched + 1 %}\n{% if single %}\n{% if n == aslot %}\n{% set s.active = true %}\n{% if sp.rem < job_g %}{% set s.short = true %}{% else %}{% set s.ok = true %}{% endif %}\n{% endif %}\n{% else %}\n{% if sp.rem < job_g %}{% set s.short = true %}{% else %}{% set s.ok = true %}{% endif %}\n{% endif %}\n{% endif %}\n{% endfor %}\n{% set v = namespace(state='unknown', label='check unavailable') %}\n{% if job_g <= 0 %}\n{% set v.state = 'none' %}\n{% set v.label = 'no slicer estimate yet' %}\n{% elif s.short %}\n{% set v.state = 'short' %}\n{% set v.label = 'NOT ENOUGH' %}\n{% elif s.ok %}\n{% set v.state = 'ok' %}\n{% set v.label = 'enough' %}\n{% elif single and aslot == '' %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'no active CFS slot' %}\n{% elif single and not s.active %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'active slot has no spool' %}\n{% elif s.matched == 0 %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'no spool loaded' %}\n{% endif %}\n{{ rem_g }} g left to print · {{ v.label }}", - "multiline_secondary": true, "grid_options": { "columns": 6, "rows": "auto" - } + }, + "icon": "mdi:scale-balance", + "icon_color": "{% set gcm = states('input_number.sparkx_i7_filament_g_cm') | float(0.0298) %}\n{% set lencm = states('sensor.sparkx_i7_expected_material_length') | float(0) %}\n{% set wgt = states('sensor.sparkx_i7_expected_material_weight') | float(0) %}\n{% set job_g = ((wgt if wgt > 0 else lencm * gcm) | round(1)) %}\n{% set used_g = ((states('sensor.sparkx_i7_used_material_length') | float(0)) * gcm) | round(1) %}\n{% set rem_g = ([job_g - used_g, 0] | max) | round(1) %}\n{% set gc = namespace(list=[]) %}\n{% for p in (state_attr('sensor.sparkx_i7_expected_material_length','color') | default('', true) | string).split(';') %}\n{% set q = p | replace('#','') | lower | trim %}\n{% if q not in ['','none','unknown','unavailable'] %}{% set gc.list = gc.list + [q] %}{% endif %}\n{% endfor %}\n{% set single = (gc.list | length) == 1 %}\n{% set aslot = (states('sensor.sparkx_i7_active_filament_slot') | default('', true) | string).split('_')[-1] %}\n{% set aslot = aslot if aslot in ['1','2','3','4'] else '' %}\n{% set s = namespace(short=false, ok=false, matched=0, active=false) %}\n{% for n in ['1','2','3','4'] %}\n{% set sp = namespace(id='', rem=-1) %}\n{% for e in integration_entities('spoolman') if e.endswith('_color_hex') %}\n{% if sp.id == '' and (state_attr(e[:-10],'location') | default('', true) | lower) == ('cfs lite ' ~ n) %}\n{% set sp.id = e[:-10] %}\n{% set sp.rem = states(e[:-10]) | float(-1) %}\n{% endif %}\n{% endfor %}\n{% if sp.id != '' and sp.rem >= 0 %}\n{% set s.matched = s.matched + 1 %}\n{% if single %}\n{% if n == aslot %}\n{% set s.active = true %}\n{% if sp.rem < job_g %}{% set s.short = true %}{% else %}{% set s.ok = true %}{% endif %}\n{% endif %}\n{% else %}\n{% if sp.rem < job_g %}{% set s.short = true %}{% else %}{% set s.ok = true %}{% endif %}\n{% endif %}\n{% endif %}\n{% endfor %}\n{% set v = namespace(state='unknown', label='check unavailable') %}\n{% if job_g <= 0 %}\n{% set v.state = 'none' %}\n{% set v.label = 'no slicer estimate yet' %}\n{% elif s.short %}\n{% set v.state = 'short' %}\n{% set v.label = 'NOT ENOUGH' %}\n{% elif s.ok %}\n{% set v.state = 'ok' %}\n{% set v.label = 'enough' %}\n{% elif single and aslot == '' %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'no active CFS slot' %}\n{% elif single and not s.active %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'active slot has no spool' %}\n{% elif s.matched == 0 %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'no spool loaded' %}\n{% endif %}\n{% if v.state == 'ok' %}green{% elif v.state == 'short' %}red{% elif v.state == 'none' %}grey{% else %}orange{% endif %}", + "multiline_secondary": true, + "name": "Filament Sufficiency", + "primary": "{% set gcm = states('input_number.sparkx_i7_filament_g_cm') | float(0.0298) %}\n{% set lencm = states('sensor.sparkx_i7_expected_material_length') | float(0) %}\n{% set wgt = states('sensor.sparkx_i7_expected_material_weight') | float(0) %}\n{% set job_g = ((wgt if wgt > 0 else lencm * gcm) | round(1)) %}\n{% set used_g = ((states('sensor.sparkx_i7_used_material_length') | float(0)) * gcm) | round(1) %}\n{% set rem_g = ([job_g - used_g, 0] | max) | round(1) %}\n{% set gc = namespace(list=[]) %}\n{% for p in (state_attr('sensor.sparkx_i7_expected_material_length','color') | default('', true) | string).split(';') %}\n{% set q = p | replace('#','') | lower | trim %}\n{% if q not in ['','none','unknown','unavailable'] %}{% set gc.list = gc.list + [q] %}{% endif %}\n{% endfor %}\n{% set single = (gc.list | length) == 1 %}\n{% set aslot = (states('sensor.sparkx_i7_active_filament_slot') | default('', true) | string).split('_')[-1] %}\n{% set aslot = aslot if aslot in ['1','2','3','4'] else '' %}\n{% set s = namespace(short=false, ok=false, matched=0, active=false) %}\n{% for n in ['1','2','3','4'] %}\n{% set sp = namespace(id='', rem=-1) %}\n{% for e in integration_entities('spoolman') if e.endswith('_color_hex') %}\n{% if sp.id == '' and (state_attr(e[:-10],'location') | default('', true) | lower) == ('cfs lite ' ~ n) %}\n{% set sp.id = e[:-10] %}\n{% set sp.rem = states(e[:-10]) | float(-1) %}\n{% endif %}\n{% endfor %}\n{% if sp.id != '' and sp.rem >= 0 %}\n{% set s.matched = s.matched + 1 %}\n{% if single %}\n{% if n == aslot %}\n{% set s.active = true %}\n{% if sp.rem < job_g %}{% set s.short = true %}{% else %}{% set s.ok = true %}{% endif %}\n{% endif %}\n{% else %}\n{% if sp.rem < job_g %}{% set s.short = true %}{% else %}{% set s.ok = true %}{% endif %}\n{% endif %}\n{% endif %}\n{% endfor %}\n{% set v = namespace(state='unknown', label='check unavailable') %}\n{% if job_g <= 0 %}\n{% set v.state = 'none' %}\n{% set v.label = 'no slicer estimate yet' %}\n{% elif s.short %}\n{% set v.state = 'short' %}\n{% set v.label = 'NOT ENOUGH' %}\n{% elif s.ok %}\n{% set v.state = 'ok' %}\n{% set v.label = 'enough' %}\n{% elif single and aslot == '' %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'no active CFS slot' %}\n{% elif single and not s.active %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'active slot has no spool' %}\n{% elif s.matched == 0 %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'no spool loaded' %}\n{% endif %}\n{{ job_g }} g needed · {{ used_g }} g used", + "secondary": "{% set gcm = states('input_number.sparkx_i7_filament_g_cm') | float(0.0298) %}\n{% set lencm = states('sensor.sparkx_i7_expected_material_length') | float(0) %}\n{% set wgt = states('sensor.sparkx_i7_expected_material_weight') | float(0) %}\n{% set job_g = ((wgt if wgt > 0 else lencm * gcm) | round(1)) %}\n{% set used_g = ((states('sensor.sparkx_i7_used_material_length') | float(0)) * gcm) | round(1) %}\n{% set rem_g = ([job_g - used_g, 0] | max) | round(1) %}\n{% set gc = namespace(list=[]) %}\n{% for p in (state_attr('sensor.sparkx_i7_expected_material_length','color') | default('', true) | string).split(';') %}\n{% set q = p | replace('#','') | lower | trim %}\n{% if q not in ['','none','unknown','unavailable'] %}{% set gc.list = gc.list + [q] %}{% endif %}\n{% endfor %}\n{% set single = (gc.list | length) == 1 %}\n{% set aslot = (states('sensor.sparkx_i7_active_filament_slot') | default('', true) | string).split('_')[-1] %}\n{% set aslot = aslot if aslot in ['1','2','3','4'] else '' %}\n{% set s = namespace(short=false, ok=false, matched=0, active=false) %}\n{% for n in ['1','2','3','4'] %}\n{% set sp = namespace(id='', rem=-1) %}\n{% for e in integration_entities('spoolman') if e.endswith('_color_hex') %}\n{% if sp.id == '' and (state_attr(e[:-10],'location') | default('', true) | lower) == ('cfs lite ' ~ n) %}\n{% set sp.id = e[:-10] %}\n{% set sp.rem = states(e[:-10]) | float(-1) %}\n{% endif %}\n{% endfor %}\n{% if sp.id != '' and sp.rem >= 0 %}\n{% set s.matched = s.matched + 1 %}\n{% if single %}\n{% if n == aslot %}\n{% set s.active = true %}\n{% if sp.rem < job_g %}{% set s.short = true %}{% else %}{% set s.ok = true %}{% endif %}\n{% endif %}\n{% else %}\n{% if sp.rem < job_g %}{% set s.short = true %}{% else %}{% set s.ok = true %}{% endif %}\n{% endif %}\n{% endif %}\n{% endfor %}\n{% set v = namespace(state='unknown', label='check unavailable') %}\n{% if job_g <= 0 %}\n{% set v.state = 'none' %}\n{% set v.label = 'no slicer estimate yet' %}\n{% elif s.short %}\n{% set v.state = 'short' %}\n{% set v.label = 'NOT ENOUGH' %}\n{% elif s.ok %}\n{% set v.state = 'ok' %}\n{% set v.label = 'enough' %}\n{% elif single and aslot == '' %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'no active CFS slot' %}\n{% elif single and not s.active %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'active slot has no spool' %}\n{% elif s.matched == 0 %}\n{% set v.state = 'unknown' %}\n{% set v.label = 'no spool loaded' %}\n{% endif %}\n{{ rem_g }} g left to print · {{ v.label }}", + "type": "custom:mushroom-template-card" }, { "heading": "Temperature", @@ -167,8 +167,8 @@ "name": "Flow", "severity": { "green": 0, - "yellow": 12, - "red": 24 + "red": 24, + "yellow": 12 }, "type": "gauge" }