Verbessere Verbindungsstatusverfolgung in BambuVirtualPrinter mit erweiterten Debug-Logs und informiere über erfolgreiche MQTT-Verbindungen
This commit is contained in:
parent
3690767ced
commit
5661c11190
@ -176,7 +176,9 @@ class BambuVirtualPrinter:
|
|||||||
@property
|
@property
|
||||||
def is_connected(self):
|
def is_connected(self):
|
||||||
"""Custom property to track connection status without modifying BambuClient directly"""
|
"""Custom property to track connection status without modifying BambuClient directly"""
|
||||||
return self._custom_connected and self._mqtt_connected
|
connection_status = self._custom_connected and self._mqtt_connected
|
||||||
|
self._log.debug(f"Connection status check: custom_connected={self._custom_connected}, mqtt_connected={self._mqtt_connected}, result={connection_status}")
|
||||||
|
return connection_status
|
||||||
|
|
||||||
def change_state(self, new_state: APrinterState):
|
def change_state(self, new_state: APrinterState):
|
||||||
self._state_change_queue.put(new_state)
|
self._state_change_queue.put(new_state)
|
||||||
@ -252,6 +254,7 @@ class BambuVirtualPrinter:
|
|||||||
client.subscribe(device_topic)
|
client.subscribe(device_topic)
|
||||||
|
|
||||||
self._log.debug(f"Subscribed to topic: {device_topic}")
|
self._log.debug(f"Subscribed to topic: {device_topic}")
|
||||||
|
self._log.info(f"MQTT connection successful. Connected: {self.is_connected}")
|
||||||
|
|
||||||
# Notify that we're connected
|
# Notify that we're connected
|
||||||
self.sendOk()
|
self.sendOk()
|
||||||
@ -448,6 +451,13 @@ class BambuVirtualPrinter:
|
|||||||
self._mqtt_client.connect(host, port, 60)
|
self._mqtt_client.connect(host, port, 60)
|
||||||
self._mqtt_client.loop_start()
|
self._mqtt_client.loop_start()
|
||||||
self._log.info(f"MQTT client started with {host}:{port}")
|
self._log.info(f"MQTT client started with {host}:{port}")
|
||||||
|
|
||||||
|
# Explicitly set the connection status
|
||||||
|
self._custom_connected = True
|
||||||
|
|
||||||
|
# Force initialize the printer connection status
|
||||||
|
if not hasattr(self._bambu_client, 'device'):
|
||||||
|
self._bambu_client._init_device()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._log.error(f"Failed to connect to MQTT broker: {e}")
|
self._log.error(f"Failed to connect to MQTT broker: {e}")
|
||||||
raise
|
raise
|
||||||
|
Loading…
x
Reference in New Issue
Block a user