Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
884101c0ba | |||
7c87ba9482 | |||
1d9f874560 | |||
21e30034d0 | |||
3c8b904a26 | |||
55ad4c1718 | |||
4ef8e40702 | |||
2537bc8f57 | |||
28be048300 | |||
eaa0ed94c0 | |||
14af93b1d0 |
@ -2,3 +2,4 @@ include README.md
|
|||||||
recursive-include octoprint_bambu_printer/templates *
|
recursive-include octoprint_bambu_printer/templates *
|
||||||
recursive-include octoprint_bambu_printer/translations *
|
recursive-include octoprint_bambu_printer/translations *
|
||||||
recursive-include octoprint_bambu_printer/static *
|
recursive-include octoprint_bambu_printer/static *
|
||||||
|
include octoprint_bambu_printer/printer/pybambu/filaments.json
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
from __future__ import absolute_import, annotations
|
from __future__ import absolute_import, annotations
|
||||||
|
|
||||||
|
import json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import threading
|
import threading
|
||||||
from time import perf_counter
|
from time import perf_counter
|
||||||
@ -101,7 +103,7 @@ class BambuPrintPlugin(
|
|||||||
"always_use_default_options": False,
|
"always_use_default_options": False,
|
||||||
"ams_data": [],
|
"ams_data": [],
|
||||||
"ams_mapping": [],
|
"ams_mapping": [],
|
||||||
"ams_current_tray": None,
|
"ams_current_tray": 255,
|
||||||
}
|
}
|
||||||
|
|
||||||
def is_api_adminonly(self):
|
def is_api_adminonly(self):
|
||||||
|
@ -43,7 +43,7 @@ class BambuPrinterTelemetry:
|
|||||||
lastTempAt: float = time.monotonic()
|
lastTempAt: float = time.monotonic()
|
||||||
firmwareName: str = "Bambu"
|
firmwareName: str = "Bambu"
|
||||||
extruderCount: int = 1
|
extruderCount: int = 1
|
||||||
ams_current_tray: int = -1
|
ams_current_tray: int = 255
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
@ -210,7 +210,8 @@ class BambuVirtualPrinter:
|
|||||||
self._telemetry.bedTemp = temperatures.bed_temp
|
self._telemetry.bedTemp = temperatures.bed_temp
|
||||||
self._telemetry.bedTargetTemp = temperatures.target_bed_temp
|
self._telemetry.bedTargetTemp = temperatures.target_bed_temp
|
||||||
self._telemetry.chamberTemp = temperatures.chamber_temp
|
self._telemetry.chamberTemp = temperatures.chamber_temp
|
||||||
self._telemetry.ams_current_tray = device_data.push_all_data["ams"]["tray_now"] or -1
|
if device_data.push_all_data and "ams" in device_data.push_all_data:
|
||||||
|
self._telemetry.ams_current_tray = device_data.push_all_data["ams"]["tray_now"] or 255
|
||||||
|
|
||||||
if self._telemetry.ams_current_tray != self._settings.get_int(["ams_current_tray"]):
|
if self._telemetry.ams_current_tray != self._settings.get_int(["ams_current_tray"]):
|
||||||
self._settings.set_int(["ams_current_tray"], self._telemetry.ams_current_tray)
|
self._settings.set_int(["ams_current_tray"], self._telemetry.ams_current_tray)
|
||||||
@ -356,7 +357,7 @@ class BambuVirtualPrinter:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
if file_info is None:
|
if file_info is None:
|
||||||
self._log.error(f"Cannot select not existing file: {file_path}")
|
self._log.error(f"Cannot select non-existent file: {file_path}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self._selected_project_file = file_info
|
self._selected_project_file = file_info
|
||||||
@ -366,8 +367,9 @@ class BambuVirtualPrinter:
|
|||||||
##~~ command implementations
|
##~~ command implementations
|
||||||
|
|
||||||
@gcode_executor.register_no_data("M21")
|
@gcode_executor.register_no_data("M21")
|
||||||
def _sd_status(self) -> None:
|
def _sd_status(self) -> bool:
|
||||||
self.sendIO("SD card ok")
|
self.sendIO("SD card ok")
|
||||||
|
return True
|
||||||
|
|
||||||
@gcode_executor.register("M23")
|
@gcode_executor.register("M23")
|
||||||
def _select_sd_file(self, data: str) -> bool:
|
def _select_sd_file(self, data: str) -> bool:
|
||||||
@ -468,6 +470,9 @@ class BambuVirtualPrinter:
|
|||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
@gcode_executor.register_no_data("M115")
|
@gcode_executor.register_no_data("M115")
|
||||||
def _report_firmware_info(self) -> bool:
|
def _report_firmware_info(self) -> bool:
|
||||||
|
# wait for connection to be established before sending back firmware info
|
||||||
|
while self.bambu_client.connected is False:
|
||||||
|
time.sleep(1)
|
||||||
self.sendIO("Bambu Printer Integration")
|
self.sendIO("Bambu Printer Integration")
|
||||||
self.sendIO("Cap:AUTOREPORT_SD_STATUS:1")
|
self.sendIO("Cap:AUTOREPORT_SD_STATUS:1")
|
||||||
self.sendIO("Cap:AUTOREPORT_TEMP:1")
|
self.sendIO("Cap:AUTOREPORT_TEMP:1")
|
||||||
@ -680,7 +685,7 @@ class BambuVirtualPrinter:
|
|||||||
self._state_change_queue.join()
|
self._state_change_queue.join()
|
||||||
|
|
||||||
def _printer_worker(self):
|
def _printer_worker(self):
|
||||||
self._create_client_connection_async()
|
# self._create_client_connection_async()
|
||||||
self.sendIO("Printer connection complete")
|
self.sendIO("Printer connection complete")
|
||||||
while self._running:
|
while self._running:
|
||||||
try:
|
try:
|
||||||
|
@ -87,7 +87,7 @@ class CachedFileView:
|
|||||||
def _get_file_by_stem_cached(self, file_stem: str, allowed_suffixes: list[str]):
|
def _get_file_by_stem_cached(self, file_stem: str, allowed_suffixes: list[str]):
|
||||||
for file_path_str in list(self._file_data_cache.keys()) + list(self._file_alias_cache.keys()):
|
for file_path_str in list(self._file_data_cache.keys()) + list(self._file_alias_cache.keys()):
|
||||||
file_path = Path(file_path_str)
|
file_path = Path(file_path_str)
|
||||||
if file_stem == file_path.with_suffix("").stem and all(
|
if file_stem == file_path.with_suffix("").stem and any(
|
||||||
suffix in allowed_suffixes for suffix in file_path.suffixes
|
suffix in allowed_suffixes for suffix in file_path.suffixes
|
||||||
):
|
):
|
||||||
return self.get_file_data_cached(file_path)
|
return self.get_file_data_cached(file_path)
|
||||||
|
@ -10,6 +10,9 @@ from octoprint_bambu_printer.printer.file_system.remote_sd_card_file_list import
|
|||||||
class PrintJob:
|
class PrintJob:
|
||||||
file_info: FileInfo
|
file_info: FileInfo
|
||||||
progress: int
|
progress: int
|
||||||
|
remaining_time: int
|
||||||
|
current_layer: int
|
||||||
|
total_layers: int
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def file_position(self):
|
def file_position(self):
|
||||||
|
@ -23,7 +23,7 @@ class BambuCloud:
|
|||||||
url = 'https://api.bambulab.cn/v1/user-service/user/login'
|
url = 'https://api.bambulab.cn/v1/user-service/user/login'
|
||||||
else:
|
else:
|
||||||
url = 'https://api.bambulab.com/v1/user-service/user/login'
|
url = 'https://api.bambulab.com/v1/user-service/user/login'
|
||||||
headers = {'User-Agent' : "HA Bambulab"}
|
headers = {'User-Agent' : "OctoPrint Plugin"}
|
||||||
data = {'account': self._email, 'password': self._password}
|
data = {'account': self._email, 'password': self._password}
|
||||||
with httpx.Client(http2=True) as client:
|
with httpx.Client(http2=True) as client:
|
||||||
response = client.post(url, headers=headers, json=data, timeout=10)
|
response = client.post(url, headers=headers, json=data, timeout=10)
|
||||||
@ -105,7 +105,7 @@ class BambuCloud:
|
|||||||
url = 'https://api.bambulab.cn/v1/iot-service/api/user/bind'
|
url = 'https://api.bambulab.cn/v1/iot-service/api/user/bind'
|
||||||
else:
|
else:
|
||||||
url = 'https://api.bambulab.com/v1/iot-service/api/user/bind'
|
url = 'https://api.bambulab.com/v1/iot-service/api/user/bind'
|
||||||
headers = {'Authorization': 'Bearer ' + self._auth_token, 'User-Agent' : "HA Bambulab"}
|
headers = {'Authorization': 'Bearer ' + self._auth_token, 'User-Agent' : "OctoPrint Plugin"}
|
||||||
with httpx.Client(http2=True) as client:
|
with httpx.Client(http2=True) as client:
|
||||||
response = client.get(url, headers=headers, timeout=10)
|
response = client.get(url, headers=headers, timeout=10)
|
||||||
if response.status_code >= 400:
|
if response.status_code >= 400:
|
||||||
@ -186,7 +186,7 @@ class BambuCloud:
|
|||||||
url = 'https://api.bambulab.cn/v1/iot-service/api/slicer/setting?version=undefined'
|
url = 'https://api.bambulab.cn/v1/iot-service/api/slicer/setting?version=undefined'
|
||||||
else:
|
else:
|
||||||
url = 'https://api.bambulab.com/v1/iot-service/api/slicer/setting?version=undefined'
|
url = 'https://api.bambulab.com/v1/iot-service/api/slicer/setting?version=undefined'
|
||||||
headers = {'Authorization': 'Bearer ' + self._auth_token, 'User-Agent' : "HA Bambulab"}
|
headers = {'Authorization': 'Bearer ' + self._auth_token, 'User-Agent' : "OctoPrint Plugin"}
|
||||||
with httpx.Client(http2=True) as client:
|
with httpx.Client(http2=True) as client:
|
||||||
response = client.get(url, headers=headers, timeout=10)
|
response = client.get(url, headers=headers, timeout=10)
|
||||||
if response.status_code >= 400:
|
if response.status_code >= 400:
|
||||||
@ -241,7 +241,7 @@ class BambuCloud:
|
|||||||
url = 'https://api.bambulab.cn/v1/user-service/my/tasks'
|
url = 'https://api.bambulab.cn/v1/user-service/my/tasks'
|
||||||
else:
|
else:
|
||||||
url = 'https://api.bambulab.com/v1/user-service/my/tasks'
|
url = 'https://api.bambulab.com/v1/user-service/my/tasks'
|
||||||
headers = {'Authorization': 'Bearer ' + self._auth_token, 'User-Agent' : "HA Bambulab"}
|
headers = {'Authorization': 'Bearer ' + self._auth_token, 'User-Agent' : "OctoPrint Plugin"}
|
||||||
with httpx.Client(http2=True) as client:
|
with httpx.Client(http2=True) as client:
|
||||||
response = client.get(url, headers=headers, timeout=10)
|
response = client.get(url, headers=headers, timeout=10)
|
||||||
if response.status_code >= 400:
|
if response.status_code >= 400:
|
||||||
|
@ -25,7 +25,7 @@ class IdleState(APrinterState):
|
|||||||
filesystem_root = (
|
filesystem_root = (
|
||||||
"file:///mnt/sdcard/"
|
"file:///mnt/sdcard/"
|
||||||
if self._printer._settings.get(["device_type"]) in ["X1", "X1C"]
|
if self._printer._settings.get(["device_type"]) in ["X1", "X1C"]
|
||||||
else "file:///"
|
else "file:///sdcard/"
|
||||||
)
|
)
|
||||||
|
|
||||||
print_command = {
|
print_command = {
|
||||||
|
@ -37,14 +37,14 @@ class PausedState(APrinterState):
|
|||||||
|
|
||||||
def start_new_print(self):
|
def start_new_print(self):
|
||||||
if self._printer.bambu_client.connected:
|
if self._printer.bambu_client.connected:
|
||||||
if self._printer.bambu_client.publish(pybambu.commands.RESUME):
|
if self._printer.bambu_client.publish(octoprint_bambu_printer.printer.pybambu.commands.RESUME):
|
||||||
self._log.info("print resumed")
|
self._log.info("print resumed")
|
||||||
else:
|
else:
|
||||||
self._log.info("print resume failed")
|
self._log.info("print resume failed")
|
||||||
|
|
||||||
def cancel_print(self):
|
def cancel_print(self):
|
||||||
if self._printer.bambu_client.connected:
|
if self._printer.bambu_client.connected:
|
||||||
if self._printer.bambu_client.publish(pybambu.commands.STOP):
|
if self._printer.bambu_client.publish(octoprint_bambu_printer.printer.pybambu.commands.STOP):
|
||||||
self._log.info("print cancelled")
|
self._log.info("print cancelled")
|
||||||
self._printer.finalize_print_job()
|
self._printer.finalize_print_job()
|
||||||
else:
|
else:
|
||||||
|
@ -75,19 +75,19 @@ class PrintingState(APrinterState):
|
|||||||
return
|
return
|
||||||
|
|
||||||
progress = print_job_info.print_percentage
|
progress = print_job_info.print_percentage
|
||||||
self._printer.current_print_job = PrintJob(project_file_info, progress)
|
self._printer.current_print_job = PrintJob(project_file_info, progress, print_job_info.remaining_time, print_job_info.current_layer, print_job_info.total_layers)
|
||||||
self._printer.select_project_file(project_file_info.path.as_posix())
|
self._printer.select_project_file(project_file_info.path.as_posix())
|
||||||
|
|
||||||
def pause_print(self):
|
def pause_print(self):
|
||||||
if self._printer.bambu_client.connected:
|
if self._printer.bambu_client.connected:
|
||||||
if self._printer.bambu_client.publish(pybambu.commands.PAUSE):
|
if self._printer.bambu_client.publish(octoprint_bambu_printer.printer.pybambu.commands.PAUSE):
|
||||||
self._log.info("print paused")
|
self._log.info("print paused")
|
||||||
else:
|
else:
|
||||||
self._log.info("print pause failed")
|
self._log.info("print pause failed")
|
||||||
|
|
||||||
def cancel_print(self):
|
def cancel_print(self):
|
||||||
if self._printer.bambu_client.connected:
|
if self._printer.bambu_client.connected:
|
||||||
if self._printer.bambu_client.publish(pybambu.commands.STOP):
|
if self._printer.bambu_client.publish(octoprint_bambu_printer.printer.pybambu.commands.STOP):
|
||||||
self._log.info("print cancelled")
|
self._log.info("print cancelled")
|
||||||
self._printer.finalize_print_job()
|
self._printer.finalize_print_job()
|
||||||
else:
|
else:
|
||||||
|
@ -18,6 +18,8 @@ $(function () {
|
|||||||
self.use_ams = true;
|
self.use_ams = true;
|
||||||
self.ams_mapping = ko.observableArray([]);
|
self.ams_mapping = ko.observableArray([]);
|
||||||
|
|
||||||
|
self.job_info = ko.observable();
|
||||||
|
|
||||||
self.ams_mapping_computed = function(){
|
self.ams_mapping_computed = function(){
|
||||||
var output_list = [];
|
var output_list = [];
|
||||||
var index = 0;
|
var index = 0;
|
||||||
@ -92,6 +94,10 @@ $(function () {
|
|||||||
self.listHelper.updateItems(data.files);
|
self.listHelper.updateItems(data.files);
|
||||||
self.listHelper.resetPage();
|
self.listHelper.resetPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.job_info !== undefined) {
|
||||||
|
self.job_info(data.job_info);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.onBeforeBinding = function () {
|
self.onBeforeBinding = function () {
|
||||||
|
@ -10,3 +10,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row-fluid" data-bind="visible: job_info">
|
||||||
|
<div class="span6">{{ _('Layer') }}:</div><div class="span6" data-bind="text: function(){return (job_info.current_layer() + ' of ' + job_info.total_layers);}"></div>
|
||||||
|
</div>
|
||||||
|
4
setup.py
4
setup.py
@ -14,7 +14,7 @@ plugin_package = "octoprint_bambu_printer"
|
|||||||
plugin_name = "OctoPrint-BambuPrinter"
|
plugin_name = "OctoPrint-BambuPrinter"
|
||||||
|
|
||||||
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
|
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
|
||||||
plugin_version = "0.1.8rc1"
|
plugin_version = "0.1.8rc6"
|
||||||
|
|
||||||
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
|
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
|
||||||
# module
|
# module
|
||||||
@ -43,7 +43,7 @@ plugin_requires = ["paho-mqtt<2", "python-dateutil", "httpx[http2]>=0.27.0"]
|
|||||||
# already be installed automatically if they exist. Note that if you add something here you'll also need to update
|
# already be installed automatically if they exist. Note that if you add something here you'll also need to update
|
||||||
# MANIFEST.in to match to ensure that python setup.py sdist produces a source distribution that contains all your
|
# MANIFEST.in to match to ensure that python setup.py sdist produces a source distribution that contains all your
|
||||||
# files. This is sadly due to how python's setup.py works, see also http://stackoverflow.com/a/14159430/2028598
|
# files. This is sadly due to how python's setup.py works, see also http://stackoverflow.com/a/14159430/2028598
|
||||||
plugin_additional_data = []
|
plugin_additional_data = ["octoprint_bambu_printer/printer/pybambu/filaments.json"]
|
||||||
|
|
||||||
# Any additional python packages you need to install with your plugin that are not contained in <plugin_package>.*
|
# Any additional python packages you need to install with your plugin that are not contained in <plugin_package>.*
|
||||||
plugin_additional_packages = []
|
plugin_additional_packages = []
|
||||||
|
Reference in New Issue
Block a user