automations.yaml, zigbee2mqtt/state.json
This commit is contained in:
@@ -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
|
||||
|
||||
+11
-11
@@ -4,7 +4,7 @@
|
||||
"state": "ON",
|
||||
"led_brightness": 100,
|
||||
"countdown_to_turn_off": 0,
|
||||
"voltage": 119.4,
|
||||
"voltage": 119.9,
|
||||
"countdown_to_turn_on": 0,
|
||||
"ac_frequency": 60,
|
||||
"power_factor": 0.14,
|
||||
@@ -58,7 +58,7 @@
|
||||
"latest_release_notes": null
|
||||
},
|
||||
"linkquality": 145,
|
||||
"power": 85.8,
|
||||
"power": 85.6,
|
||||
"current": 0.79,
|
||||
"power_on_behavior": "on"
|
||||
},
|
||||
@@ -74,12 +74,12 @@
|
||||
"led_brightness": 100,
|
||||
"countdown_to_turn_off": 0,
|
||||
"countdown_to_turn_on": 0,
|
||||
"voltage": 116.4,
|
||||
"voltage": 118.3,
|
||||
"state": "ON",
|
||||
"ac_frequency": 60,
|
||||
"energy": 220.79,
|
||||
"power": 421.2,
|
||||
"current": 3.7,
|
||||
"energy": 220.8,
|
||||
"power": 430.3,
|
||||
"current": 3.71,
|
||||
"power_factor": 0.99,
|
||||
"update": {
|
||||
"state": "idle",
|
||||
@@ -96,9 +96,9 @@
|
||||
"countdown_to_turn_off": 0,
|
||||
"countdown_to_turn_on": 0,
|
||||
"voltage": 119.4,
|
||||
"energy": 103.52,
|
||||
"energy": 103.53,
|
||||
"state": "ON",
|
||||
"power": 19.2,
|
||||
"power": 18.6,
|
||||
"current": 0.28,
|
||||
"ac_frequency": 60,
|
||||
"power_factor": 0.54,
|
||||
@@ -114,7 +114,7 @@
|
||||
},
|
||||
"0xffffb40e060895b3": {
|
||||
"state": "ON",
|
||||
"voltage": 119.2,
|
||||
"voltage": 119.7,
|
||||
"ac_frequency": 60,
|
||||
"energy": 15.19,
|
||||
"current": 0.01,
|
||||
@@ -136,14 +136,14 @@
|
||||
"0xffffb40e0608864e": {
|
||||
"led_brightness": 100,
|
||||
"countdown_to_turn_off": 0,
|
||||
"voltage": 119.2,
|
||||
"voltage": 119.7,
|
||||
"energy": 36.92,
|
||||
"countdown_to_turn_on": 0,
|
||||
"state": "ON",
|
||||
"current": 0.02,
|
||||
"ac_frequency": 60,
|
||||
"power": 0.4,
|
||||
"power_factor": 0.15,
|
||||
"power_factor": 0.14,
|
||||
"update": {
|
||||
"state": "idle",
|
||||
"installed_version": 268513381,
|
||||
|
||||
Reference in New Issue
Block a user