Jelajahi Sumber

Fix developer mode detection always reporting null

The MQTT "fun" field is an integer in the JSON payload, but the
parser used int(value, 16) which requires a string. This raised
TypeError on every message, silently swallowed by the except clause,
so developer_mode was never set.
maziggy 3 bulan lalu
induk
melakukan
257b4748e5
2 mengubah file dengan 5 tambahan dan 1 penghapusan
  1. 3 0
      CHANGELOG.md
  2. 2 1
      backend/app/services/bambu_mqtt.py

+ 3 - 0
CHANGELOG.md

@@ -4,6 +4,9 @@ All notable changes to Bambuddy will be documented in this file.
 
 ## [0.2.1b3] - Unreleased
 
+### Fixed
+- **Developer Mode Detection Always Reports Null** — The MQTT `fun` field is an integer in the JSON payload, but the parser used `int(value, 16)` which requires a string argument. This raised `TypeError` on every message, silently caught by the exception handler, so `developer_mode` was never set. Now handles both integer and hex string formats.
+
 ## [0.2.1b2] - 2026-02-21
 
 ### Fixed

+ 2 - 1
backend/app/services/bambu_mqtt.py

@@ -2058,7 +2058,8 @@ class BambuMQTTClient:
         # Parse developer LAN mode from "fun" field
         if "fun" in data:
             try:
-                fun_int = int(data["fun"], 16)
+                fun_val = data["fun"]
+                fun_int = fun_val if isinstance(fun_val, int) else int(fun_val, 16)
                 self.state.developer_mode = (fun_int & 0x20000000) == 0
             except (ValueError, TypeError):
                 pass