Parcourir la source

Fix support bundle reporting 0 AMS units

raw_data["ams"] is stored as a list by the MQTT handler, but the
support info code only checked for a nested dict format. AMS unit
and tray counts were always 0.
maziggy il y a 3 mois
Parent
commit
a5706fe20a
2 fichiers modifiés avec 11 ajouts et 7 suppressions
  1. 1 0
      CHANGELOG.md
  2. 10 7
      backend/app/api/routes/support.py

+ 1 - 0
CHANGELOG.md

@@ -41,6 +41,7 @@ All notable changes to Bambuddy will be documented in this file.
 - **Energy Cost Shows 0.00 in "Total Consumption" Mode** ([#284](https://github.com/maziggy/bambuddy/issues/284)) — Statistics Quick Stats showed 0.00 energy cost when Energy Display Mode was set to "Total Consumption" with Home Assistant smart plugs. The `homeassistant_service` was not configured with HA URL/token before querying plug energy data, causing it to silently return nothing.
 - **H2D Pro Prints Fail at ~75% With Extrusion Motor Overload** ([#245](https://github.com/maziggy/bambuddy/issues/245)) — H2D Pro firmware interprets `use_ams: 1` (integer) as a nozzle index, routing filament to the deputy nozzle instead of the main nozzle. Bambu Studio sends `use_ams: true` (boolean) while using integers for other fields. Fixed by keeping `use_ams` as boolean for all printers including H2D series.
 - **GitHub Backup Description Misleading** — The "App Settings" backup card said "excludes sensitive data" but the complete database is pushed. Updated description to "complete database."
+- **Support Bundle Shows 0 AMS Units** — The support info always reported `ams_unit_count: 0` because it expected `raw_data["ams"]` to be a nested dict (`{"ams": [...]}`) but the MQTT handler stores it as a flat list. Now handles both formats.
 
 ### Documentation
 - **Supported Printers Updated** — Updated README, website, and wiki to list all 12 supported Bambu Lab printer models: X1, X1C, X1E, P1P, P1S, P2S, A1, A1 Mini, H2D, H2D Pro, H2C, H2S. Removed outdated "Testers Needed" messaging and Tested/Needs Testing distinctions — all models are now uniformly listed as supported. Added H2C printer image to website. Added H2D Pro, H2C columns to wiki feature comparison tables and new P2 Series section.

+ 10 - 7
backend/app/api/routes/support.py

@@ -463,13 +463,16 @@ async def _collect_support_info() -> dict:
             has_vt_tray = False
             if state:
                 ams_data = state.raw_data.get("ams")
-                if isinstance(ams_data, dict) and "ams" in ams_data:
-                    ams_units = ams_data["ams"]
-                    if isinstance(ams_units, list):
-                        ams_unit_count = len(ams_units)
-                        for unit in ams_units:
-                            trays = unit.get("tray", [])
-                            ams_tray_count += len([t for t in trays if t.get("tray_type")])
+                if isinstance(ams_data, list):
+                    ams_units = ams_data
+                elif isinstance(ams_data, dict) and "ams" in ams_data:
+                    ams_units = ams_data["ams"] if isinstance(ams_data["ams"], list) else []
+                else:
+                    ams_units = []
+                ams_unit_count = len(ams_units)
+                for unit in ams_units:
+                    trays = unit.get("tray", [])
+                    ams_tray_count += len([t for t in trays if t.get("tray_type")])
                 has_vt_tray = state.raw_data.get("vt_tray") is not None
 
             info["printers"].append(