The AMS-slot -> Spoolman-spool persistence never worked: KobraXBridge referenced `config_loader` in both the load (__init__) and save (handle_kx_spoolman_set_active) paths, but the module alias is `env_loader` (kobrax_moonraker_bridge.py:32). The resulting NameError was swallowed by a bare `except`, so the map was neither loaded on startup nor written on change - it only appeared to persist. The map also lived in a single global `[spoolman] slot_spools` key, so on a multi-printer bridge two AMS units clobbered each other's mapping (same class of bug as #74/#75 for filament profiles). - config_loader: add list_spool_map()/save_spool_map(printer_id) using a per-printer `[spoolman_<id>]` section with read-fallback to the legacy global key, mirroring _filament_section/list_filament_profiles. The global `[spoolman]` section keeps server/sync_rate. - bridge: load via config_loader.list_spool_map(self._printer_id); persist via save_spool_map(..., self._printer_id); surface failures via log.warning instead of a silent except. - _build_mmu_object: emit real gate_spool_id from the per-printer map (was hardcoded [-1]*num_gates) so Happy-Hare/OrcaSlicer can show the bound spool. - config.ini.example: document the [spoolman] section. - tests: tests/test_spoolman_slot_map.py (per-printer isolation, persistence round-trip, server/sync_rate preservation, parser robustness). Verified on a 2-printer bridge: after restart KX1 loads its spools and KX2 loads its own, isolated; a real multicolor print deducted per slot (white spool 1.02g vs 0.98g slicer estimate) against the correct printer's spools. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
111 lines
3.7 KiB
Plaintext
111 lines
3.7 KiB
Plaintext
# KX-Bridge Konfigurationsdatei
|
|
# Kopiere diese Datei nach config.ini und trage deine Werte ein:
|
|
# cp config.ini.example config.ini
|
|
#
|
|
# Credentials automatisch eintragen:
|
|
# python3 tools/fetch_credentials.py --ip 192.168.x.x --write-config
|
|
# Alternativ (Windows, ohne Drucker-IP bekannt):
|
|
# extract_credentials.exe --write-env (liest aus laufendem AnycubicSlicerNext)
|
|
|
|
[connection]
|
|
# IP-Adresse des Druckers im lokalen Netzwerk
|
|
printer_ip = 192.168.x.x
|
|
|
|
# MQTT-Port (Anycubic Kobra X Standard: 9883)
|
|
mqtt_port = 9883
|
|
|
|
# MQTT-Zugangsdaten (druckerspezifisch, beginnt mit "user")
|
|
username = userXXXXXXXXXX
|
|
password = XXXXXXXXXXXXXXX
|
|
|
|
# Geräte-ID (32-stelliger Hex-String, druckerspezifisch)
|
|
device_id = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
|
|
# Modell-ID (Kobra X Standard: 20030)
|
|
mode_id = 20030
|
|
|
|
[print]
|
|
# Standard-AMS-Slot für Einfarbdruck (auto = alle belegten Slots, 0-3 = fixer Slot)
|
|
default_ams_slot = auto
|
|
|
|
# Auto-Leveling vor jedem Druck (1 = an, 0 = aus)
|
|
auto_leveling = 1
|
|
|
|
# Kamera-Stream bei Druckstart automatisch einschalten (1 = an, 0 = aus)
|
|
camera_on_print = 0
|
|
|
|
# Warnung vor Druck von Web-Uploads (1 = an, 0 = aus)
|
|
web_upload_warning = 1
|
|
|
|
[bridge]
|
|
# Poll-Intervall in Sekunden
|
|
poll_interval = 3
|
|
|
|
# ─── Spoolman (optional) ───────────────────────────────────────────────────────
|
|
# Verfolgt den Filamentverbrauch je AMS-Slot und bucht ihn automatisch vom
|
|
# passenden Spool ab (mm-basiert, wie Moonraker; Spoolman rechnet mm→Gramm).
|
|
# [spoolman]
|
|
# # Server-URL der Spoolman-Instanz (aus Sicht des Bridge-Containers erreichbar):
|
|
# server = http://192.168.x.x:7912
|
|
# # 0 = nur am Druckende abbuchen, >0 = alle N Sekunden während des Drucks:
|
|
# sync_rate = 0
|
|
#
|
|
# Die AMS-Slot → Spool-Zuordnung wird in der Weboberfläche gesetzt und je Drucker
|
|
# automatisch persistiert (nicht von Hand eintragen):
|
|
# Einzeldrucker : [spoolman] slot_spools = 0:42,1:17
|
|
# Multi-Printer : [spoolman_1] slot_spools = 0:42,1:17
|
|
# [spoolman_2] slot_spools = 0:5,1:6
|
|
|
|
# ─── Multi-Printer (optional) ──────────────────────────────────────────────────
|
|
# Mehrere Drucker können als [printer_1], [printer_2], … definiert werden.
|
|
# Jede Bridge-Instanz verbindet sich mit einem Drucker (je eigener Port).
|
|
# bridge_url zeigt auf die jeweilige Bridge-Instanz (für den /kx/printers-Endpunkt).
|
|
# Die [connection]-Sektion wird weiterhin als Fallback für diese Instanz verwendet.
|
|
#
|
|
# Beispiel:
|
|
# [printer_1]
|
|
# name = Kobra X Links
|
|
# bridge_url = http://192.168.178.95:7125
|
|
# printer_ip = 192.168.178.95
|
|
# mqtt_port = 9883
|
|
# username = userXXXXXXXXXX
|
|
# password = XXXXXXXXXXXXXXX
|
|
# device_id = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
# mode_id = 20030
|
|
#
|
|
# [printer_2]
|
|
# name = Kobra X Rechts
|
|
# bridge_url = http://192.168.178.96:7125
|
|
# printer_ip = 192.168.178.96
|
|
# mqtt_port = 9883
|
|
# username = userYYYYYYYYYY
|
|
# password = YYYYYYYYYYYYYYY
|
|
# device_id = yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
|
# mode_id = 20030
|
|
|
|
[ace_dry_presets]
|
|
# Vordefinierte Dry-Set Presets (Temp in °C, Dauer in Sekunden)
|
|
pla_temp = 45
|
|
pla_duration_sec = 14400
|
|
pla_plus_temp = 45
|
|
pla_plus_duration_sec = 14400
|
|
petg_temp = 50
|
|
petg_duration_sec = 14400
|
|
tpu_temp = 55
|
|
tpu_duration_sec = 14400
|
|
abs_asa_temp = 45
|
|
abs_asa_duration_sec = 28800
|
|
pa_pc_temp = 55
|
|
pa_pc_duration_sec = 43200
|
|
|
|
# Custom Presets (Name + Temp + Dauer)
|
|
custom_1_name = Custom 1
|
|
custom_1_temp = 45
|
|
custom_1_duration_sec = 14400
|
|
custom_2_name = Custom 2
|
|
custom_2_temp = 45
|
|
custom_2_duration_sec = 14400
|
|
custom_3_name = Custom 3
|
|
custom_3_temp = 45
|
|
custom_3_duration_sec = 14400
|