CC2 Control copies take the colour the printer reports for the tray
CI / test (push) Successful in 2m46s
CI / image (push) Successful in 50s

CC2 Control compares a spool's colour exactly with the tray's, which is the
tag's colour from the display palette (e.g. #F72221 for Spoolman's #FF0000),
and flags the slot or asks again when they differ. New copies take the
tag's colour; copies in a slot are set to the tray's colour, others keep
theirs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014GcEk5tkfFSYD6NTF66NkC
This commit is contained in:
Jonas MenzelandClaude Opus 5.5 committed 2026-10-25 22:53:12 +01:00
1 parent 87c5decc1c
commit d863287f1f
2 files changed
+42 -12

No files matched your search

+18 -5
View File
@@ -153,9 +153,13 @@ def cc2_spool_fields(sm: dict, channel: dict | None) -> tuple[dict, list[str]]:
material = new
if not material:
material = "PLA"
color = color_hex(sm)
# CC2 Control compares the spool's colour exactly with what the printer reports for the tray, which is
# the tag's (a colour of the display palette): take that, so it does not flag the slot or ask again
color = tagcodec.normalize_hex_color(str(channel.get("color") or "").replace("0x", ""))
if color is None:
color = tagcodec.normalize_hex_color(str(channel.get("color") or "").replace("0x", "")) or "000000"
color = color_hex(sm)
if color is None:
color = "000000"
notes.append(f"Spoolman-Spule hat keine Farbe; verwende #{color}")
fields: dict = {
"name": label(sm),
@@ -686,6 +690,12 @@ class PrinterWorker:
mapped = {m["cc2"]: int(k) for k, m in self.st["slots"].items() if m.get("cc2")}
in_tray = {s["spool_id"] for s in self.record_slots
if s["spool_id"] is not None and self.tray_status.get(s["slot"]) in (1, 2)}
tray_color = {} # copy in a slot -> the colour the printer reports there
for s in cc2.get("slots") or []:
c = (s.get("printer") or {}).get("color") if isinstance(s.get("printer"), dict) else None
c = tagcodec.normalize_hex_color(str(c or "").replace("0x", ""))
if slot_spool_id(s) and c:
tray_color[slot_spool_id(s)] = c
for sp in cc2.get("spools") or []:
smid = spoolman_id_of(sp)
if smid is None:
@@ -711,14 +721,17 @@ class PrinterWorker:
continue
if sp.get("archived"):
continue
self._sync_fields(cid, sp, sm, name)
self._sync_fields(cid, sp, sm, name, tray_color.get(cid))
if cid in mapped:
self._sync_remaining(cid, sp, sm, name)
except CC2Error as e:
self._log("error", f"{name}: {e}")
def _sync_fields(self, cid: str, sp: dict, sm: dict, name: str) -> None:
fields, _ = cc2_spool_fields(sm, None)
def _sync_fields(self, cid: str, sp: dict, sm: dict, name: str, tray_color: str | None) -> None:
"""Master data from Spoolman; the colour only for a copy in a slot, and then the printer's colour there."""
fields, _ = cc2_spool_fields(sm, {"color": tray_color} if tray_color else None)
if not tray_color:
fields.pop("color", None)
changed = {}
for key, want in fields.items():
if key in ("remaining", "note", "material"):