mirror of
https://github.com/RunLit/Bambu-Run.git
synced 2026-06-22 22:19:03 +01:00
Add Vortek hotend rack tracking: per-SN registry with slot mapping confirmed against live MQTT capture, plus a fallback for non-inductive nozzles (e.g. H2C's fixed left nozzle) shown read-only without fabricated identity. New dashboard card hides entirely on printers with no Vortek/nozzle-info data at all.
This commit is contained in:
@@ -571,6 +571,38 @@ class Command(BaseCommand):
|
||||
match_method=match_method
|
||||
)
|
||||
|
||||
def _update_hotends(self, printer, printer_metric, hotends_data):
|
||||
from bambu_run.models import Hotend, HotendSnapshot
|
||||
|
||||
for h in hotends_data:
|
||||
if h.get("is_empty"):
|
||||
continue
|
||||
|
||||
hotend, _ = Hotend.objects.update_or_create(
|
||||
printer=printer,
|
||||
serial_number=h.get("serial_number"),
|
||||
defaults={
|
||||
"raw_id": h.get("raw_id", 0),
|
||||
"nozzle_type": h.get("nozzle_type", ""),
|
||||
"diameter": self._to_decimal(h.get("diameter")),
|
||||
"slot_number": h.get("slot_number"),
|
||||
"is_toolhead": bool(h.get("is_toolhead")),
|
||||
"last_filament_profile_id": h.get("fila_id", ""),
|
||||
"last_color": h.get("color") or "",
|
||||
"used_time_seconds": h.get("used_time_seconds", 0),
|
||||
"wear_percent": h.get("wear_percent", 0),
|
||||
},
|
||||
)
|
||||
|
||||
HotendSnapshot.objects.create(
|
||||
printer_metric=printer_metric,
|
||||
hotend=hotend,
|
||||
raw_id=h.get("raw_id", 0),
|
||||
used_time_seconds=h.get("used_time_seconds", 0),
|
||||
wear_percent=h.get("wear_percent", 0),
|
||||
stat=h.get("stat"),
|
||||
)
|
||||
|
||||
def _track_print_job(self, session, metric, snapshot):
|
||||
from bambu_run.models import PrintJob
|
||||
|
||||
@@ -757,12 +789,17 @@ class Command(BaseCommand):
|
||||
external_spool=snapshot.get("external_spool", {}),
|
||||
lights_report=snapshot.get("lights_report", []),
|
||||
vortek_raw=snapshot.get("vortek_raw", {}),
|
||||
nozzle_info=snapshot.get("hotends", []),
|
||||
)
|
||||
|
||||
filaments_data = snapshot.get('filaments', [])
|
||||
if filaments_data:
|
||||
self._create_filament_snapshots(metric, filaments_data, snapshot)
|
||||
|
||||
hotends_data = snapshot.get('hotends', [])
|
||||
if hotends_data:
|
||||
self._update_hotends(session.printer, metric, hotends_data)
|
||||
|
||||
self._track_print_job(session, metric, snapshot)
|
||||
|
||||
session.success_count += 1
|
||||
|
||||
Reference in New Issue
Block a user