From 7e94c689930a8a3539ff3947c9f32159863137c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E7=8E=AE=20=28Jade=20Lin=29?= Date: Sun, 5 May 2024 02:11:59 +0800 Subject: [PATCH] printer: tempstore fixup (#1353) temp from get_stat could be {} if the device is not available --- ks_includes/printer.py | 3 ++- panels/base_panel.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ks_includes/printer.py b/ks_includes/printer.py index 2b01f5ef..35dc6587 100644 --- a/ks_includes/printer.py +++ b/ks_includes/printer.py @@ -396,7 +396,8 @@ class Printer: for x in self.tempstore[device]: self.tempstore[device][x].pop(0) temp = self.get_stat(device, x[:-1]) - if temp is None: + if not temp: + # If the temperature is not available, set it to 0. temp = 0 self.tempstore[device][x].append(temp) return True diff --git a/panels/base_panel.py b/panels/base_panel.py index 134e6a5f..393b887d 100644 --- a/panels/base_panel.py +++ b/panels/base_panel.py @@ -256,7 +256,7 @@ class BasePanel(ScreenPanel): return for device in self._printer.get_temp_devices(): temp = self._printer.get_stat(device, "temperature") - if temp is not None and device in self.labels: + if temp and device in self.labels: name = "" if not (device.startswith("extruder") or device.startswith("heater_bed")): if self.titlebar_name_type == "full":