automations.yaml, zigbee2mqtt/state.json

This commit is contained in:
Home Assistant Version Control committed 2026-10-14 14:01:09 +00:00
1 parent be225cebad
commit 75f5d6697e
2 files changed
+88 -11

No files matched your search

+77
View File
@@ -4772,3 +4772,80 @@
target:
entity_id: notify.franco
mode: single
- id: '1791477238799'
alias: SparkX i7 - Filament sufficiency check at print start
description: >-
When a print starts and stays printing for 45 s, compares the loaded CFS Lite
spools against the slicer's filament requirement. A single-material job is
checked exactly against its reported weight; a multi-material job has no
per-colour figure, so each loaded spool is compared against the whole job
total (worst case). Always sends a notification.
triggers:
- trigger: state
entity_id: sensor.sparkx_i7_print_status
to: printing
for: '00:00:45'
conditions: []
actions:
- variables:
gcm: "{{ states('input_number.sparkx_i7_filament_g_cm') | float(0.0298) }}"
length_cm: "{{ states('sensor.sparkx_i7_expected_material_length') | float(0) }}"
weight_g: "{{ states('sensor.sparkx_i7_expected_material_weight') | float(0) }}"
job_g: "{{ ((weight_g | float) if (weight_g | float) > 0 else (length_cm | float) * (gcm | float)) | round(1) }}"
gcol: "{{ state_attr('sensor.sparkx_i7_expected_material_length', 'color') | default('', true) | string | replace('#', '') | lower }}"
mono: "{{ (weight_g | float) > 0 and (gcol | length) <= 6 }}"
- variables:
report: |-
{% set ns = namespace(req=[], short=[], missing=[], loaded=[], avail=0) %}
{% set cols = namespace(list=[]) %}
{% for n in ['1','2','3','4'] %}{% set cc = states('sensor.sparkx_i7_cfs_box_1_slot_' ~ n ~ '_color') | replace('#','') | lower %}{% if cc not in ['','none','unknown','unavailable'] %}{% set cols.list = cols.list + [cc] %}{% endif %}{% endfor %}
{% set per_slot = gcol if (mono and gcol != '' and gcol in cols.list) else '' %}
{% set mono_offline = mono and gcol != '' and gcol not in cols.list %}
{% for n in ['1','2','3','4'] %}
{% set c = states('sensor.sparkx_i7_cfs_box_1_slot_' ~ n ~ '_color') | replace('#','') | lower %}
{% if c not in ['','none','unknown','unavailable'] %}
{% set cname = states('sensor.sparkx_i7_slot_' ~ n ~ '_color_name') %}
{% set flabel = states('sensor.sparkx_i7_cfs_box_1_slot_' ~ n ~ '_filament') %}
{% set label = 'Slot ' ~ n ~ ' ' ~ (cname if cname not in ['','unknown','unavailable'] else (flabel if flabel not in ['','unknown','unavailable'] else ('#' ~ (c | upper)))) %}
{% set sp = namespace(id='', rem=0) %}
{% for e in integration_entities('spoolman') if e.endswith('_color_hex') %}
{% if sp.id == '' and (states(e) | replace('#','') | lower) == c and (state_attr(e[:-10],'location') | default('', true) | lower) == 'cfs lite' %}
{% set sp.id = e[:-10] %}
{% set sp.rem = states(e[:-10]) | float(0) %}
{% endif %}
{% endfor %}
{% if sp.id != '' %}{% set ns.avail = ns.avail + sp.rem %}{% set ns.loaded = ns.loaded + [label ~ ': ' ~ (sp.rem | round(1)) ~ ' g'] %}{% endif %}
{% if job_g > 0 %}
{% set req = job_g if (per_slot == '' or c == per_slot) else 0 %}
{% if req > 0 %}
{% if sp.id == '' %}{% set ns.missing = ns.missing + [label ~ ' (#' ~ (c | upper) ~ ')'] %}
{% elif sp.rem < req %}{% set ns.short = ns.short + [label ~ ': ' ~ (sp.rem | round(1)) ~ ' g left, up to ' ~ req ~ ' g needed'] %}
{% else %}{% set ns.req = ns.req + [label ~ ': ' ~ (sp.rem | round(1)) ~ ' g left, up to ' ~ req ~ ' g needed'] %}{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% if job_g <= 0 %}Cannot verify: slicer filament estimate not available yet.{% if ns.loaded %} Loaded: {{ ns.loaded | join('; ') }}.{% endif %}
{% elif mono_offline %}Cannot verify: this looks like a single-colour print of #{{ gcol | upper }}, which is not in a loaded CFS slot.
{% elif ns.short %}NOT ENOUGH filament - possible shortfall:
{{ ns.short | join('\n') }}{% if ns.req %}
OK: {{ ns.req | join('; ') }}{% endif %}{% if ns.missing %}
No Spoolman spool matched for: {{ ns.missing | join(', ') }}{% endif %}
{% elif ns.req %}Enough filament:
{{ ns.req | join('\n') }}{% if ns.missing %}
No Spoolman spool matched for: {{ ns.missing | join(', ') }}{% endif %}
{% else %}Cannot verify: could not match this job's filament to a loaded CFS slot.{% endif %}
- action: notify.persistent_notification
data:
title: Print started - filament check
message: '{{ report }}'
- action: notify.mobile_app_francos_ipad
data:
title: Print started - filament check
message: '{{ report }}'
- action: notify.mobile_app_sm_f956w
data:
title: Print started - filament check
message: '{{ report }}'
mode: single