This commit is contained in:
Home Assistant Version Control
2026-10-08 17:53:01 +00:00
parent 3735908183
commit 57950cba9c
4 changed files with 77 additions and 14 deletions
+42 -6
View File
@@ -243,18 +243,54 @@ light_color_temp_helper:
spoolman_set_spool_remaining:
alias: Spoolman - Set Spool Remaining
fields:
slot:
name: CFS Slot
description: CFS slot number 1-4 - resolves the spool by the slot color hex
selector:
number:
min: 1
max: 4
mode: box
spool_id:
required: true
name: Spool ID
description: Direct Spoolman spool ID - used when no slot is given
selector:
number:
min: 1
max: 9999
mode: box
sequence:
- action: spoolman.patch_spool
data:
id: '{{ spool_id | int(0) }}'
remaining_weight: '{{ states(''input_number.spoolman_set_remaining'') | float(0)
}}'
- variables:
resolved_id: '{% set n = (slot | int(0)) if slot is defined else 0 %}{% if n
>= 1 %}{% set color = states(''sensor.sparkx_i7_cfs_box_1_slot_'' ~ (n | int)
~ ''_color'') | replace(''#'', '''') | lower %}{% set ns = namespace(id='''')
%}{% for e in integration_entities(''spoolman'') %}{% if e.endswith(''_color_hex'')
and (states(e) | replace(''#'', '''') | lower) == color and ns.id == ''''
%}{% set ns.id = states(e[:-10] ~ ''_id'') %}{% endif %}{% endfor %}{{ ns.id
}}{% else %}{{ (spool_id | int(0)) if spool_id is defined else 0 }}{% endif
%}'
slot_n: '{{ (slot | int(0)) if slot is defined else 0 }}'
- choose:
- conditions:
condition: template
value_template: '{{ resolved_id | int(0) > 0 }}'
sequence:
- action: spoolman.patch_spool
data:
id: '{{ resolved_id | int(0) }}'
remaining_weight: '{{ states(''input_number.spoolman_set_remaining'') |
float(0) }}'
default:
- action: notify.persistent_notification
data:
title: Spoolman - remaining not set
message: '{% if slot_n | int >= 1 %}No Spoolman spool matched CFS slot {{
slot_n }} (color {{ states(''sensor.sparkx_i7_cfs_box_1_slot_'' ~ (slot_n
| int) ~ ''_color'') }}) - register a spool with that color hex in Spoolman,
then try again.{% else %}No spool resolved - pass spool_id or a CFS slot
1-4. Nothing was set.{% endif %}'
mode: single
description: Sets a Spoolman spool remaining weight from the shared helper input_number.spoolman_set_remaining.
Pass slot (1-4) to resolve the spool by the CFS slot color hex (no remaining-weight
guard, so an exhausted spool can be reset to full), or pass spool_id directly.
Notifies via persistent notification when nothing could be resolved.