This commit is contained in:
Home Assistant Version Control
2026-10-08 17:45:13 +00:00
parent 62c37588ba
commit 1b7ae00ddb
3 changed files with 174 additions and 23 deletions
@@ -0,0 +1,53 @@
# ha_mcp_backup
schema_version: 1
domain: automation
entity_id: automation.sparkx_i7_latch_print_spool_for_spoolman
captured: '2026-10-08T17:45:06.877265+00:00'
tool: ha_config_set_automation
config:
id: '1791477238762'
alias: SparkX i7 - Latch print spool for Spoolman
triggers:
- trigger: state
entity_id: sensor.sparkx_i7_print_status
to: printing
id: print_started
- trigger: state
entity_id: sensor.sparkx_i7_active_filament_slot
- trigger: state
entity_id:
- sensor.sparkx_i7_cfs_box_1_slot_1_color
- sensor.sparkx_i7_cfs_box_1_slot_2_color
- sensor.sparkx_i7_cfs_box_1_slot_3_color
- sensor.sparkx_i7_cfs_box_1_slot_4_color
conditions:
- condition: state
entity_id: sensor.sparkx_i7_print_status
state: printing
actions:
- choose:
- conditions:
condition: trigger
id: print_started
sequence:
- action: input_text.set_value
target:
entity_id: input_text.sparkx_i7_print_spool_latch
data:
value: ''
- variables:
spool_id: "{%- set slot = states('sensor.sparkx_i7_active_filament_slot') -%}\n\
{%- set ce = 'sensor.sparkx_i7_cfs_' ~ (slot | lower | replace(' ', '_'))\
\ ~ '_color' -%}\n{%- set color = states(ce) | replace('#', '') | lower -%}\n\
{%- set ns = namespace(id = '') -%}\n{%- for e in integration_entities('spoolman')\
\ -%}\n {%- if e.endswith('_color_hex') and (states(e) | lower) == color\
\ -%}\n {%- set ns.id = states(e[:-10] ~ '_id') -%}\n {%- endif -%}\n\
{%- endfor -%}\n{{ ns.id }}"
- condition: template
value_template: '{{ spool_id not in ['''', ''unknown'', ''unavailable''] }}'
- action: input_text.set_value
target:
entity_id: input_text.sparkx_i7_print_spool_latch
data:
value: '{{ spool_id }}'
mode: single
File diff suppressed because one or more lines are too long
+120 -23
View File
@@ -4426,6 +4426,12 @@
mode: single mode: single
- id: '1791477238762' - id: '1791477238762'
alias: SparkX i7 - Latch print spool for Spoolman alias: SparkX i7 - Latch print spool for Spoolman
description: 'Segment tracking for Spoolman: at print start resets the length checkpoint
and per-slot gram counters and latches the active CFS slot. On every slot change
mid-print, deducts the exact extrusion of the finished segment (used_material_length
delta x g/cm) from the Spoolman spool matching the previous slot color hex (only
if that spool has remaining weight), accumulates grams per slot, notifies on no-match,
then re-baselines the checkpoint and advances the latch.'
triggers: triggers:
- trigger: state - trigger: state
entity_id: sensor.sparkx_i7_print_status entity_id: sensor.sparkx_i7_print_status
@@ -4433,40 +4439,131 @@
id: print_started id: print_started
- trigger: state - trigger: state
entity_id: sensor.sparkx_i7_active_filament_slot entity_id: sensor.sparkx_i7_active_filament_slot
- trigger: state id: slot_changed
entity_id:
- sensor.sparkx_i7_cfs_box_1_slot_1_color
- sensor.sparkx_i7_cfs_box_1_slot_2_color
- sensor.sparkx_i7_cfs_box_1_slot_3_color
- sensor.sparkx_i7_cfs_box_1_slot_4_color
conditions: conditions:
- condition: state - condition: state
entity_id: sensor.sparkx_i7_print_status entity_id: sensor.sparkx_i7_print_status
state: printing state: printing
actions: actions:
- variables:
new_slot: '{{ states(''sensor.sparkx_i7_active_filament_slot'') }}'
old_slot: '{{ states(''input_text.sparkx_i7_print_spool_latch'') }}'
cur: '{{ states(''sensor.sparkx_i7_used_material_length'') | float(0) }}'
- choose: - choose:
- conditions: - conditions:
condition: trigger condition: trigger
id: print_started id: print_started
sequence: sequence:
- action: input_number.set_value
target:
entity_id: input_number.sparkx_i7_spoolman_length_checkpoint
data:
value: '{{ cur }}'
- action: input_number.set_value
target:
entity_id:
- input_number.sparkx_i7_slot_1_grams
- input_number.sparkx_i7_slot_2_grams
- input_number.sparkx_i7_slot_3_grams
- input_number.sparkx_i7_slot_4_grams
data:
value: 0
- action: input_text.set_value - action: input_text.set_value
target: target:
entity_id: input_text.sparkx_i7_print_spool_latch entity_id: input_text.sparkx_i7_print_spool_latch
data: data:
value: '' value: '{{ new_slot if new_slot not in [''unknown'', ''unavailable''] else
- variables: '''' }}'
spool_id: "{%- set slot = states('sensor.sparkx_i7_active_filament_slot') -%}\n{%- - conditions:
set ce = 'sensor.sparkx_i7_cfs_' ~ (slot | lower | replace(' ', '_')) ~ '_color' condition: template
-%}\n{%- set color = states(ce) | replace('#', '') | lower -%}\n{%- set ns value_template: '{{ old_slot not in ['''', ''unknown'', ''unavailable''] and
= namespace(id = '') -%}\n{%- for e in integration_entities('spoolman') -%}\n new_slot not in ['''', ''unknown'', ''unavailable''] and new_slot != old_slot
\ {%- if e.endswith('_color_hex') and (states(e) | lower) == color -%}\n {%- }}'
set ns.id = states(e[:-10] ~ '_id') -%}\n {%- endif -%}\n{%- endfor -%}\n{{ sequence:
ns.id }}" - variables:
- condition: template grams: '{{ (([cur | float - (states(''input_number.sparkx_i7_spoolman_length_checkpoint'')
value_template: '{{ spool_id not in ['''', ''unknown'', ''unavailable''] }}' | float(0)), 0] | max) * (states(''input_number.sparkx_i7_filament_g_cm'')
- action: input_text.set_value | float(0.03))) | round(2) }}'
target: color: '{{ states(''sensor.sparkx_i7_cfs_'' ~ (old_slot | lower | replace(''
entity_id: input_text.sparkx_i7_print_spool_latch '', ''_'')) ~ ''_color'') | replace(''#'', '''') | lower }}'
data: - variables:
value: '{{ spool_id }}' spool_id: '{% set ns = namespace(id='''') %}{% for e in integration_entities(''spoolman'')
mode: single %}{% if e.endswith(''_color_hex'') and (states(e) | replace(''#'', '''')
| lower) == color %}{% set b = e[:-10] %}{% if (states(b) | float(0))
> 0 and ns.id == '''' %}{% set ns.id = states(b ~ ''_id'') %}{% endif
%}{% endif %}{% endfor %}{{ ns.id }}'
- if:
condition: template
value_template: '{{ grams | float > 0 }}'
then:
- choose:
- conditions:
condition: template
value_template: '{{ spool_id not in ['''', ''unknown'', ''unavailable'']
}}'
sequence:
- action: spoolman.use_spool_filament
data:
id: '{{ spool_id | int(0) }}'
use_weight: '{{ grams | float(0) }}'
- if:
condition: template
value_template: '{{ old_slot.split('' '')[-1] in [''1'', ''2'', ''3'',
''4''] }}'
then:
- action: input_number.set_value
target:
entity_id: input_number.sparkx_i7_slot_{{ old_slot.split(' ')[-1]
}}_grams
data:
value: '{{ (states(''input_number.sparkx_i7_slot_'' ~ old_slot.split(''
'')[-1] ~ ''_grams'') | float(0)) + (grams | float) }}'
default:
- action: notify.persistent_notification
data:
title: 'Spoolman: no spool for slot color'
message: 'Segment of {{ grams }} g from {{ old_slot }} (color #{{ color
| upper }}) could not be deducted - no Spoolman spool with remaining
weight matches that color. Register the new roll in Spoolman, then
adjust manually if needed.'
- action: notify.mobile_app_francos_ipad
data:
title: 'Spoolman: no spool for slot color'
message: 'Segment of {{ grams }} g from {{ old_slot }} (color #{{ color
| upper }}) could not be deducted - no Spoolman spool with remaining
weight matches that color. Register the new roll in Spoolman, then
adjust manually if needed.'
- action: notify.mobile_app_sm_f956w
data:
title: 'Spoolman: no spool for slot color'
message: 'Segment of {{ grams }} g from {{ old_slot }} (color #{{ color
| upper }}) could not be deducted - no Spoolman spool with remaining
weight matches that color. Register the new roll in Spoolman, then
adjust manually if needed.'
- action: input_number.set_value
target:
entity_id: input_number.sparkx_i7_spoolman_length_checkpoint
data:
value: '{{ cur }}'
- action: input_text.set_value
target:
entity_id: input_text.sparkx_i7_print_spool_latch
data:
value: '{{ new_slot }}'
- conditions:
condition: template
value_template: '{{ old_slot in ['''', ''unknown'', ''unavailable''] and new_slot
not in ['''', ''unknown'', ''unavailable''] }}'
sequence:
- action: input_number.set_value
target:
entity_id: input_number.sparkx_i7_spoolman_length_checkpoint
data:
value: '{{ cur }}'
- action: input_text.set_value
target:
entity_id: input_text.sparkx_i7_print_spool_latch
data:
value: '{{ new_slot }}'
mode: queued
max: 10