From b54e3723429ff5cf885d00c820bae038bb26c385 Mon Sep 17 00:00:00 2001 From: jneilliii Date: Thu, 14 Nov 2024 21:26:41 -0500 Subject: [PATCH] 0.1.8rc10 reduce settings save by refactoring ams data updates --- .../printer/bambu_virtual_printer.py | 19 ++----------------- .../printer/states/printing_state.py | 2 +- setup.py | 2 +- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/octoprint_bambu_printer/printer/bambu_virtual_printer.py b/octoprint_bambu_printer/printer/bambu_virtual_printer.py index 608656b..88da375 100644 --- a/octoprint_bambu_printer/printer/bambu_virtual_printer.py +++ b/octoprint_bambu_printer/printer/bambu_virtual_printer.py @@ -170,22 +170,6 @@ class BambuVirtualPrinter: def change_state(self, new_state: APrinterState): self._state_change_queue.put(new_state) - def _convert2serialize(self, obj): - if isinstance(obj, dict): - return {k: self._convert2serialize(v) for k, v in obj.items()} - elif hasattr(obj, "_ast"): - return self._convert2serialize(obj._ast()) - elif not isinstance(obj, str) and hasattr(obj, "__iter__"): - return [self._convert2serialize(v) for v in obj] - elif hasattr(obj, "__dict__"): - return { - k: self._convert2serialize(v) - for k, v in obj.__dict__.items() - if not callable(v) and not k.startswith('_') - } - else: - return obj - def new_update(self, event_type): if event_type == "event_hms_errors": self._update_hms_errors() @@ -196,7 +180,8 @@ class BambuVirtualPrinter: device_data = self.bambu_client.get_device() print_job_state = device_data.print_job.gcode_state temperatures = device_data.temperature - ams_data = self._convert2serialize(device_data.ams.data) + # strip out extra data to avoid unneeded settings updates + ams_data = [{"tray": asdict(x).pop("tray", None)} for x in device_data.ams.data if x is not None] if self.ams_data != ams_data: self._log.debug(f"Recieveid AMS Update: {ams_data}") diff --git a/octoprint_bambu_printer/printer/states/printing_state.py b/octoprint_bambu_printer/printer/states/printing_state.py index 2784b24..9ed3a9f 100644 --- a/octoprint_bambu_printer/printer/states/printing_state.py +++ b/octoprint_bambu_printer/printer/states/printing_state.py @@ -71,7 +71,7 @@ class PrintingState(APrinterState): subtask_name: str = print_job_info.subtask_name gcode_file: str = print_job_info.gcode_file - self._log.info(f"update_print_job_info: {print_job_info}") + self._log.debug(f"update_print_job_info: {print_job_info}") project_file_info = self._printer.project_files.get_file_by_name(subtask_name) or self._printer.project_files.get_file_by_name(gcode_file) if project_file_info is None: diff --git a/setup.py b/setup.py index 3ee85ed..114492c 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_package = "octoprint_bambu_printer" plugin_name = "OctoPrint-BambuPrinter" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "0.1.8rc9" +plugin_version = "0.1.8rc10" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module