mirror of
https://github.com/RunLit/Bambu-Run.git
synced 2026-06-24 15:00:18 +01:00
Feature/multi printer support (#12)
* Initial implementation of multi-printer support. * Always show device dropdown and add bambu_diagnose for multi-printer troubleshooting. * Add multi-AMS support: per-unit snapshot/usage tracking, grouped dashboard panels with real type labels, and dual-nozzle card UX fixes. Fixes a real-world AMS info-code parsing bug found by inspecting live H2C data. * 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:
22
bambu_run/migrations/0005_printermetrics_vortek_raw.py
Normal file
22
bambu_run/migrations/0005_printermetrics_vortek_raw.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 5.2.8 on 2026-06-18 12:20
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bambu_run", "0004_h2c_dual_nozzle_and_ams_fields"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="printermetrics",
|
||||
name="vortek_raw",
|
||||
field=models.JSONField(
|
||||
blank=True,
|
||||
default=dict,
|
||||
help_text="Raw print.device MQTT payload (Vortek rack groundwork)",
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,63 @@
|
||||
# Generated by Django 5.2.8 on 2026-06-20 12:40
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bambu_run", "0005_printermetrics_vortek_raw"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name="filamentsnapshot",
|
||||
options={
|
||||
"ordering": ["printer_metric", "ams_unit_id", "tray_id"],
|
||||
"verbose_name": "Filament Snapshot",
|
||||
"verbose_name_plural": "Filament Snapshots",
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="filamentsnapshot",
|
||||
name="ams_type",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
choices=[
|
||||
("AMS", "AMS"),
|
||||
("AMS 2 Pro", "AMS 2 Pro"),
|
||||
("AMS HT", "AMS HT"),
|
||||
],
|
||||
default="",
|
||||
help_text="Type of the AMS unit this tray belongs to (AMS / AMS 2 Pro / AMS HT)",
|
||||
max_length=32,
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="filamentsnapshot",
|
||||
name="ams_unit_id",
|
||||
field=models.PositiveSmallIntegerField(
|
||||
blank=True,
|
||||
db_index=True,
|
||||
help_text="Which physical AMS unit this tray belongs to (matches MQTT ams[i].id; 128 = AMS HT)",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="filamentusage",
|
||||
name="ams_unit_id",
|
||||
field=models.PositiveSmallIntegerField(
|
||||
blank=True,
|
||||
db_index=True,
|
||||
help_text="Which physical AMS unit the slot belongs to (matches MQTT ams[i].id; 128 = AMS HT)",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name="filamentsnapshot",
|
||||
index=models.Index(
|
||||
fields=["printer_metric", "ams_unit_id", "tray_id"],
|
||||
name="infrastruct_printer_2ad168_idx",
|
||||
),
|
||||
),
|
||||
]
|
||||
172
bambu_run/migrations/0007_hotend_hotendsnapshot.py
Normal file
172
bambu_run/migrations/0007_hotend_hotendsnapshot.py
Normal file
@@ -0,0 +1,172 @@
|
||||
# Generated by Django 5.2.8 on 2026-06-20 14:07
|
||||
|
||||
import django.db.models.deletion
|
||||
import django.utils.timezone
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bambu_run", "0006_alter_filamentsnapshot_options_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="Hotend",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("serial_number", models.CharField(db_index=True, max_length=100)),
|
||||
(
|
||||
"nozzle_type",
|
||||
models.CharField(blank=True, default="", max_length=50),
|
||||
),
|
||||
(
|
||||
"diameter",
|
||||
models.DecimalField(
|
||||
blank=True, decimal_places=2, max_digits=3, null=True
|
||||
),
|
||||
),
|
||||
(
|
||||
"raw_id",
|
||||
models.PositiveSmallIntegerField(
|
||||
help_text="Last-seen MQTT device.nozzle.info[].id"
|
||||
),
|
||||
),
|
||||
(
|
||||
"slot_number",
|
||||
models.PositiveSmallIntegerField(
|
||||
blank=True,
|
||||
help_text="Rack bay 1-6, derived from raw_id 16-21. Null if currently unknown (e.g. mounted on toolhead and id reports as the 0 sentinel).",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"is_toolhead",
|
||||
models.BooleanField(
|
||||
default=False,
|
||||
help_text="True if currently mounted on the toolhead under normal polling (raw_id == 0).",
|
||||
),
|
||||
),
|
||||
(
|
||||
"last_filament_profile_id",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
default="",
|
||||
help_text="Bambu material profile id of the filament last loaded (MQTT fila_id, e.g. 'GFA01')",
|
||||
max_length=20,
|
||||
),
|
||||
),
|
||||
(
|
||||
"last_color",
|
||||
models.CharField(
|
||||
blank=True,
|
||||
default="",
|
||||
help_text="6-char hex of the filament last loaded (MQTT color_m, alpha stripped)",
|
||||
max_length=6,
|
||||
),
|
||||
),
|
||||
("used_time_seconds", models.PositiveIntegerField(default=0)),
|
||||
(
|
||||
"wear_percent",
|
||||
models.DecimalField(
|
||||
decimal_places=2,
|
||||
default=0,
|
||||
help_text="MQTT wear (0-128 scale) converted to a 0-100 percent",
|
||||
max_digits=5,
|
||||
),
|
||||
),
|
||||
("last_seen_at", models.DateTimeField(auto_now=True)),
|
||||
("created_at", models.DateTimeField(auto_now_add=True)),
|
||||
(
|
||||
"printer",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="hotends",
|
||||
to="bambu_run.printer",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Hotend",
|
||||
"verbose_name_plural": "Hotends",
|
||||
"db_table": "infrastructure_hotend",
|
||||
"ordering": ["printer", "-is_toolhead", "slot_number", "serial_number"],
|
||||
"unique_together": {("printer", "serial_number")},
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="HotendSnapshot",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name="ID",
|
||||
),
|
||||
),
|
||||
("raw_id", models.PositiveSmallIntegerField()),
|
||||
("used_time_seconds", models.PositiveIntegerField(default=0)),
|
||||
(
|
||||
"wear_percent",
|
||||
models.DecimalField(decimal_places=2, default=0, max_digits=5),
|
||||
),
|
||||
(
|
||||
"stat",
|
||||
models.IntegerField(
|
||||
blank=True,
|
||||
help_text="Raw MQTT status code for this hotend",
|
||||
null=True,
|
||||
),
|
||||
),
|
||||
(
|
||||
"timestamp",
|
||||
models.DateTimeField(
|
||||
db_index=True, default=django.utils.timezone.now
|
||||
),
|
||||
),
|
||||
(
|
||||
"hotend",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="snapshots",
|
||||
to="bambu_run.hotend",
|
||||
),
|
||||
),
|
||||
(
|
||||
"printer_metric",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="hotend_snapshots",
|
||||
to="bambu_run.printermetrics",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
"verbose_name": "Hotend Snapshot",
|
||||
"verbose_name_plural": "Hotend Snapshots",
|
||||
"db_table": "infrastructure_hotend_snapshot",
|
||||
"ordering": ["printer_metric", "hotend"],
|
||||
"indexes": [
|
||||
models.Index(
|
||||
fields=["printer_metric", "hotend"],
|
||||
name="infrastruct_printer_b528aa_idx",
|
||||
),
|
||||
models.Index(
|
||||
fields=["hotend", "-timestamp"],
|
||||
name="infrastruct_hotend__691f7e_idx",
|
||||
),
|
||||
],
|
||||
},
|
||||
),
|
||||
]
|
||||
22
bambu_run/migrations/0008_printermetrics_nozzle_info.py
Normal file
22
bambu_run/migrations/0008_printermetrics_nozzle_info.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# Generated by Django 5.2.8 on 2026-06-20 14:22
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bambu_run", "0007_hotend_hotendsnapshot"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="printermetrics",
|
||||
name="nozzle_info",
|
||||
field=models.JSONField(
|
||||
blank=True,
|
||||
default=list,
|
||||
help_text="Parsed per-poll nozzle/hotend info list",
|
||||
),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user