Skip to content

Commit

Permalink
0.1.8rc10
Browse files Browse the repository at this point in the history
reduce settings save by refactoring ams data updates
jneilliii committed Nov 15, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 76f706d commit b54e372
Showing 3 changed files with 4 additions and 19 deletions.
19 changes: 2 additions & 17 deletions octoprint_bambu_printer/printer/bambu_virtual_printer.py
Original file line number Diff line number Diff line change
@@ -170,22 +170,6 @@ def project_files(self):
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 @@ def _update_printer_info(self):
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}")
2 changes: 1 addition & 1 deletion octoprint_bambu_printer/printer/states/printing_state.py
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ def update_print_job_info(self):
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:
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
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

0 comments on commit b54e372

Please sign in to comment.