From bf33dccfb4b8cc9144bb09bfc8a6ac3610eb348a Mon Sep 17 00:00:00 2001 From: maziggy Date: Sat, 28 Feb 2026 09:35:16 +0100 Subject: [PATCH] Fix SpoolBuddy scale tare & calibration not being applied MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- spoolbuddy/daemon/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spoolbuddy/daemon/main.py b/spoolbuddy/daemon/main.py index 6175df85c..d3b9d886f 100644 --- a/spoolbuddy/daemon/main.py +++ b/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 else: 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) cal = result.get("calibration_factor", config.calibration_factor)