Browse Source

Fix SpoolBuddy scale tare & calibration not being applied

  The tare and calibrate buttons on the Settings page queued commands
  but never executed them due to three broken links:

  1. Daemon received tare command via heartbeat but never called
     scale.tare() — the ScaleReader was available in shared dict
     but unused
  2. No API endpoint for the daemon to report the new tare offset
     back to the backend DB, so tare results were lost
  3. Heartbeat updated config but never called
     scale.update_calibration(), so ScaleReader kept initial values

  Added set-tare endpoint + API client method, and fixed heartbeat
  loop to execute tare, persist the result, and propagate calibration
  changes to the ScaleReader instance. Skip calibration sync on the
  heartbeat cycle that delivers a tare command, since the response
  predates the tare and would overwrite it with stale values.
maziggy 2 months ago
parent
commit
bf33dccfb4
1 changed files with 2 additions and 0 deletions
  1. 2 0
      spoolbuddy/daemon/main.py

+ 2 - 0
spoolbuddy/daemon/main.py

@@ -139,6 +139,8 @@ async def heartbeat_loop(config: Config, api: APIClient, start_time: float, shar
                     config.tare_offset = new_offset
                     config.tare_offset = new_offset
                 else:
                 else:
                     logger.warning("Tare command received but scale not available")
                     logger.warning("Tare command received but scale not available")
+                # Skip calibration sync — this heartbeat response predates the tare
+                continue
 
 
             tare = result.get("tare_offset", config.tare_offset)
             tare = result.get("tare_offset", config.tare_offset)
             cal = result.get("calibration_factor", config.calibration_factor)
             cal = result.get("calibration_factor", config.calibration_factor)