diff --git a/bambulabs_api/mqtt_client.py b/bambulabs_api/mqtt_client.py index f5c61e8..c428e3b 100644 --- a/bambulabs_api/mqtt_client.py +++ b/bambulabs_api/mqtt_client.py @@ -457,7 +457,8 @@ def __send_gcode_line(self, gcode_command: str) -> bool: Args: gcode_command (str): G-code command to send to the printer """ - return self.__publish_command({"print": {"command": "gcode_line", + return self.__publish_command({"print": {"sequence_id": "0", + "command": "gcode_line", "param": f"{gcode_command}"}}) def send_gcode(self, gcode_command: str | list[str]) -> bool: @@ -490,6 +491,42 @@ def set_bed_temperature(self, temperature: int) -> bool: """ return self.__send_gcode_line(f"M140 S{temperature}\n") + def get_fan_gear(self): + """ + Get fan_gear + + Returns: + int: consolidated fan value for part, aux and chamber fan speeds + """ + return self.__get("fan_gear", 0) + + def get_part_fan_speed(self): + """ + Get part fan speed + + Returns: + int: 0-255 value representing part fan speed + """ + return self.get_fan_gear() % 256 + + def get_aux_fan_speed(self): + """ + Get auxiliary fan speed + + Returns: + int: 0-255 value representing auxiliary fan speed + """ + return ((self.get_fan_gear() >> 8)) % 256 + + def get_chamber_fan_speed(self): + """ + Get chamber fan speed + + Returns: + int: 0-255 value representing chamber fan speed + """ + return self.get_fan_gear() >> 16 + def set_part_fan_speed(self, speed: int | float) -> bool: """ Set the fan speed of the part fan