Compare commits

...

4 Commits

Author SHA1 Message Date
98ab94b371 0.1.8rc11
update pybambu/bambu_cloud.py from upstream HA project
2024-11-14 23:35:03 -05:00
b54e372342 0.1.8rc10
reduce settings save by refactoring ams data updates
2024-11-14 21:26:41 -05:00
76f706df19 0.1.8rc9
* check for filename in cache subfolder for files started through cloud connected printers
* send 0% progress when in prepare state and progress is 100
* minor UI tweaks
2024-11-09 21:57:17 -05:00
5c8a9787d4 0.1.8rc8
* updates to pybambu module
* update cloud login workflow, #59
2024-11-09 20:01:41 -05:00
10 changed files with 221 additions and 91 deletions

View File

@ -61,6 +61,7 @@ class BambuPrintPlugin(
_plugin_manager: octoprint.plugin.PluginManager
_bambu_file_system: RemoteSDCardFileList
_timelapse_files_view: CachedFileView
_bambu_cloud: None
def on_settings_initialized(self):
self._bambu_file_system = RemoteSDCardFileList(self._settings)
@ -117,7 +118,8 @@ class BambuPrintPlugin(
return True
def get_api_commands(self):
return {"register": ["email", "password", "region", "auth_token"]}
return {"register": ["email", "password", "region", "auth_token"],
"verify": ["auth_type", "password"]}
def on_api_command(self, command, data):
if command == "register":
@ -128,16 +130,44 @@ class BambuPrintPlugin(
and "auth_token" in data
):
self._logger.info(f"Registering user {data['email']}")
bambu_cloud = BambuCloud(
self._bambu_cloud = BambuCloud(
data["region"], data["email"], data["password"], data["auth_token"]
)
bambu_cloud.login(data["region"], data["email"], data["password"])
auth_response = self._bambu_cloud.login(data["region"], data["email"], data["password"])
return flask.jsonify(
{
"auth_token": bambu_cloud.auth_token,
"username": bambu_cloud.username,
"auth_response": auth_response,
}
)
elif command == "verify":
auth_response = None
if (
"auth_type" in data
and "password" in data
and self._bambu_cloud is not None
):
self._logger.info(f"Verifying user {self._bambu_cloud._email}")
if data["auth_type"] == "verifyCode":
auth_response = self._bambu_cloud.login_with_verification_code(data["password"])
elif data["auth_type"] == "tfa":
auth_response = self._bambu_cloud.login_with_2fa_code(data["password"])
else:
self._logger.warning(f"Unknown verification type: {data['auth_type']}")
if auth_response == "success":
return flask.jsonify(
{
"auth_token": self._bambu_cloud.auth_token,
"username": self._bambu_cloud.username
}
)
else:
self._logger.info(f"Error verifying: {auth_response}")
return flask.jsonify(
{
"error": "Unable to verify"
}
)
def on_event(self, event, payload):
if event == Events.TRANSFER_DONE:

View File

@ -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}")
@ -286,7 +271,7 @@ class BambuVirtualPrinter:
local_mqtt=self._settings.get_boolean(["local_mqtt"]),
region=self._settings.get(["region"]),
email=self._settings.get(["email"]),
auth_token=self._settings.get(["auth_token"]),
auth_token=self._settings.get(["auth_token"]) if self._settings.get_boolean(["local_mqtt"]) is False else "",
)
bambu_client.on_disconnect = self.on_disconnect(bambu_client.on_disconnect)
bambu_client.on_connect = self.on_connect(bambu_client.on_connect)

View File

@ -86,6 +86,10 @@ class CachedFileView:
file_name = f"{file_name}.3mf"
elif f"{file_name}.gcode.3mf" in file_list:
file_name = f"{file_name}.gcode.3mf"
elif f"cache/{file_name}.3mf" in file_list:
file_name = f"cache/{file_name}.3mf"
elif f"cache/{file_name}.gcode.3mf" in file_list:
file_name = f"cache/{file_name}.gcode.3mf"
file_data = self.get_file_data_cached(file_name)
if file_data is None:

View File

@ -237,7 +237,7 @@ class MqttThread(threading.Thread):
exceptionSeen = ""
while True:
try:
host = self._client.host if self._client._local_mqtt else self._client.bambu_cloud.cloud_mqtt_host
host = self._client.host if self._client.local_mqtt else self._client.bambu_cloud.cloud_mqtt_host
LOGGER.debug(f"Connect: Attempting Connection to {host}")
self._client.client.connect(host, self._client._port, keepalive=5)
@ -289,7 +289,7 @@ class BambuClient:
username: str, auth_token: str, access_code: str, usage_hours: float = 0, manual_refresh_mode: bool = False, chamber_image: bool = True):
self.callback = None
self.host = host
self._local_mqtt = local_mqtt
self.local_mqtt = local_mqtt
self._serial = serial
self._auth_token = auth_token
self._access_code = access_code
@ -342,7 +342,7 @@ class BambuClient:
self.setup_tls()
self._port = 8883
if self._local_mqtt:
if self.local_mqtt:
self.client.username_pw_set("bblp", password=self._access_code)
else:
self.client.username_pw_set(self._username, password=self._auth_token)
@ -532,7 +532,7 @@ class BambuClient:
loop = asyncio.get_event_loop()
await loop.run_in_executor(None, self.setup_tls)
if self._local_mqtt:
if self.local_mqtt:
self.client.username_pw_set("bblp", password=self._access_code)
else:
self.client.username_pw_set(self._username, password=self._auth_token)

View File

@ -3,7 +3,11 @@ from __future__ import annotations
import base64
import json
from curl_cffi import requests
curl_available = True
try:
from curl_cffi import requests as curl_requests
except ImportError:
curl_available = False
from dataclasses import dataclass
@ -33,6 +37,9 @@ class BambuCloud:
def _get_authentication_token(self) -> dict:
LOGGER.debug("Getting accessToken from Bambu Cloud")
if not curl_available:
LOGGER.debug(f"Curl library is unavailable.")
return 'curlUnavailable'
# First we need to find out how Bambu wants us to login.
data = {
@ -41,7 +48,14 @@ class BambuCloud:
"apiError": ""
}
response = requests.post(get_Url(BambuUrl.LOGIN, self._region), json=data, impersonate=IMPERSONATE_BROWSER)
response = curl_requests.post(get_Url(BambuUrl.LOGIN, self._region), json=data, impersonate=IMPERSONATE_BROWSER)
# Check specifically for cloudflare block
if response.status_code == 403:
if 'cloudflare' in response.text:
LOGGER.error('CloudFlare blocked connection attempt')
return 'cloudFlare'
if response.status_code >= 400:
LOGGER.error(f"Login attempt failed with error code: {response.status_code}")
LOGGER.debug(f"Response: '{response.text}'")
@ -80,7 +94,7 @@ class BambuCloud:
}
LOGGER.debug("Requesting verification code")
response = requests.post(get_Url(BambuUrl.EMAIL_CODE, self._region), json=data, impersonate=IMPERSONATE_BROWSER)
response = curl_requests.post(get_Url(BambuUrl.EMAIL_CODE, self._region), json=data, impersonate=IMPERSONATE_BROWSER)
if response.status_code == 200:
LOGGER.debug("Verification code requested successfully.")
@ -96,7 +110,7 @@ class BambuCloud:
"code": code
}
response = requests.post(get_Url(BambuUrl.LOGIN, self._region), json=data, impersonate=IMPERSONATE_BROWSER)
response = curl_requests.post(get_Url(BambuUrl.LOGIN, self._region), json=data, impersonate=IMPERSONATE_BROWSER)
LOGGER.debug(f"Response: {response.status_code}")
if response.status_code == 200:
@ -128,7 +142,7 @@ class BambuCloud:
"tfaCode": code
}
response = requests.post(get_Url(BambuUrl.TFA_LOGIN, self._region), json=data, impersonate=IMPERSONATE_BROWSER)
response = curl_requests.post(get_Url(BambuUrl.TFA_LOGIN, self._region), json=data, impersonate=IMPERSONATE_BROWSER)
LOGGER.debug(f"Response: {response.status_code}")
if response.status_code == 200:
@ -209,13 +223,11 @@ class BambuCloud:
self._password = password
result = self._get_authentication_token()
if result == 'verifyCode':
return result
elif result == 'tfa':
return result
elif result is None:
if result is None:
LOGGER.error("Unable to authenticate.")
return None
elif len(result) < 20:
return result
else:
self._auth_token = result
self._username = self._get_username_from_authentication_token()
@ -223,7 +235,7 @@ class BambuCloud:
def login_with_verification_code(self, code: str):
result = self._get_authentication_token_with_verification_code(code)
if result == 'codeExpired' or result == 'codeIncorrect':
if len(result) < 20:
return result
self._auth_token = result
self._username = self._get_username_from_authentication_token()
@ -231,16 +243,29 @@ class BambuCloud:
def login_with_2fa_code(self, code: str):
result = self._get_authentication_token_with_2fa_code(code)
if len(result) < 20:
return result
self._auth_token = result
self._username = self._get_username_from_authentication_token()
return 'success'
def get_device_list(self) -> dict:
LOGGER.debug("Getting device list from Bambu Cloud")
response = requests.get(get_Url(BambuUrl.BIND, self._region), headers=self._get_headers_with_auth_token(), timeout=10, impersonate=IMPERSONATE_BROWSER)
if not curl_available:
LOGGER.debug(f"Curl library is unavailable.")
raise None
response = curl_requests.get(get_Url(BambuUrl.BIND, self._region), headers=self._get_headers_with_auth_token(), timeout=10, impersonate=IMPERSONATE_BROWSER)
if response.status_code == 403:
if 'cloudflare' in response.text:
LOGGER.error('CloudFlare blocked connection attempt')
raise ValueError(response.status_code)
if response.status_code >= 400:
LOGGER.debug(f"Received error: {response.status_code}")
LOGGER.error(f"Received error: '{response.text}'")
raise ValueError(response.status_code)
return response.json()['devices']
# The slicer settings are of the following form:
@ -311,13 +336,23 @@ class BambuCloud:
# }
def get_slicer_settings(self) -> dict:
LOGGER.debug("Getting slicer settings from Bambu Cloud")
response = requests.get(get_Url(BambuUrl.SLICER_SETTINGS, self._region), headers=self._get_headers_with_auth_token(), timeout=10, impersonate=IMPERSONATE_BROWSER)
if response.status_code >= 400:
LOGGER.error(f"Slicer settings load failed: {response.status_code}")
LOGGER.error(f"Slicer settings load failed: '{response.text}'")
return None
return response.json()
LOGGER.debug("DISABLED: Getting slicer settings from Bambu Cloud")
# Disabled for now since it may be contributing to cloudflare detection speed.
#
# if curl_available:
# response = curl_requests.get(get_Url(BambuUrl.SLICER_SETTINGS, self._region), headers=self._get_headers_with_auth_token(), timeout=10, impersonate=IMPERSONATE_BROWSER)
# if response.status_code == 403:
# if 'cloudflare' in response.text:
# LOGGER.error(f"Cloudflare blocked slicer settings lookup.")
# return None
# if response.status_code >= 400:
# LOGGER.error(f"Slicer settings load failed: {response.status_code}")
# LOGGER.error(f"Slicer settings load failed: '{response.text}'")
# return None
# return response.json()
return None
# The task list is of the following form with a 'hits' array with typical 20 entries.
#
@ -362,24 +397,46 @@ class BambuCloud:
# },
def get_tasklist(self) -> dict:
LOGGER.debug("Getting full task list from Bambu Cloud")
if not curl_available:
LOGGER.debug(f"Curl library is unavailable.")
raise None
url = get_Url(BambuUrl.TASKS, self._region)
response = requests.get(url, headers=self._get_headers_with_auth_token(), timeout=10, impersonate=IMPERSONATE_BROWSER)
response = curl_requests.get(url, headers=self._get_headers_with_auth_token(), timeout=10, impersonate=IMPERSONATE_BROWSER)
if response.status_code == 403:
if 'cloudflare' in response.text:
LOGGER.error('CloudFlare blocked connection attempt')
return None
# Check specifically for cloudflare block
if response.status_code == 403:
if 'cloudflare' in response.text:
LOGGER.error('CloudFlare blocked connection attempt')
return None
if response.status_code >= 400:
LOGGER.debug(f"Received error: {response.status_code}")
LOGGER.debug(f"Received error: '{response.text}'")
raise ValueError(response.status_code)
raise None
return response.json()
def get_latest_task_for_printer(self, deviceId: str) -> dict:
LOGGER.debug(f"Getting latest task from Bambu Cloud")
data = self.get_tasklist_for_printer(deviceId)
if len(data) != 0:
return data[0]
LOGGER.debug("No tasks found for printer")
LOGGER.debug(f"Getting latest task for printer from Bambu Cloud")
try:
data = self.get_tasklist_for_printer(deviceId)
if len(data) != 0:
return data[0]
LOGGER.debug("No tasks found for printer")
except:
LOGGER.debug("Unable to make call")
return None
return None
def get_tasklist_for_printer(self, deviceId: str) -> dict:
LOGGER.debug(f"Getting task list from Bambu Cloud")
LOGGER.debug(f"Getting full task list for printer from Bambu Cloud")
tasks = []
data = self.get_tasklist()
for task in data['hits']:
@ -394,10 +451,21 @@ class BambuCloud:
def download(self, url: str) -> bytearray:
LOGGER.debug(f"Downloading cover image: {url}")
response = requests.get(url, timeout=10, impersonate=IMPERSONATE_BROWSER)
if not curl_available:
LOGGER.debug(f"Curl library is unavailable.")
return None
response = curl_requests.get(url, timeout=10, impersonate=IMPERSONATE_BROWSER)
if response.status_code == 403:
if 'cloudflare' in response.text:
LOGGER.error('CloudFlare blocked connection attempt')
raise ValueError(response.status_code)
if response.status_code >= 400:
LOGGER.debug(f"Received error: {response.status_code}")
LOGGER.debug(f"Received error: {response.text}")
raise ValueError(response.status_code)
return response.content
@property
@ -408,6 +476,10 @@ class BambuCloud:
def auth_token(self):
return self._auth_token
@property
def bambu_connected(self) -> bool:
return self._auth_token != "" and self._auth_token != None
@property
def cloud_mqtt_host(self):
return "cn.mqtt.bambulab.com" if self._region == "China" else "us.mqtt.bambulab.com"

View File

@ -128,7 +128,7 @@ class Device:
return self.info.device_type != "A1" and self.info.device_type != "A1MINI"
return False
def get_active_tray(self):
if self.supports_feature(Features.AMS):
if self.ams.tray_now == 255:
@ -179,7 +179,7 @@ class Lights:
self.work_light = \
search(data.get("lights_report", []), lambda x: x.get('node', "") == "work_light",
{"mode": self.work_light}).get("mode")
return (old_data != f"{self.__dict__}")
def TurnChamberLightOn(self):
@ -228,7 +228,7 @@ class Camera:
self.recording = data.get("ipcam", {}).get("ipcam_record", self.recording)
self.resolution = data.get("ipcam", {}).get("resolution", self.resolution)
self.rtsp_url = data.get("ipcam", {}).get("rtsp_url", self.rtsp_url)
return (old_data != f"{self.__dict__}")
@dataclass
@ -255,7 +255,7 @@ class Temperature:
self.chamber_temp = round(data.get("chamber_temper", self.chamber_temp))
self.nozzle_temp = round(data.get("nozzle_temper", self.nozzle_temp))
self.target_nozzle_temp = round(data.get("nozzle_target_temper", self.target_nozzle_temp))
return (old_data != f"{self.__dict__}")
@dataclass
@ -316,7 +316,7 @@ class Fans:
self._cooling_fan_speed_override_time = None
self._heatbreak_fan_speed = data.get("heatbreak_fan_speed", self._heatbreak_fan_speed)
self._heatbreak_fan_speed_percentage = fan_percentage(self._heatbreak_fan_speed)
return (old_data != f"{self.__dict__}")
def set_fan_speed(self, fan: FansEnum, percentage: int):
@ -666,7 +666,7 @@ class Info:
self.sw_ver = "unknown"
self.online = False
self.new_version_state = 0
self.mqtt_mode = "local" if self._client._local_mqtt else "bambu_cloud"
self.mqtt_mode = "local" if self._client.local_mqtt else "bambu_cloud"
self.nozzle_diameter = 0
self.nozzle_type = "unknown"
self.usage_hours = client._usage_hours
@ -866,7 +866,7 @@ class AMSList:
index = int(name[4])
elif name.startswith("ams_f1/"):
index = int(name[7])
if index != -1:
# Sometimes we get incomplete version data. We have to skip if that occurs since the serial number is
# required as part of the home assistant device identity.
@ -1041,7 +1041,7 @@ class AMSTray:
self.tag_uid = data.get('tag_uid', self.tag_uid)
self.tray_uuid = data.get('tray_uuid', self.tray_uuid)
self.k = data.get('k', self.k)
return (old_data != f"{self.__dict__}")
@ -1110,7 +1110,7 @@ class Speed:
self._id = int(data.get("spd_lvl", self._id))
self.name = get_speed_name(self._id)
self.modifier = int(data.get("spd_mag", self.modifier))
return (old_data != f"{self.__dict__}")
def SetSpeed(self, option: str):
@ -1162,7 +1162,7 @@ class HMSList:
self._count = 0
self._errors = {}
self._errors["Count"] = 0
def print_update(self, data) -> bool:
# Example payload:
# "hms": [
@ -1201,14 +1201,14 @@ class HMSList:
if self._client.callback is not None:
self._client.callback("event_hms_errors")
return True
return False
@property
def errors(self) -> dict:
#LOGGER.debug(f"PROPERTYCALL: get_hms_errors")
return self._errors
@property
def error_count(self) -> int:
return self._count
@ -1223,10 +1223,10 @@ class PrintErrorList:
self._error = None
self._count = 0
self._client = client
def print_update(self, data) -> bool:
# Example payload:
# "print_error": 117473286
# "print_error": 117473286
# So this is 07008006 which we make more human readable to 0700-8006
# https://e.bambulab.com/query.php?lang=en
# 'Unable to feed filament into the extruder. This could be due to entangled filament or a stuck spool. If not, please check if the AMS PTFE tube is connected.'
@ -1249,11 +1249,11 @@ class PrintErrorList:
# We send the error event directly so always return False for the general data event.
return False
@property
def error(self) -> dict:
return self._error
@property
def on(self) -> int:
return self._error is not None
@ -1299,10 +1299,10 @@ class ChamberImage:
def set_jpeg(self, bytes):
self._bytes = bytes
def get_jpeg(self) -> bytearray:
return self._bytes.copy()
@dataclass
class CoverImage:
"""Returns the cover image from the Bambu API"""
@ -1317,7 +1317,7 @@ class CoverImage:
def set_jpeg(self, bytes):
self._bytes = bytes
self._image_last_updated = datetime.now()
def get_jpeg(self) -> bytearray:
return self._bytes
@ -1330,7 +1330,7 @@ class HomeFlag:
"""Contains parsed _values from the homeflag sensor"""
_value: int
_sw_ver: str
_device_type: str
_device_type: str
def __init__(self, client):
self._value = 0
@ -1359,7 +1359,7 @@ class HomeFlag:
def door_open_available(self) -> bool:
if not self._client._device.supports_feature(Features.DOOR_SENSOR):
return False
if (self._device_type in ["X1", "X1C"] and version.parse(self._sw_ver) < version.parse("01.07.00.00")):
return False
@ -1368,7 +1368,7 @@ class HomeFlag:
@property
def x_axis_homed(self) -> bool:
return (self._value & Home_Flag_Values.X_AXIS) != 0
@property
def y_axis_homed(self) -> bool:
return (self._value & Home_Flag_Values.Y_AXIS) != 0
@ -1404,7 +1404,7 @@ class HomeFlag:
@property
def sdcard_normal(self) -> bool:
return self.sdcard_present and (self._value & Home_Flag_Values.HAS_SDCARD_ABNORMAL) != SdcardState.HAS_SDCARD_ABNORMAL
@property
def ams_auto_switch_filament(self) -> bool:
return (self._value & Home_Flag_Values.AMS_AUTO_SWITCH) != 0
@ -1420,11 +1420,11 @@ class HomeFlag:
@property
def supports_motor_noise_calibration(self) -> bool:
return (self._value & Home_Flag_Values.SUPPORTS_MOTOR_CALIBRATION) != 0
@property
def p1s_upgrade_supported(self) -> bool:
return (self._value & Home_Flag_Values.SUPPORTED_PLUS) != 0
@property
def p1s_upgrade_installed(self) -> bool:
return (self._value & Home_Flag_Values.INSTALLED_PLUS) != 0
@ -1449,7 +1449,7 @@ class SlicerSettings:
def update(self):
self.custom_filaments = {}
if self._client.bambu_cloud.auth_token != "":
if self._client.bambu_cloud.auth_token != "" and self._client.local_mqtt is False:
LOGGER.debug("Loading slicer settings")
slicer_settings = self._client.bambu_cloud.get_slicer_settings()
if slicer_settings is not None:

View File

@ -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:
@ -81,6 +81,8 @@ class PrintingState(APrinterState):
return
progress = print_job_info.print_percentage
if print_job_info.gcode_state == "PREPARE" and progress == 100:
progress = 0
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())

View File

@ -20,6 +20,16 @@ $(function () {
self.job_info = ko.observable();
self.auth_type = ko.observable("");
self.show_password = ko.pureComputed(function(){
return self.settingsViewModel.settings.plugins.bambu_printer.auth_token() === '';
});
self.show_verification = ko.pureComputed(function(){
return self.auth_type() !== '';
});
self.ams_mapping_computed = function(){
var output_list = [];
var index = 0;
@ -40,16 +50,34 @@ $(function () {
self.getAuthToken = function (data) {
self.settingsViewModel.settings.plugins.bambu_printer.auth_token("");
self.auth_type("");
OctoPrint.simpleApiCommand("bambu_printer", "register", {
"email": self.settingsViewModel.settings.plugins.bambu_printer.email(),
"password": $("#bambu_cloud_password").val(),
"region": self.settingsViewModel.settings.plugins.bambu_printer.region(),
"auth_token": self.settingsViewModel.settings.plugins.bambu_printer.auth_token()
})
.done(function (response) {
self.auth_type(response.auth_response);
});
};
self.verifyCode = function (data) {
self.settingsViewModel.settings.plugins.bambu_printer.auth_token("");
OctoPrint.simpleApiCommand("bambu_printer", "verify", {
"password": $("#bambu_cloud_verify_code").val(),
"auth_type": self.auth_type(),
})
.done(function (response) {
console.log(response);
self.settingsViewModel.settings.plugins.bambu_printer.auth_token(response.auth_token);
self.settingsViewModel.settings.plugins.bambu_printer.username(response.username);
if (response.auth_token) {
self.settingsViewModel.settings.plugins.bambu_printer.auth_token(response.auth_token);
self.settingsViewModel.settings.plugins.bambu_printer.username(response.username);
self.auth_type("");
} else if (response.error) {
self.settingsViewModel.settings.plugins.bambu_printer.auth_token("");
$("#bambu_cloud_verify_code").val("");
}
});
};

View File

@ -40,15 +40,24 @@
<div class="control-group" data-bind="visible: !settingsViewModel.settings.plugins.bambu_printer.local_mqtt()">
<label class="control-label">{{ _('Email') }}</label>
<div class="controls">
<input type="text" class="input-block-level" data-bind="value: settingsViewModel.settings.plugins.bambu_printer.email" title="{{ _('Registered email address') }}"></input>
<input type="text" class="input-block-level" data-bind="value: settingsViewModel.settings.plugins.bambu_printer.email" title="{{ _('Registered email address') }}" autocomplete="off"></input>
</div>
</div>
<div class="control-group" data-bind="visible: !settingsViewModel.settings.plugins.bambu_printer.local_mqtt()">
<div class="control-group" data-bind="visible: !settingsViewModel.settings.plugins.bambu_printer.local_mqtt() && show_password()">
<label class="control-label">{{ _('Password') }}</label>
<div class="controls">
<div class="input-block-level input-append" data-bind="css: {'input-append': !show_verification()}">
<input id="bambu_cloud_password" type="password" class="input-text input-block-level" title="{{ _('Password to generate verification code') }}" autocomplete="new-password"></input>
<span class="btn btn-primary add-on" data-bind="visible: !show_verification(), click: getAuthToken">{{ _('Login') }}</span>
</div>
</div>
</div>
<div class="control-group" data-bind="visible: show_verification()">
<label class="control-label">{{ _('Verify') }}</label>
<div class="controls">
<div class="input-block-level input-append">
<input id="bambu_cloud_password" type="password" class="input-text input-block-level" title="{{ _('Password to generate Auth Token') }}"></input>
<span class="btn btn-primary add-on" data-bind="click: getAuthToken">{{ _('Login') }}</span>
<input id="bambu_cloud_verify_code" type="password" class="input-text input-block-level" title="{{ _('Verification code to generate auth token') }}"></input>
<span class="btn btn-primary add-on" data-bind="click: verifyCode">{{ _('Verify') }}</span>
</div>
</div>
</div>

View File

@ -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.8rc7"
plugin_version = "0.1.8rc11"
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module