Skip to content

Commit

Permalink
Merge pull request #448 from greghesp/develop
Browse files Browse the repository at this point in the history
Merge develop -> main
  • Loading branch information
AdrianGarside committed Jan 21, 2024
2 parents b09062f + 2b3d08b commit 00cd21f
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 17 deletions.
4 changes: 2 additions & 2 deletions custom_components/bambu_lab/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ async def async_step_Bambu_Lan(
fields[vol.Optional('host', default=default_host)] = TEXT_SELECTOR
fields[vol.Optional('access_code', default=self.config_entry.options.get('access_code', access_code))] = TEXT_SELECTOR
fields[vol.Optional('local_mqtt', default=self.config_entry.options.get('local_mqtt', True))] = BOOLEAN_SELECTOR
default_usage_hours = self.config_entry.options.get('usage_hours', 0) if user_input is None else user_input['usage_hours']
default_usage_hours = str(self.config_entry.options.get('usage_hours', 0)) if user_input is None else user_input['usage_hours']
fields[vol.Optional('usage_hours', default=default_usage_hours)] = NUMBER_SELECTOR

return self.async_show_form(
Expand Down Expand Up @@ -551,7 +551,7 @@ async def async_step_Lan(
default_access_code = self.config_entry.options.get('access_code', '') if user_input is None else user_input.get('access_code', self.config_entry.options.get('access_code', ''))
fields[vol.Required('host', default=default_host)] = TEXT_SELECTOR
fields[vol.Required('access_code', default=default_access_code)] = TEXT_SELECTOR
default_usage_hours = self.config_entry.options.get('usage_hours', 0) if user_input is None else user_input['usage_hours']
default_usage_hours = str(self.config_entry.options.get('usage_hours', 0)) if user_input is None else user_input['usage_hours']
fields[vol.Optional('usage_hours', default=default_usage_hours)] = NUMBER_SELECTOR

return self.async_show_form(
Expand Down
2 changes: 1 addition & 1 deletion custom_components/bambu_lab/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
"st": "urn:bambulab-com:device:3dprinter:1"
}
],
"version": "2.0.13"
"version": "2.0.14"
}
15 changes: 14 additions & 1 deletion custom_components/bambu_lab/pybambu/bambu_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ def run(self):
#
# Further attempts to receive data will get SSLWantReadError until a new image is ready (1-2 seconds later)
while connect_attempts < MAX_CONNECT_ATTEMPTS and not self._stop_event.is_set():
connect_attempts += 1
try:
with socket.create_connection((hostname, port)) as sock:
try:
connect_attempts += 1
sslSock = ctx.wrap_socket(sock, server_hostname=hostname)
sslSock.write(auth_data)
img = None
Expand Down Expand Up @@ -198,6 +198,15 @@ def run(self):
LOGGER.error(f"{self._client._device.info.device_type}: UNEXPECTED DATA RECEIVED: {len(dr)}")
time.sleep(1)

except OSError as e:
if e.errno == 113:
LOGGER.debug(f"{self._client._device.info.device_type}: Host is unreachable")
else:
LOGGER.error(f"{self._client._device.info.device_type}: A Chamber Image thread outer exception occurred:")
LOGGER.error(f"{self._client._device.info.device_type}: Exception. Type: {type(e)} Args: {e}")
if not self._stop_event.is_set():
time.sleep(1) # Avoid a tight loop if this is a persistent error.

except Exception as e:
LOGGER.error(f"{self._client._device.info.device_type}: A Chamber Image thread outer exception occurred:")
LOGGER.error(f"{self._client._device.info.device_type}: Exception. Type: {type(e)} Args: {e}")
Expand Down Expand Up @@ -244,6 +253,10 @@ def mqtt_listen_thread(self):
LOGGER.error("A listener loop thread exception occurred:")
LOGGER.error(f"Exception. Type: {type(e)} Args: {e}")
time.sleep(1) # Avoid a tight loop if this is a persistent error.

if self.client is None:
break

self.client.disconnect()

LOGGER.info("MQTT listener thread exited.")
Expand Down
6 changes: 3 additions & 3 deletions custom_components/bambu_lab/pybambu/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def print_update(self, data) -> bool:
if currently_idle and not previously_idle and previous_gcode_state != "unknown":
if self.start_time != None:
duration = self.end_time - self.start_time
new_hours = duration.seconds / 60 / 60
new_hours = int((duration.seconds / 60 / 60) * 100) / 100
LOGGER.debug(f"NEW USAGE HOURS: {new_hours}")
self._client._device.info.usage_hours += new_hours

Expand Down Expand Up @@ -1123,8 +1123,8 @@ def print_update(self, data) -> bool:
errors[f"{index}-Error"] = f"HMS_{hms_notif.hms_code}: {get_HMS_error_text(hms_notif.hms_code)}"
errors[f"{index}-Wiki"] = hms_notif.wiki_url
errors[f"{index}-Severity"] = hms_notif.severity
LOGGER.debug(f"HMS error for '{hms_notif.module}' and severity '{hms_notif.severity}': HMS_{hms_notif.hms_code}")
#errors[f"{index}-Module"] = hms_notif.module # commented out to avoid bloat with current structure
#LOGGER.debug(f"HMS error for '{hms_notif.module}' and severity '{hms_notif.severity}': HMS_{hms_notif.hms_code}")
#errors[f"{index}-Module"] = hms_notif.module # commented out to avoid bloat with current structure

if self.errors != errors:
self.errors = errors
Expand Down
4 changes: 2 additions & 2 deletions custom_components/bambu_lab/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"description": "Bitte geben Sie Ihre Bambu Lab-Zugangsdaten an:",
"data": {
"region": "Konto-Region:",
"email": "E-Mail Adresse",
"email": "E-Mail-Adresse oder Telefonnummer",
"password": "Passwort"
}
},
Expand Down Expand Up @@ -84,7 +84,7 @@
"description": "Bitte geben Sie Ihre Bambu Lab-Zugangsdaten an:",
"data": {
"region": "Konto-Region:",
"email": "E-Mail Adresse",
"email": "E-Mail-Adresse oder Telefonnummer",
"password": "Passwort"
}
},
Expand Down
4 changes: 2 additions & 2 deletions custom_components/bambu_lab/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"description": "Please provide your Bambu Lab credentials:",
"data": {
"region": "Account region:",
"email": "Email Address",
"email": "Email Address or Phone Number",
"password": "Password"
}
},
Expand Down Expand Up @@ -86,7 +86,7 @@
"description": "Please provide your Bambu Lab credentials:",
"data": {
"region": "Account region:",
"email": "Email Address",
"email": "Email Address or Phone Number",
"password": "Password"
}
},
Expand Down
4 changes: 2 additions & 2 deletions custom_components/bambu_lab/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"description": "Veuillez fournir vos informations d’identification Bambu Lab :",
"data": {
"region": "Région du compte :",
"email": "Adresse e-mail",
"email": "Adresse e-mail ou numéro de téléphone",
"password": "Mot de passe"
}
},
Expand Down Expand Up @@ -75,7 +75,7 @@
"description": "Veuillez fournir vos informations d’identification Bambu Lab :",
"data": {
"region": "Région du compte :",
"email": "Adresse e-mail",
"email": "Adresse e-mail ou numéro de téléphone",
"password": "Mot de passe"
}
},
Expand Down
4 changes: 2 additions & 2 deletions custom_components/bambu_lab/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"description": "Fornisci le tue credenziali Bambu Lab:",
"data": {
"region": "Area dell'account:",
"email": "Indirizzo e-mail",
"email": "Indirizzo e-mail o numero di telefono",
"password": "Password"
}
},
Expand Down Expand Up @@ -84,7 +84,7 @@
"description": "Fornisci le tue credenziali Bambu Lab:",
"data": {
"region": "Area dell'account:",
"email": "Indirizzo e-mail",
"email": "Indirizzo e-mail o numero di telefono",
"password": "Password"
}
},
Expand Down
4 changes: 2 additions & 2 deletions custom_components/bambu_lab/translations/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"description": "请提供您的 Bambu Lab 凭据:",
"data": {
"region": "帐户区域:",
"email": "电子邮件地址",
"email": "电子邮件地址或电话号码",
"password": "密码"
}
},
Expand Down Expand Up @@ -84,7 +84,7 @@
"description": "请提供您的 Bambu Lab 凭据:",
"data": {
"region": "帐户区域:",
"email": "电子邮件地址",
"email": "电子邮件地址或电话号码",
"password": "密码"
}
},
Expand Down
3 changes: 3 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### V2.014
- Improve handling of offline/unreachable printer in chamber image thread.

### V2.0.13
- Fix reconnect on lost connection to printer.
- Fix manual connection mode
Expand Down

0 comments on commit 00cd21f

Please sign in to comment.