Initialisiere BambuClient-Geräteattribut vor der MQTT-Verbindung und entferne überflüssige Initialisierung im Verbindungsstatus
This commit is contained in:
parent
5661c11190
commit
ad08d3eb9a
@ -422,6 +422,12 @@ class BambuVirtualPrinter:
|
|||||||
auth_token=self._settings.get(["auth_token"]),
|
auth_token=self._settings.get(["auth_token"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Initialisiere den BambuClient hier, bevor wir die MQTT-Verbindung herstellen
|
||||||
|
if not hasattr(bambu_client, 'device'):
|
||||||
|
self._log.debug("Initializing BambuClient device attribute")
|
||||||
|
# Stellen Sie sicher, dass wir den Client nur initialisieren, wenn er existiert
|
||||||
|
bambu_client._init_device()
|
||||||
|
|
||||||
# Set up our own MQTT client
|
# Set up our own MQTT client
|
||||||
self._mqtt_client = mqtt.Client()
|
self._mqtt_client = mqtt.Client()
|
||||||
self._mqtt_client.on_connect = self._on_mqtt_connect
|
self._mqtt_client.on_connect = self._on_mqtt_connect
|
||||||
@ -454,10 +460,6 @@ class BambuVirtualPrinter:
|
|||||||
|
|
||||||
# Explicitly set the connection status
|
# Explicitly set the connection status
|
||||||
self._custom_connected = True
|
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