Skip to content

Commit

Permalink
Fix system print_type (#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianGarside authored Apr 20, 2024
1 parent b2cbee5 commit 1278752
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions custom_components/bambu_lab/pybambu/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ class FansEnum(Enum):
}

PRINT_TYPE_OPTIONS = {
"local",
"cloud",
"idle"
"local",
"idle",
"system",
"unknown"
}

FILAMENT_NAMES = {
Expand Down
7 changes: 7 additions & 0 deletions custom_components/bambu_lab/pybambu/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
SdcardState,
SPEED_PROFILE,
GCODE_STATE_OPTIONS,
PRINT_TYPE_OPTIONS,
)
from .commands import (
CHAMBER_LIGHT_ON,
Expand Down Expand Up @@ -439,11 +440,15 @@ def print_update(self, data) -> bool:
if previous_gcode_state != self.gcode_state:
LOGGER.debug(f"GCODE_STATE: {previous_gcode_state} -> {self.gcode_state}")
if self.gcode_state.lower() not in GCODE_STATE_OPTIONS:
LOGGER.debug(f"Unknown gcode_state. Please log an issue : '{self.gcode_state}'")
self.gcode_state = "unknown"
if previous_gcode_state != self.gcode_state:
LOGGER.debug(f"GCODE_STATE: {previous_gcode_state} -> {self.gcode_state}")
self.gcode_file = data.get("gcode_file", self.gcode_file)
self.print_type = data.get("print_type", self.print_type)
if self.print_type.lower() not in PRINT_TYPE_OPTIONS:
LOGGER.debug(f"Unknown print_type. Please log an issue : '{self.print_type}'")
self.print_type = "unknown"
self.subtask_name = data.get("subtask_name", self.subtask_name)
self.file_type_icon = "mdi:file" if self.print_type != "cloud" else "mdi:cloud-outline"
self.current_layer = data.get("layer_num", self.current_layer)
Expand Down Expand Up @@ -1101,6 +1106,8 @@ def print_update(self, data) -> bool:
old_data = f"{self.__dict__}"

self._print_type = data.get("print_type", self._print_type)
if self._print_type.lower() not in PRINT_TYPE_OPTIONS:
self._print_type = "unknown"
self._id = int(data.get("stg_cur", self._id))
if (self._print_type == "idle") and (self._id == 0):
# On boot the printer reports stg_cur == 0 incorrectly instead of 255. Attempt to correct for this.
Expand Down

0 comments on commit 1278752

Please sign in to comment.