Просмотр исходного кода

Fix P1S/P1P printer card showing "Printing" when idle (#813)

  Some P1S/P1P firmware reports stg_cur=0 when idle, which maps to
  the "Printing" stage name and overrides the correct IDLE gcode_state
  on the printer card. Extend the existing A1/A1 Mini stg_cur idle bug
  workaround to also cover P1S and P1P models.
maziggy 5 месяцев назад
Родитель
Сommit
7d94bf7896
2 измененных файлов с 18 добавлено и 4 удалено
  1. 1 0
      CHANGELOG.md
  2. 17 4
      backend/app/services/printer_manager.py

+ 1 - 0
CHANGELOG.md

@@ -48,6 +48,7 @@ All notable changes to Bambuddy will be documented in this file.
 - **SpoolBuddy Update Columns Missing from Database** — The OTA update feature added `update_status` and `update_message` to the device model but was missing the database migration, causing "no such column" errors on existing installations.
 - **Queue Print Command Not Reaching Printer** ([#778](https://github.com/maziggy/bambuddy/issues/778)) — When a queue item targeted a specific printer and the scheduler's power-on-wait loop triggered, each reconnection attempt created a new MQTT client that re-attempted subscribing to the request topic. On printers whose broker rejects this subscription (e.g. A1), this caused repeated connect/disconnect cycles for up to 170 seconds, leaving the MQTT connection in a fragile state where the print command could silently fail to reach the printer. Fixed by caching request topic support state per serial number at the class level, so new client instances skip the subscription immediately instead of rediscovering the rejection. Reported by @RubenKremer.
 - **Stale MQTT Connection Not Recovering** ([#813](https://github.com/maziggy/bambuddy/issues/813)) — When a printer's MQTT connection went stale (no messages for 60+ seconds), Bambuddy marked it as disconnected but did not force the underlying TCP socket closed, so paho-mqtt's auto-reconnect never triggered and print commands were silently published into a dead connection. Additionally, the spurious-disconnect filter (designed to ignore false disconnect callbacks from paho) used a 30-second window that could suppress real keepalive-timeout disconnects (which fire at ~22.5s with keepalive=15s). Fixed by: (1) never suppressing error disconnects (`rc.is_failure`) regardless of timing, and tightening the spurious filter window from 30s to 10s; (2) force-closing the socket on stale detection so paho's loop thread detects the break and auto-reconnects. Reported by @inkdawgz.
+- **P1S/P1P Printer Card Shows "Printing" When Idle** ([#813](https://github.com/maziggy/bambuddy/issues/813)) — Some P1S and P1P firmware versions report `stg_cur=0` when idle, which maps to the "Printing" stage name and overrides the correct "Idle" gcode_state on the printer card. The System Info page was unaffected because it displays the raw gcode_state. Extended the existing A1/A1 Mini workaround for this firmware bug to also cover P1S and P1P models. Reported by @inkdawgz.
 - **AMS Slot Search Shows Unrelated Profiles** ([#681](https://github.com/maziggy/bambuddy/issues/681)) — Searching for a non-existent filament profile in the AMS slot configuration showed unrelated profiles instead of an empty result. The saved preset bypassed the search filter entirely, so stale mappings (e.g. a slot previously configured with "Bambu PLA Matte" that now holds a Silk spool) would always appear regardless of the search query. The saved preset now only bypasses the printer model filter, not the search filter. Reported by @RosdasHH.
 - **Virtual Printer FTP Routed to Wrong VP** ([#735](https://github.com/maziggy/bambuddy/issues/735)) — When running multiple virtual printers with different access codes on separate bind IPs, FTP connections were routed to the wrong VP. Root cause: the iptables `REDIRECT` rule rewrites the destination IP to the incoming interface's primary address, so all FTP traffic went to the first VP regardless of the intended target. Fix: FTP server now binds directly to port 990 (standard implicit FTPS), eliminating the need for iptables redirect. Requires `CAP_NET_BIND_SERVICE` (already set in the systemd service and Docker image). Also removed a global `set_exception_handler()` in the MQTT server that caused spurious error messages when running multiple VPs. See `docs/migration-vp-ftp-port.md` for migration steps. Reported by @VREmma.
 - **X1C Virtual Printer Not Accepting Sends** ([#735](https://github.com/maziggy/bambuddy/issues/735)) — X1C (and X1) virtual printers were advertised with legacy SSDP model codes (`3DPrinter-X1-Carbon` / `3DPrinter-X1`) that BambuStudio doesn't recognize, causing "incompatible printer preset" when sending. Fixed to use the correct codes (`BL-P001` / `BL-P002`). Also fixed proxy mode auto-inherit storing the printer's display name (e.g. `X1C`) instead of the SSDP code. Existing VPs are automatically migrated on startup. Reported by @RosdasHH.

+ 17 - 4
backend/app/services/printer_manager.py

@@ -55,6 +55,19 @@ A1_MODELS = frozenset(
     ]
 )
 
+# Models affected by the stg_cur=0 idle bug (firmware reports stg_cur=0 when idle,
+# which maps to "Printing" in STAGE_NAMES and overrides the correct IDLE state)
+STG_CUR_IDLE_BUG_MODELS = A1_MODELS | frozenset(
+    [
+        # Display names
+        "P1P",
+        "P1S",
+        # Internal codes (from MQTT/SSDP)
+        "C11",  # P1P
+        "C12",  # P1S
+    ]
+)
+
 
 def supports_chamber_temp(model: str | None) -> bool:
     """Check if a printer model has a real chamber temperature sensor.
@@ -72,14 +85,14 @@ def supports_chamber_temp(model: str | None) -> bool:
 def has_stg_cur_idle_bug(model: str | None) -> bool:
     """Check if a printer model may incorrectly report stg_cur=0 when idle.
 
-    Some A1/A1 Mini firmware versions report stg_cur=0 (which maps to "Printing")
-    even when the printer is idle. This is a known firmware bug that was observed
-    in the Home Assistant Bambu Lab integration.
+    Some firmware versions report stg_cur=0 (which maps to "Printing")
+    even when the printer is idle. Originally observed on A1/A1 Mini via the
+    Home Assistant Bambu Lab integration, also confirmed on P1S.
     """
     if not model:
         return False
     model_upper = model.strip().upper()
-    return model_upper in A1_MODELS
+    return model_upper in STG_CUR_IDLE_BUG_MODELS
 
 
 # Minimum firmware versions for AMS drying support (confirmed via capture testing)